Reputation: 113
I have perform like query in mongodb. I have following document in employee collection
as:
{
"_id" :1
"name":"Abc",
"salary": 56789.98456
}
So far,I have performed like query
to match the above employee document. I have tried following queries in mongo:
db.employee.find({"salary":/.*56789.98.*/}).pretty()
db.employee.find({"salary":/^56789.98/}).pretty()
db.employee.find({"salary":/56789.98/}).pretty()
But it doesn't work. I also looked at: How to query MongoDB with "like"?
How do I achieve this in mongo ?
Upvotes: 0
Views: 93
Reputation: 6548
You can do something like this:
db.employee.find({"$where":"/^56789.98.*/.test(this.salary)"})
Upvotes: 1