1MONGOC_COLLECTION_INSERT_MANY(3)   libmongoc  MONGOC_COLLECTION_INSERT_MANY(3)
2
3
4

NAME

6       mongoc_collection_insert_many - mongoc_collection_insert_many()
7

SYNOPSIS

9          bool
10          mongoc_collection_insert_many (mongoc_collection_t *collection,
11                                         const bson_t **documents,
12                                         size_t n_documents,
13                                         const bson_t *opts,
14                                         bson_t *reply,
15                                         bson_error_t *error);
16

PARAMETERS

18collection: A mongoc_collection_t.
19
20documents: An array of pointers to bson_t.
21
22n_documents: The length of documents.
23
24reply:  Optional.  An  uninitialized bson_t populated with the insert
25         result, or NULL.
26
27error: An optional location for a bson_error_t or NULL.
28
29       opts may be NULL or a BSON document with additional command options:
30
31writeConcern:  Construct  a  mongoc_write_concern_t  and   use   mon‐
32         goc_write_concern_append  to  add  the write concern to opts. See the
33         example code for mongoc_client_write_command_with_opts.
34
35sessionId:  First,  construct  a  mongoc_client_session_t  with  mon‐
36         goc_client_start_session.  You  can  begin  a  transaction  with mon‐
37         goc_client_session_start_transaction, optionally with a mongoc_trans‐
38         action_opt_t  that  overrides  the options inherited from collection,
39         and use mongoc_client_session_append to add the session to opts.  See
40         the example code for mongoc_client_session_t.
41
42validate:     Construct     a     bitwise-or     of    all    desired
43         bson_validate_flags_t. Set to false to skip client-side validation of
44         the provided BSON documents.
45
46ordered:  set to false to attempt to insert all documents, continuing
47         after errors.
48
49bypassDocumentValidation: Set to true to skip server-side schema val‐
50         idation of the provided BSON documents.
51

DESCRIPTION

53       Insert documents into collection.
54
55       To insert a single document, see mongoc_collection_insert_one.
56
57       For  any  document that does not have an "_id" field, a bson_oid_t will
58       be generated locally and added to the document. If you  must  know  the
59       inserted document's _id, generate it in your code and include it in the
60       document. The _id you generate can be a bson_oid_t or any other non-ar‐
61       ray BSON type.
62
63       If  you pass a non-NULL reply, it is filled out with an "insertedCount"
64       field. If there is a server error then reply may  contain  a  "writeEr‐
65       rors"  array and/or a "writeConcernErrors" array (see Bulk Write Opera‐
66       tions for examples). The reply must be freed with bson_destroy().
67

ERRORS

69       Errors are propagated via the error parameter.
70

RETURNS

72       Returns true if successful. Returns false and sets error if  there  are
73       invalid arguments or a server or network error.
74
75       A write concern timeout or write concern error is considered a failure.
76

AUTHOR

78       MongoDB, Inc
79
81       2017-present, MongoDB, Inc
82
83
84
85
861.20.0                           Nov 18, 2021 MONGOC_COLLECTION_INSERT_MANY(3)
Impressum