1MONGOC_COLLECTION_DELETE_ONE(3) libmongoc MONGOC_COLLECTION_DELETE_ONE(3)
2
3
4
6 mongoc_collection_delete_one - mongoc_collection_delete_one()
7
9 bool
10 mongoc_collection_delete_one (mongoc_collection_t *collection,
11 const bson_t *selector,
12 const bson_t *opts,
13 bson_t *reply,
14 bson_error_t *error);
15
17 • collection: A mongoc_collection_t.
18
19 • selector: A bson_t containing the query to match documents.
20
21 • reply: Optional. An uninitialized bson_t populated with the delete
22 result, or NULL.
23
24 • error: 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
28 • writeConcern: 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
32 • sessionId: 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
39 • validate: 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
43 • comment: 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
47 • collation: Configure textual comparisons. See Setting Collation Or‐
48 der, and the MongoDB Manual entry on Collation. Collation requires
49 MongoDB 3.2 or later, otherwise an error is returned.
50
51 • hint: A document or string that specifies the index to use to support
52 the query predicate.
53
54 • let: A BSON document consisting of any number of parameter names,
55 each followed by definitions of constants in the MQL Aggregate Ex‐
56 pression language.
57
59 This function removes at most one document in the given collection that
60 matches selector.
61
62 To delete all matching documents, use mongoc_collection_delete_many().
63
64 If you pass a non-NULL reply, it is filled out with the field "deleted‐
65 Count". If there is a server error then reply contains either a
66 "writeErrors" array with one subdocument or a "writeConcernErrors" ar‐
67 ray. The reply must be freed with bson_destroy().
68
70 Errors are propagated via the error parameter.
71
73 Returns true if successful. Returns false and sets error if there are
74 invalid arguments or a server or network error.
75
77 MongoDB, Inc
78
80 2017-present, MongoDB, Inc
81
82
83
84
851.23.1 Oct 20, 2022 MONGOC_COLLECTION_DELETE_ONE(3)