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?
BTW, here is what docs contains in the callback:
{
"queryDebugString": "||||||",
"language": "english",
"results": [],
"stats": {
"nscanned": 0,
"nscannedObjects": 0,
"n": 0,
"nfound": 0,
"timeMicros": 55
},
"ok": 1
}
BTW, if there's another approach to make this work with just the normal native driver, I'm fine with that.
Using the native driver I can run a command off of the db object as follows:
I noticed you are running the command off of the collection object, that might be the problem.