如何在本机node-mongo-native驱动程序中执行MongoDB查询? [英] How to execute a MongoDB query in the native node-mongo-native driver?
问题描述
有什么方法可以将像db.things.find()
这样的MongoDB查询直接传递给 Mongo C驱动程序或Javascript驱动程序 node-mongo-native 进行查询?
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.
该怎么做?
谢谢!
推荐答案
mongo.h 似乎是您要搜索的内容.
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);
我在这里找到了一个用法示例: https://github.com/mongodb/mongo-c-driver/blob/master/test/platform/linux/timeouts.c
I found an usage example here: https://github.com/mongodb/mongo-c-driver/blob/master/test/platform/linux/timeouts.c
这篇关于如何在本机node-mongo-native驱动程序中执行MongoDB查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!