Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c statement equivalent to mongo query db.users.find({age {$gt: 3}}, {})

Tags:

c

mongodb

I have searched for the usage of conditional statements(<,>,<=,etc..,) in C API documentation in the link http://api.mongodb.org/c/current/. But I am unable to find it.

Example:

The mongo shell query is

db.users.find({age: {$gt: 3}}, {})

I want the equivalent C statement for the above.

like image 878
sudesh Avatar asked Nov 04 '22 07:11

sudesh


1 Answers

For example, query:

find({ age : { $gt : 5, $lt : 12}})

would be written like this:

bson_init(&b);
bson_append_start_object(&b,"age");
bson_append_int(&b,"$gt",5);
bson_append_int(&b,"$lt",12);
bson_append_finish_object(&b);
bson_finish(&b);
like image 102
milan Avatar answered Nov 09 '22 05:11

milan