gpt4 book ai didi

复杂查询mongodb c

转载 作者:行者123 更新时间:2023-11-30 19:49:46 25 4
gpt4 key购买 nike

我已经像这样创建了我的 mongodb 查询 >

 86     bson query[1];
87 bson_init(query);
88 bson_append_start_object(query, "service.virtual_mach ine");
89 bson_append_oid(query,"_id",result);
90 bson_append_finish_object(query);
91 bson_finish(query);

我用这个运行它>

 93     bson fields[1];
94 bson_init(fields);
95 bson_append_oid(fields, "_id", result);
96 bson_finish(fields);
97
98 mongo_cursor* cursor = NULL;
99 cursor = mongo_find(conn, "db.services", query, field s, 9999,0,0);

如果我打印“mongo_cursor_next(cursor)”方法,我得到一个“-1”(错误),我想知道我的查询中有什么错误。

提前谢谢您。

最佳答案

这个? https://github.com/mongodb/mongo-c-driver#error-handling

Most functions return MONGO_OK or BSON_OK on success and MONGO_ERROR or BSON_ERROR on failure. Specific error codes and error strings are then stored in the err and errstr fields of the mongo and bson objects. It is the client's responsibility to check for errors and handle them appropriately.

关于复杂查询mongodb c,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10852160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com