0

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 ?

Community
  • 1
  • 1
khanal sir
  • 103
  • 1
  • 9

1 Answers1

1

You can do something like this:

db.employee.find({"$where":"/^56789.98.*/.test(this.salary)"})
oblivion
  • 5,928
  • 3
  • 34
  • 55