Here's the structure part of my collection :
{
...
likes: ['6a6ca923517f304900badd98','6a6ca923517f304900badd99','...'],
...
}
Which method could you advise me to retrieve the list of values in the "likes" field with C lib please ?
I don't have a working MongoDB C driver, but this should help get you started. Also, the docs should help you (here).
bson_iterator i[1], sub[i];
bson_type type;
const char * key;
const char * value;
// do query, get cursor
while(mongo_cursor_next(cursor) == MONGO_OK) {
// look for the "likes" field
if( bson_find( iterator, bson, "likes" )) {
// need to iterate through the elements of the array
bson_iterator_subiterator( iterator, sub );
// then iterate using "sub", until returns a BSON_EOO
while (BSON_EOO != bson_iterator_next( sub )) {
key = bson_iterator_key( sub );
// if it's a string...
value = bson_iterator_string( sub );
}
}
}