5

How can I do this query in mongoC with bcon_new?

 db.users.find({"name": /.*m.*/})
MooseMan55
  • 524
  • 2
  • 6
  • 21
Faruk
  • 5,438
  • 3
  • 30
  • 46

3 Answers3

2

After few try and error i finally found the answer based on libbson analogy

bson_t *query;

query = BCON_NEW ("name", BCON_REGEX("m","i") );
Faruk
  • 5,438
  • 3
  • 30
  • 46
2

There is also a specialist for the bson_append_...

bson_append_regex(&doc, "name", -1, ".*m.*", nullptr);
cursor = mongoc_collection_find(coll, MONGOC_QUERY_NONE, 0, 0, 0, &doc, nullptr, nullptr);
Totonga
  • 4,236
  • 2
  • 25
  • 31
1

There is also a specialist for the bson_append_...

bson_append_regex(&doc, "name", -1, ".*m.*", nullptr);
Totonga
  • 4,236
  • 2
  • 25
  • 31