mongodb-c

Complex query with two $OrderBy

北城余情 提交于 2019-12-24 20:47:37
问题 Here's the structure part of my collection : by: [ { id: ObjectId("XX"), type: NumberInt(1) } ], timestamp: NumberInt(), // is timestamp 1 status: NumberInt(0), mails: [ { id: ObjectId("YY"), text: "", timestamp: NumberInt(), // is timestamp 2 } ] I can recover my data in chronological order according to the timestamp 1 via the following lines: ... bson_init(&query); bson_append_document_begin(&query, "$orderby", -1, &child); bson_append_int32(&child, "timestamp", -1, 1); bson_append_document

sub-object in sub-array in mongodb-C

僤鯓⒐⒋嵵緔 提交于 2019-12-12 01:36:37
问题 Here's the structure part of my collection : { ... list: [ { id:'00A', name:'None 1' }, { id:'00B', name:'None 2' }, ], ... } Which method could you advise me to retrieve the list of values in the "id" and/or "name" field with C lib please ? 回答1: It seems you are asking for the equivalent of "db.collection.distinct" with the C driver. Is that correct? If so, you can issue distinct as a db command using the mongo_run_command function: http://api.mongodb.org/c/current/api/mongo_8h.html

Using the mongodb cxx driver in a cmake c++ project

∥☆過路亽.° 提交于 2019-12-10 06:06:24
问题 I am new to cmake and I want to connect to a mongodb using c++ and the latest mongodb cxx driver. I managed to compile and install the driver but now I stuck with using it in my cmake project. I installed the mongodb driver with the default settings, so it's located under /usr/local/lib/include/mongocxx/v_noabi/mongocxx. In my cmake file i manged to get the includes resolved with: include_directories(/usr/local/lib/include/mongocxx/v_noabi /usr/local/lib/include/bsoncxx/v_noabi) but I don't

Using the mongodb cxx driver in a cmake c++ project

帅比萌擦擦* 提交于 2019-12-05 12:04:04
I am new to cmake and I want to connect to a mongodb using c++ and the latest mongodb cxx driver. I managed to compile and install the driver but now I stuck with using it in my cmake project. I installed the mongodb driver with the default settings, so it's located under /usr/local/lib/include/mongocxx/v_noabi/mongocxx. In my cmake file i manged to get the includes resolved with: include_directories(/usr/local/lib/include/mongocxx/v_noabi /usr/local/lib/include/bsoncxx/v_noabi) but I don't know how to actually link the driver libs to my executable. Could any one please help me? You shouldn't