skip to Main Content

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


  1. 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!!!

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search