C++ 在mongo-c-driver或mongo cxx驱动程序中升级文档后如何获取“\u id”?
在mongo-c-driver或mongo cxx驱动程序中升级文档后如何获取C++ 在mongo-c-driver或mongo cxx驱动程序中升级文档后如何获取“\u id”?,c++,c,mongodb,mongo-c-driver,mongo-cxx-driver,C++,C,Mongodb,Mongo C Driver,Mongo Cxx Driver,在mongo-c-driver或mongo cxx驱动程序中升级文档后如何获取\u id 下面的代码片段来自mongo shell,它显示了WriteResult最后一行的\u id字段 db.coll.update( { item: "ZZZ135" }, { item: "ZZZ135", stock: 5, tags: [ "database" ] }, {upsert: true}
\u id
下面的代码片段来自mongo shell,它显示了WriteResult
最后一行的\u id
字段
db.coll.update(
{ item: "ZZZ135" },
{ item: "ZZZ135", stock: 5, tags: [ "database" ] },
{upsert: true}
)
WriteResult({
"nMatched" : 0,
"nUpserted" : 1,
"nModified" : 0,
"_id" : ObjectId("54455f33b247e073d7161b32")
})
在mongo C驱动程序中,您可以使用
bson\t*reply
在以下位置接收返回的\u id
:
<> > C++中的等价项是<代码> bSONOB**FIG/<代码>:
bool mongoc_collection_command_simple (
mongoc_collection_t *collection,
const bson_t *command,
const mongoc_read_prefs_t *read_prefs,
bson_t *reply,
bson_error_t *error
)
bool mongo::DBClientWithCommands::simpleCommand (
const std::string & dbname,
BSONObj * info,
const std::string & command
)