Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform a bulk insert via sails-mongo and sails.js?

Is there a way to perform a bulk insert via sails-mongo. So if I pass an array of documents to the model's create method, it will insert each document within that array atomically into the database?

like image 320
ses Avatar asked Jul 01 '14 10:07

ses


1 Answers

It works exactly like you asked:

Model.create([{foo: "first},{foo:"2nd"}]).exec(...

See http://beta.sailsjs.org/#/documentation/reference/Models/Model-Methods/create.html

like image 112
mdunisch Avatar answered Sep 20 '22 03:09

mdunisch