Gle*_*lem 5 mongodb node.js node-mongodb-native
我正在尝试从nodejs中使用MongoDB 2.4实验文本搜索功能.唯一的问题是,就我所知,native nativejs mongo驱动程序似乎不支持集合级runCommand.
Mongo shell语法如下所示:
db.collection.runCommand( "text", { search : "Textvalue" } );
Run Code Online (Sandbox Code Playgroud)
它出现了一个db.command/db.executeDbCommand函数,但我不知道如何选择一个集合并使用它运行text命令(如果可能的话),因为它需要在集合级别而不是数据库级别.
任何帮助,将不胜感激
Gle*_*lem 14
通过利用,我设法通过结合Asya Kamsky的评论来实现它
this.db.command({text:"collection" , search: "phrase" }).
Run Code Online (Sandbox Code Playgroud)
问题是它没有像标准结果那样返回,因此toArray()调用失败了.相反,我把回调直接放在里面:
this.db.command({text:"collection" , search: "phrase" }, function(err, cb){
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6139 次 |
| 最近记录: |