MongoCollectionInsert
MongoCollectionInsert[MongoCollection[…],doc]
inserts a document doc into the collection.
MongoCollectionInsert[MongoCollection[…],{doc1,…,docn}]
inserts n documents into the collection.
更多信息和选项
- 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.
范例
基本范例 (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:
文本
Wolfram Research (2018),MongoCollectionInsert,Wolfram 语言函数,https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionInsert.html.
CMS
Wolfram 语言. 2018. "MongoCollectionInsert." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionInsert.html.
APA
Wolfram 语言. (2018). MongoCollectionInsert. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/MongoLink/ref/MongoCollectionInsert.html 年