express-restify-mongoose icon indicating copy to clipboard operation
express-restify-mongoose copied to clipboard

Option to use InsertMany when creating array of objects

Open RuneSP opened this issue 3 years ago • 1 comments

Looking through the code, it seems the standard mongoose create method is also used when passing an array of objects.

Would it be possible to add an option to use InsertMany instead when passing an array of objects? InsertMany is faster as it will only send one operation to database instead of one for each document.

https://mongoosejs.com/docs/api/model.html#model_Model.insertMany

Thanks, Rune

RuneSP avatar Apr 15 '21 09:04 RuneSP

As far as I can remember, the only reason we don't use insertMany is that it didn't exist back then.

Zertz avatar Oct 24 '22 02:10 Zertz