tags:

views:

30

answers:

0

I've been trying to use the $where functionality with a Mongo database but I always get the same error message each time...

$err: name has to be a string

It doesn't matter what type I actually use (string eval, function, etc) - I get the same message each time. I've even gone as far as to try the examples listed on their website and still have the same error message.

Other queries work fine - it is just the $where function that has this error.

Running: Ubuntu on VirtualBox with latest MongoDB stable release

To clarify, I'm using both the shell and drivers with the same error. I'm using examples similar to those found on the website.

(From the Mongo website)

db.myCollection.find( { $where: "this.a > 3" });
db.myCollection.find( "this.a > 3" );
db.myCollection.find( { $where: function() { return this.a > 3;}});