What is the correct syntax in MongoDB to return all queries that meet the following criteria:
a % 4 >= 2
I tried using below command, but it returns empty
db.data.find( { a : { $mod : [ 4, { $gte : 2 } ] } } );
Another option would be using Javascript expression as follow:
db.data.find( "this.a % 4 >= 2" );
Javascript expression works and returns expected documents, but it does not work from within PyMongo.
MongoDB version 2.0.4
PyMongo version 2.1.1
I don’t think you can do this currently with a simple query, and you’ll have to use your javascript version instead. You should be able to do that with PyMongo with the where method on the created cursor. F.e.: