I am creating array of objects first, then I want to run insertMany function, but nothing happens.
By ‘nothing happens’ do you mean no document was inserted ? Did you see any error messages ?
For insertMany function, each group of operations can have at most 1000 operations. If a group exceeds this limit, MongoDB will divide the group into smaller groups of 1000 or less. For example, if the queue consists of 2000 operations, MongoDB creates 2 groups, each with 1000 operations.
The sizes and grouping mechanics are internal performance details and are subject to change in future versions. You can further read about insertMany behaviours in the MongoDB manual.
One sample code that works in mongo shell with v3.2 server is below:
arr = [];
for (i =0; i < 1000000 ; i++) {
arr.push({ "x" : i }) ;
}
//set ordered to false to make inserts faster
db.bulk.insertMany(arr, { ordered: false})
If you have further questions, can you please provide the information below:
Regards,
Nishant
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/56f856ce-15a0-48bd-a091-7537a1960d22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.