1MONGOC_COLLECTION_INSERT_ONE(3)    libmongoc   MONGOC_COLLECTION_INSERT_ONE(3)
2
3
4

NAME

6       mongoc_collection_insert_one - mongoc_collection_insert_one()
7

SYNOPSIS

9          bool
10          mongoc_collection_insert_one (mongoc_collection_t *collection,
11                                        const bson_t *document,
12                                        const bson_t *opts,
13                                        bson_t *reply,
14                                        bson_error_t *error);
15

PARAMETERS

17collection: A mongoc_collection_t.
18
19document: A bson_t.
20
21reply:  Optional.  An  uninitialized bson_t populated with the insert
22         result, or NULL.
23
24error: An optional location for a bson_error_t or NULL.
25
26       opts may be NULL or a BSON document with additional command options:
27
28writeConcern:   Construct   a    mongoc_write_concern_t    and    use
29         mongoc_write_concern_append()  to  add the write concern to opts. See
30         the example code for mongoc_client_write_command_with_opts().
31
32sessionId:   First,   construct   a   mongoc_client_session_t    with
33         mongoc_client_start_session().  You  can  begin  a  transaction  with
34         mongoc_client_session_start_transaction(),    optionally    with    a
35         mongoc_transaction_opt_t  that  overrides  the options inherited from
36         collection, and use mongoc_client_session_append() to add the session
37         to opts. See the example code for mongoc_client_session_t.
38
39validate:     Construct     a     bitwise-or     of    all    desired
40         bson_validate_flags_t. Set to false to skip client-side validation of
41         the provided BSON documents.
42
43comment: A bson_value_t specifying the comment to attach to this com‐
44         mand. The comment will appear in log messages, profiler  output,  and
45         currentOp output. Requires MongoDB 4.4 or later.
46
47bypassDocumentValidation: Set to true to skip server-side schema val‐
48         idation of the provided BSON documents.
49

DESCRIPTION

51       This function shall insert document into collection.
52
53       To insert an array of documents, see mongoc_collection_insert_many().
54
55       If no _id element is found in document, then a bson_oid_t will be  gen‐
56       erated locally and added to the document. If you must know the inserted
57       document's _id, generate it in your code and include it  in  the  docu‐
58       ment.  The  _id you generate can be a bson_oid_t or any other non-array
59       BSON type.
60
61       If you pass a non-NULL reply, it is filled out with an  "insertedCount"
62       field.  If  there  is  a  server  error  then  reply  contains either a
63       "writeErrors" array with one subdocument or a "writeConcernErrors"  ar‐
64       ray. The reply must be freed with bson_destroy().
65

ERRORS

67       Errors are propagated via the error parameter.
68

RETURNS

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

AUTHOR

76       MongoDB, Inc
77
79       2017-present, MongoDB, Inc
80
81
82
83
841.23.1                           Oct 20, 2022  MONGOC_COLLECTION_INSERT_ONE(3)
Impressum