1MONGOC_COLLECTION_DELETE_ONE(3) libmongoc MONGOC_COLLECTION_DELETE_ONE(3)
2
3
4
6 bool
7 mongoc_collection_delete_one (mongoc_collection_t *collection,
8 const bson_t *selector,
9 const bson_t *opts,
10 bson_t *reply,
11 bson_error_t *error);
12
14 • collection: A mongoc_collection_t.
15
16 • selector: A bson_t containing the query to match documents.
17
18 • reply: Optional. An uninitialized bson_t populated with the delete
19 result, or NULL.
20
21 • error: An optional location for a bson_error_t or NULL.
22
23 opts may be NULL or a BSON document with additional command options:
24
25 • writeConcern: Construct a mongoc_write_concern_t and use
26 mongoc_write_concern_append() to add the write concern to opts. See
27 the example code for mongoc_client_write_command_with_opts().
28
29 • sessionId: First, construct a mongoc_client_session_t with
30 mongoc_client_start_session(). You can begin a transaction with
31 mongoc_client_session_start_transaction(), optionally with a
32 mongoc_transaction_opt_t that overrides the options inherited from
33 collection, and use mongoc_client_session_append() to add the session
34 to opts. See the example code for mongoc_client_session_t.
35
36 • validate: Construct a bitwise-or of all desired
37 bson_validate_flags_t. Set to false to skip client-side validation of
38 the provided BSON documents.
39
40 • comment: A bson_value_t specifying the comment to attach to this com‐
41 mand. The comment will appear in log messages, profiler output, and
42 currentOp output. Requires MongoDB 4.4 or later.
43
44 • collation: Configure textual comparisons. See Setting Collation Or‐
45 der, and the MongoDB Manual entry on Collation. Collation requires
46 MongoDB 3.2 or later, otherwise an error is returned.
47
48 • hint: A document or string that specifies the index to use to support
49 the query predicate.
50
51 • let: A BSON document consisting of any number of parameter names,
52 each followed by definitions of constants in the MQL Aggregate Ex‐
53 pression language.
54
56 This function removes at most one document in the given collection that
57 matches selector.
58
59 To delete all matching documents, use mongoc_collection_delete_many().
60
61 If you pass a non-NULL reply, it is filled out with the field "deleted‐
62 Count". 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
67 Errors are propagated via the error parameter.
68
70 Returns true if successful. Returns false and sets error if there are
71 invalid arguments or a server or network error.
72
74 MongoDB, Inc
75
77 2017-present, MongoDB, Inc
78
79
80
81
821.25.1 Nov 08, 2023 MONGOC_COLLECTION_DELETE_ONE(3)