BSONObjBuilder builder; builder.appendTimestamp("created_at"); // Appends a timestamp field with the key "created_at" BSONObj bson = builder.obj(); // Creates a BSON object
BSONObjBuilder builder; time_t myTime = time(0); builder.appendTimestamp("last_updated", myTime); // Appends a timestamp field with the key "last_updated" and the specified timestamp BSONObj bson = builder.obj(); // Creates a BSON objectIn this example, a specific timestamp is appended as a timestamp field to the BSON object being constructed. Package Library: The BSONObjBuilder class is part of the MongoDB C++ driver library.