MongoDB - Javascript function
$where operator : It uses to either a string containing a JavaScript expression. The full JavaScript function also used in the query system. This feature available after MongoDB version >= 2.4.
List of properties:
args
MaxKey
MinKey
List of some javascript function that can be used in MongoDB query:
assert()
BinData()
DBPointer()
DBRef()
doassert()
emit()
gc()
HexData()
hex_md5()
isNumber()
isObject()
ISODate()
isString()
Map()
MD5()
NumberInt()
NumberLong()
ObjectId()
print()
printjson()
printjsononeline()
sleep()
Timestamp()
tojson()
tojsononeline()
tojsonObject()
UUID()
version()
E.g. We want to findout the employee age is greater than 40.
db.collection.find({$where: function() { return this.age > 40 }});
Above query return employee which age is greater than 40.
0 Comment(s)