MONGOC_COLLECTION_DELETE_ONE(3)
π MONGOC_COLLECTION_DELETE_ONE π
okay bestie, welcome to the libmongoc manual page for mongoc_collection_delete_one β yes that's the whole manual name, we're not copying the header line, we're living it β¨
This is the function that deletes exactly one document and honestly? she's an icon, she's a legend, and she is the moment π₯
β¨ SYNOPSIS β¨
bool
mongoc_collection_delete_one (mongoc_collection_t *collection,
const bson_t *selector,
const bson_t *opts,
bson_t *reply,
bson_error_t *error);
like, look at that signature. no cap, it ate π
π PARAMETERS π
collectionβ amongoc_collection_t. literally the collection you're deleting from, she's the main character here πselectorβ abson_tholding the query that matches documents. this is how you tell her which doc you mean π―replyβ a maybe-NULLpointer to overwritable storage for abson_tthat will contain the results. maybe-NULLis so real of her πerrorβ an optional location for abson_error_t, orNULL. your choice bestie π«Ά
so opts can be NULL, or a BSON document with extra command options, and here's the whole lineup:
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()π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, and currentOp output. requires MongoDB 4.4 or later π¦collationβ configure textual comparisons. see Setting Collation Order, and the MongoDB Manual entry on Collation. collation requires MongoDB 3.2 or later, otherwise an error is returned πhintβ a document or string that specifies the index to use to support the query predicate πletβ a BSON document consisting of any number of parameter names, each followed by definitions of constants in the MQL Aggregate Expression language πΈ
π DESCRIPTION π
this function removes at most one document in the given collection that matches selector. one. single. document. she's not greedy, she's discerning π
if you need to delete all the matching documents, use mongoc_collection_delete_many() β different function, different vibe, go look her up π
if you pass a non-NULL reply, it gets filled out with the field "deletedCount". and if there's a server error then reply contains either a "writeErrors" array with one subdocument, or a "writeConcernErrors" array. either way, that reply must be freed with bson_destroy(). don't forget, bestie, that's a memory leak waiting to happen π
π₯ ERRORS π₯
errors are propagated via the error parameter. that's it, that's the whole section, she's lowkey mysterious about it π
π RETURNS π
returns true if successful. returns false and sets error if there are invalid arguments or a server or network error. simple as that, no cap β¨
π AUTHOR π
MongoDB, Inc π
β COPYRIGHT β
2009-present, MongoDB, Inc. β protect her at all costs π«Ά
and that's the page, babes!! sign-off time: this was libmongoc version 2.5.6, dated Oct 09, 2026, and honestly? she's giving timeless. go delete exactly one document, drink some water, and remember that bson_destroy() is self care πππ¦π
π¦ 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