BSON_COPY_TO_EXCLUDING_NOINIT(3)
π BSON_COPY_TO_EXCLUDING_NOINIT(3) π
okay bestie, welcome to the libbson manual page for bson_copy_to_excluding_noinit β itβs giving βcopy this bson but skip the keys I said to skipβ energy. β¨
β¨ SYNOPSIS β¨
void
bson_copy_to_excluding_noinit (const bson_t *src,
bson_t *dst,
const char *first_exclude,
...);
π«Ά PARAMETERS π«Ά
srcβ abson_t. πΈ the source bson, the one youβre copying from.dstβ abson_t. π the destination bson, the one getting the fields.first_excludeβ the first field name to exclude. π this is where the variadic,NULLterminated list of keys to exclude starts.
π DESCRIPTION π
so the bson_copy_to_excluding_noinit() function shall copy all fields from src to dst except those specified by the variadic, NULL terminated list of keys starting from first_exclude. π«‘ like, you pass the first field name to exclude, then more field names, then NULL to end the list, and those fields do not make the copy. slay.
the big detail: it does not call bson_init() on dst. not even once. π¨ thatβs literally what the _noinit is telling you, iykyk.
WARNING: this is generally not needed except in very special situations. and we mean very special β donβt just casually reach for it unless you know youβre in one of those situations. π
πΈ EXAMPLE πΈ
hereβs the demo, copied exactly so you can see how it goes: π¦
#include <bson/bson.h>
int main ()
{
bson_t bson;
bson_t bson2;
char *str;
bson_init (&bson);
bson_append_int32 (&bson, "a", 1, 1);
bson_append_int32 (&bson, "b", 1, 2);
bson_append_int32 (&bson, "c", 1, 2);
bson_init (&bson2);
bson_copy_to_excluding_noinit (&bson, &bson2, "b", NULL);
str = bson_as_relaxed_extended_json (&bson2, NULL);
/* Prints
* { "a" : 1, "c" : 2 }
*/
printf ("%s\n", str);
bson_free (str);
bson_destroy (&bson);
bson_destroy (&bson2);
}
the comment in there says it prints { "a" : 1, "c" : 2 } β because "b" got excluded and NULL ends the list. iconic. π
π AUTHOR π
MongoDB, Inc β yes, the MongoDB girlies. π«Ά
π COPYRIGHT π
2009-present, MongoDB, Inc. β periodt. π
okay thatβs the whole page, bestie! from the libbson manual, version 2.5.6, dated Oct 09, 2026 β bye, love you, go copy responsibly ππ
π¦π
π¦ where this page comes from
- epel 10: libbson-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