我正在尝试做一些应该很简单的事情,但显然我做错了。任何帮助,将不胜感激。
我知道_id
文件的内容,我只想验证它available_uses
是$gte 1
简单文档样本:
{
"_id" : ObjectId("572f4d6f6d210e5c2d60cc41"),
"invite_data" : "something useful here",
"available_uses" : NumberInt(25),
}
我尝试了以下 BCON,但它不起作用。我能够编译而没有任何错误,但是当我运行它时,应用程序会在query
设置行后立即死亡,因此显然该结构存在问题。没有错误,只是应用程序退出。
query = bson_new ();
bson_oid_t oid;
bson_oid_init_from_string (&oid, invite_id);
query = BCON_NEW ("_id", BCON_OID(&oid),
"{",
"available_uses",
"{",
"$gte", BCON_INT32 (1)
"}",
"}");
// Find the document
cursor = mongoc_collection_find (collection, MONGOC_QUERY_NONE, 0, 0, 0, query, NULL, NULL);