Atomicity of Model.create in Mongoose when passing an array of documents Atomicity of Model.create in Mongoose when passing an array of documents mongoose mongoose

Atomicity of Model.create in Mongoose when passing an array of documents


MongoDB Wire Protocol accepts either single document or multiple documents with OP_INSERT. However, on the server they are still inserted one at a time.

In other words, if the server were to crash part-way through the insert, some documents would be inserted and others would not be. Within each document you are guaranteed consistent view of it - either it's all inserted or it's not. But for multiple documents no such guarantee exists.