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

前端 未结 4 956
终归单人心
终归单人心 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条回答
  •  -上瘾入骨i
    2021-02-13 05:18

    For inserting multiple records in your collection you can use mikowals:batch-insert plugin.

    a simple example it would be :

    var names = [{name:'hello'},{name:'hello again'}];
    yourCollection.batchInsert(names);
    

    What you get here is using only one connection you will be able to insert all data in one go same as mongo bulk insert operation.

提交回复
热议问题