zs2020
zs2020

Reputation: 54524

How to execute a MongoDB query in the native node-mongo-native driver?

is there any way I can pass a MongoDB query like db.things.find() directly to the Mongo C Driver or the Javascript driver node-mongo-native to make a query?

I am wondering the native driver is able to evaluate the query and return the result.

How to do that?

Thanks!

Upvotes: 2

Views: 967

Answers (1)

nutlike
nutlike

Reputation: 4975

The method mongo_simple_str_command(…) in mongo.h seems to be what you are searching for.

mongo_simple_str_command(conn, db, "$eval", "db.foo.find()", out);

I found an usage example here: https://github.com/mongodb/mongo-c-driver/blob/master/test/platform/linux/timeouts.c

Upvotes: 3

Related Questions