Let's say I have an JavaScript Array companyBills and inside of it I have m objects stored in such manner; with m > 100.000 elements.
{key_0:value_0, key_1:value_0_1, key_n:value_0_n},
{key_0:value_1, key_1:value_1_1, key_n:value_1_n},
{key_0:value_m, key_1:value_m_1, key_n:value_m_n}
Now I want to store this in MongoDB via Mongoose, in such a manner:
CompanyBills.create (companyBills, function(err, jellybean, snickers) {
if(!err) {
console.log('Success');
} else {
console.log('Error');
}
However the array companyBills is too huge. Thus I want to store in chunks of 1/100 m. How to split the array companyBills Time-efficiently and store in MongoDB?
I am creating the array with https://github.com/SheetJS/js-xlsx, maybe there is an opportunity to hook-in early.
asynclibrary for put each chunk into the db in parallel