Regular expression in MongoC

How can I execute this request in mongoC using bcon_new?

 db.users.find({"name": /.*m.*/})
+4
source share
3 answers

After several attempts and errors, I finally found an answer based on libbson analogies

bson_t *query;

query = BCON_NEW ("name", BCON_REGEX("m","i") );
+1
source

There is also a specialist for bson_append _...

bson_append_regex(&doc, "name", -1, ".*m.*", nullptr);
+1
source

There is also a specialist for bson_append _...

bson_append_regex(&doc, "name", -1, ".*m.*", nullptr);
cursor = mongoc_collection_find(coll, MONGOC_QUERY_NONE, 0, 0, 0, &doc, nullptr, nullptr);
+1
source

All Articles