Monday, 26 August 2013

MongoDB and MongoJS - can't get runCommand to work for text queries

MongoDB and MongoJS - can't get runCommand to work for text queries

My goal is to use MongoDB's (2.4.4) text command from Node. It works fine
from the command line. Based on this previous SO issue: Equivalent to
mongo shell db.collection.runCommand() in Node.js, I tried using MongoJS
(0.7.17) but can't make it go. Here is the code:
mongojs = require('mongojs');
var products = mongojs('localhost:27017/mydb').collection('products');
products.runCommand('text', {search: 'a'}, function (err, docs) {
...
});
docs returns undefined and err is null. I can execute a normal function
such as products.find() fine... and I can execute the search on the
MongoDB command line. Anyone know how to make this go?

No comments:

Post a Comment