Does inserting multiple documents in a Meteor Collection work the same as pure mongodb?

前端 未结 4 941
终归单人心
终归单人心 2021-02-13 04:52

It seems I can\'t do a multiple insert in Meteor the same way it is described here in the Mongodb documentation...

In my js console :

> Test.insert([{na

4条回答
  •  温柔的废话
    2021-02-13 05:16

    From the Meteor leaderboard example code, it looks like you cannot bulk insert. You can either use a loop or underscore iteration function.

    Using underscore,

    var names = [{name:'hello'},{name:'hello again'}]
    
    _.each(names, function(doc) { 
      Test.insert(doc);
    })
    

提交回复
热议问题