Hi
I am new to using the C API for mongoldb.
Need to construct a query filter using the C API programmatically as I build the string based on values passed to my program.
The filter using the mongo shell is: db.example.find( {"city": { $gte: "London" }} ) which works fine.
I tried this in the C API:
bson_t* query = BCON_NEW("filter");
BCON_APPEND(query, "{");
BCON_APPEND(query, "city");
BCON_APPEND(query, "{");
BCON_APPEND(query, "$gte");
BCON_APPEND(query, "London");
BCON_APPEND(query, "}");
BCON_APPEND(query, "}");
However the api calls fail with an assert.
I also tried:
bson_t* query = BCON_NEW(BCON_UTF8(" {"city": { $gte: "London" }} )"));
Anybody have any ideas?