Mongodb 如何使用选项从mongoc_collection_find_检索数据
以下是我用C编写的代码片段,为便于阅读而进行了编辑:Mongodb 如何使用选项从mongoc_collection_find_检索数据,mongodb,bson,mongo-c-driver,Mongodb,Bson,Mongo C Driver,以下是我用C编写的代码片段,为便于阅读而进行了编辑: bCursor = mongoc_collection_find_with_opts(...); mongoc_cursor_next(bCursor, &bDoc); 我在bDoc中以json的形式获取文档: { "_id" : { "$numberInt" : "4184300" }, "msgTime" : { "$numberInt" : "969481160" }, "msgLTm" : { "$numberI
bCursor = mongoc_collection_find_with_opts(...);
mongoc_cursor_next(bCursor, &bDoc);
我在bDoc中以json的形式获取文档:
{
"_id" : { "$numberInt" : "4184300" },
"msgTime" : { "$numberInt" : "969481160" },
"msgLTm" : { "$numberInt" : "969484760" }
}
如何输入字段id、msgTime或msgLTm
我试过了
if (bson_iter_init(&bIter, (bson_t *)&cDoc) && bson_iter_find_descendant(&bIter, "_id", &bVal))
....
但是没有用。。因为可能没有后代
任何反馈都将不胜感激。
干杯你已经编辑了一堆,但是当你展示你把bson放在bDoc中时,你展示的是bson iter init和任何cDoc。cDoc从哪里来的?是的。。。我的错;感谢您调查并指出这一点。