MONGOC_COLLECTION_INSERT_MANY(3)
π
MONGOC_COLLECTION_INSERT_MANY(3) β libmongoc π
okay bestie, welcome to the libmongoc manual page for MONGOC_COLLECTION_INSERT_MANY(3) β the batch-insert function that is literally here to slide a whole array of documents into a collection. no cap, itβs giving bulk-insert main character energy. β¨
β¨ SYNOPSIS β¨
bool
mongoc_collection_insert_many (mongoc_collection_t *collection,
const bson_t **documents,
size_t n_documents,
const bson_t *opts,
bson_t *reply,
bson_error_t *error);
π«Ά PARAMETERS π«Ά
collectionβ amongoc_collection_t, aka the collection girlie in question.documentsβ an array of pointers tobson_t. Yes, plural β itβs a whole lineup.n_documentsβ the length ofdocuments, aka how many besties are in the array.replyβ a maybe-NULLpointer to overwritable storage for abson_tto contain the results.errorβ an optional location for abson_error_torNULL.
opts may be NULL or a BSON document with additional command options:
writeConcernβ construct amongoc_write_concern_tand usemongoc_write_concern_append()to add the write concern toopts. See the example code formongoc_client_write_command_with_opts()β it has the receipts.sessionIdβ first, construct amongoc_client_session_twithmongoc_client_start_session(). You can begin a transaction withmongoc_client_session_start_transaction(), optionally with amongoc_transaction_opt_tthat overrides the options inherited fromcollection, and usemongoc_client_session_append()to add the session toopts. See the example code formongoc_client_session_t.validateβ construct a bitwise-or of all desiredbson_validate_flags_t. Set tofalseto skip client-side validation of the provided BSON documents.commentβ abson_value_tspecifying the comment to attach to this command. The comment will appear in log messages, profiler output, andcurrentOpoutput. Requires MongoDB 4.4 or later.orderedβ set tofalseto attempt to insert all documents, continuing after errors β yes, even the messy ones.bypassDocumentValidationβ set totrueto skip server-side schema validation of the provided BSON documents.
π¦ DESCRIPTION π¦
Insert documents into collection. Thatβs the whole vibe.
To insert a single document, see mongoc_collection_insert_one().
For any document that does not have an "_id" field, a bson_oid_t will be generated locally and added to the document β lowkey magic, but documented magic. If you must know the inserted document's _id, generate it in your code and include it in the document. The _id you generate can be a bson_oid_t or any other non-array BSON type.
If you pass a non-NULL reply, it is filled out with an "insertedCount" field. If there is a server error then reply may contain a "writeErrors" array and/or a "writeConcernErrors" array (see Bulk Write Operations for examples). The reply must be freed with bson_destroy() β do not ghost it. π
π ERRORS π
Errors are propagated via the error parameter. Periodt.
π RETURNS π
Returns true if successful. Returns false and sets error if there are invalid arguments or a server or network error.
A write concern timeout or write concern error is considered a failure β no cap, thatβs a fail.
π AUTHOR π
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
thatβs the whole page, bestie! π source/version: 2.5.6 Β· date: Oct 09, 2026 Β· manual: MONGOC_COLLECTION_INSERT_MANY(3) β now go insert many, fr fr π
β¨
π¦ where this page comes from
- epel 10: mongo-c-driver-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms