Equivalent to mongo shell db.collection.runCommand() in Node.js

久未见 提交于 2019-12-13 18:13:16

问题


I'd like to use full text search available in MongoDB 2.4. Text search is available through runCommand function e.g. db.collection.runCommand( "text", { search: "keywords"}). So, I'm wondering whether there is an equivalent to runCommand() function in mongojs or node-mongodb-native modules.

I know the question has been touched before but was never answered sufficiently. Thanks in advance.


回答1:


I found that as an equivalent:

collection.find({ $text: { $search : "your search words" }})
  .toArray(function(err,results) {
    // ..callback stuff..
});



回答2:


runCommand support has been added! https://github.com/gett/mongojs/issues/62



来源:https://stackoverflow.com/questions/17002711/equivalent-to-mongo-shell-db-collection-runcommand-in-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!