March 2019
Intermediate to advanced
394 pages
11h 4m
English
In the case of inserts, we can generally expect that the order of operations doesn't matter.
bulk, however, can be used with many more operations than just inserts. In the following example, we have a single book with isbn : 101 and the name of Mastering MongoDB in a bookOrders collection with the number of available copies to purchase in the available field, with the 99 books available for purchase:
> db.bookOrders.find(){ "_id" : ObjectId("59204793141daf984112dc3c"), "isbn" : 101, "name" : "Mastering MongoDB", "available" : 99 }
With the following series of operations in a single bulk operation, we are adding one book to the inventory and then ordering 100 books, for a final total of zero copies available: ...
Read now
Unlock full access