BSON_APPEND_TIMESTAMP(3)
π BSON_APPEND_TIMESTAMP π
okay so bestie, welcome to the libbson girlies' corner of the manual β this one's about BSON_APPEND_TIMESTAMP, and it's lowkey iconic for how much it is not the date-time function. buckle up π
β¨ SYNOPSIS β¨
the macro version, for when you're feeling efficient:
#define BSON_APPEND_TIMESTAMP(b, key, val, inc) \
bson_append_timestamp (b, key, (int) strlen (key), val, inc)
and the real function underneath, doing the actual work:
bool
bson_append_timestamp (bson_t *bson,
const char *key,
int key_length,
uint32_t timestamp,
uint32_t increment);
πΈ PARAMETERS πΈ
bsonβ abson_t. that's the doc you're stuffing things into, bestie π«Άkeyβ an ASCII C string with the name of the field. cute, short, ASCII.key_lengthβ how longkeyis, in bytes. orrr you can pass-1and let it figure the length out withstrlen(). main character energy honestly β¨timestampβ auint32_t. yes, exactly that type, don't come at me.incrementβ anotheruint32_t. it's a whole separate field, we'll get to it π
π¦ DESCRIPTION π¦
okay so FIRST thing's first, and I need you to really hear me on this one: this function is not similar in functionality to bson_append_date_time(). like, not even a little. they are different girls, they serve different purposes, do not confuse them π
timestamp elements are different in that they include only second precision and an increment field. that's it. that's the whole vibe. no fancy sub-second anything, just seconds plus that little increment riding along π
they are primarily used for intra-MongoDB server communication. iykyk β it's an internal thing, it's giving "backstage pass only" π«
and the actual deed: bson_append_timestamp() shall append a new element of type BSON_TYPE_TIMESTAMP. slay β¨
β RETURNS β
returns true if the operation was applied successfully β we love a happy ending π
β οΈ but heads up: the function will fail if appending the value growsbsonlarger thanINT32_MAX. like, that's the line, and we do not cross it. π
π AUTHOR π
MongoDB, Inc β icons only, no notes π
π COPYRIGHT π
2009-present, MongoDB, Inc. β a long and storied reign, periodt π
and that's the page, bestie! go forth and append those timestamps, and remember: second precision only, increment included, and absolutely not bson_append_date_time(). mwah π
β signed with love from the libbson 2.5.6 girlies, dated Oct 09, 2026 π§ββοΈπ
π¦ 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