MongoCollectionInsert
MongoCollectionInsert[MongoCollection[…],doc]
inserts a document doc into the collection.
MongoCollectionInsert[MongoCollection[…],{doc1,…,docn}]
inserts n documents into the collection.
Details and Options
- To use MongoCollectionInsert, you first need to load MongoLink using Needs["MongoLink`"].
- MongoCollectionInsert returns a MongoInsertResult object.
- Each document docn is an Association that must be convertible to the "BSON" format. Documents that cannot be converted to the BSON format will cause an insertion failure.
- The following options are supported:
-
"Ordered" True whether to insert documents in the given order. "WriteConcern" Automatic the write concern to use. - "WriteConcern" can either be Automatic, or a MongoWriteConcern object.
- If "Ordered" is True, documents will be inserted on the server serially, in the order provided. If an error occurs all remaining inserts are aborted. If False, documents will be inserted on the server in arbitrary order, possibly in parallel, and all document inserts will be attempted.
- MongoCollectionInsert corresponds to db.collection.insertMany.
- MongoDB puts a size restriction of 16 megabytes on BSON documents to insert.
Examples
Basic Examples (1)
Connect to a the "WolframTestCollection" collection in the "WolframTestDB" database:
Create an data association to represent a document:
Insert one document into the collection:
Obtain a list of the primary keys of the inserted documents:
Create an data association to represent a series of documents:
Text
Wolfram Research (2018), MongoCollectionInsert, Wolfram Language function, https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionInsert.html.
CMS
Wolfram Language. 2018. "MongoCollectionInsert." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionInsert.html.
APA
Wolfram Language. (2018). MongoCollectionInsert. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionInsert.html