| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
MongoDB.BulkOperation.Execute
Executes all operations queued into the bulk operation.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| MongoDB | 16.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "MongoDB.BulkOperation.Execute"; MongoDBRef ) More
Parameters
| Parameter | Description | Example |
|---|---|---|
| MongoDBRef | The reference number for the mongo connection. | $MongoDB |
Result
Returns JSON or error.
Description
Executes all operations queued into the bulk operation.Unless ordered = false was specified in the opts passed to MongoDB.BulkOperation.Create, then forward progress will be stopped upon the first error.
It is only valid to call MongoDB.BulkOperation.Execute once. The bulk operation must be destroyed afterwards.
Returns the result or raises an exception.
Sets the used server id, which you can query with MongoDB.BulkOperation.GetUsedServerId function.
Examples
Insert two records:
# insert a record with bulk operation
Set Variable [ $r ; Value: MBS( "MongoDB.BulkOperation.Create"; $Mongo ) ]
# add multiple changes
Set Variable [ $r ; Value: MBS( "MongoDB.BulkOperation.Insert"; $Mongo; JSONSetElement ( "{}"; ["First"; "Joe"; JSONString]; ["Last"; "Jones"; JSONString] )) ]
Set Variable [ $r ; Value: MBS( "MongoDB.BulkOperation.Insert"; $Mongo; JSONSetElement ( "{}"; ["First"; "Dave"; JSONString]; ["Last"; "Daniels"; JSONString] )) ]
# and run it
Set Variable [ $r ; Value: MBS( "MongoDB.BulkOperation.Execute"; $Mongo ) ]
Show Custom Dialog [ "Result" ; $r ]
Example result:
{ "nInserted" : 2, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "nUpserted" : 0, "writeErrors" : [ ] }
Set Variable [ $r ; Value: MBS( "MongoDB.BulkOperation.Create"; $Mongo ) ]
# add multiple changes
Set Variable [ $r ; Value: MBS( "MongoDB.BulkOperation.Insert"; $Mongo; JSONSetElement ( "{}"; ["First"; "Joe"; JSONString]; ["Last"; "Jones"; JSONString] )) ]
Set Variable [ $r ; Value: MBS( "MongoDB.BulkOperation.Insert"; $Mongo; JSONSetElement ( "{}"; ["First"; "Dave"; JSONString]; ["Last"; "Daniels"; JSONString] )) ]
# and run it
Set Variable [ $r ; Value: MBS( "MongoDB.BulkOperation.Execute"; $Mongo ) ]
Show Custom Dialog [ "Result" ; $r ]
Example result:
{ "nInserted" : 2, "nMatched" : 0, "nModified" : 0, "nRemoved" : 0, "nUpserted" : 0, "writeErrors" : [ ] }
See also
- MongoDB.BulkOperation.Close
- MongoDB.BulkOperation.Create
- MongoDB.BulkOperation.GetLet
- MongoDB.BulkOperation.GetUsedServerId
- MongoDB.BulkOperation.Insert
- MongoDB.BulkOperation.RemoveMany
- MongoDB.BulkOperation.RemoveOne
- MongoDB.BulkOperation.ReplaceOne
- MongoDB.BulkOperation.SetLet
- MongoDB.BulkOperation.UpdateMany
Example Databases
Blog Entries
This function checks for a license.
Created 9th August 2026, last changed 21st October 2026
MongoDB.BulkOperation.Create - MongoDB.BulkOperation.GetBypassDocumentValidation
MarkDown version: MongoDBBulkOperationExecute.md