How can I update or insert bulk operations in Meteor Mongodb?
Here is my simple script:
var obj = [];
for(var i = 0; i < 100000; i++){
obj.push({title: i, inTime: new Date(), outTime: new Date})
}
Activities.bulkWrite([
{
insertMany: obj
}
])
Why I am getting this error:
Exception while invoking method TypeError: Activities.bulkWrite is not a function
2
Answers
Not sure of what is Activities is referred to here.
If Activities is the schema or collection object, then just use as
Activities.insertMany
function to insert all the records to your database collection.Hope this helps!!!
Meteor Collection object doesn’t have the bulkWrite function. Remember, Meteor uses a lib to provide MongoDB function. To access the native functions of MongoDB in a collection, you need to use
rawCollection
. See here.