Answer the question
In order to leave comments, you need to log in
MongoDB search for occurrence of specified digit in numeric field
Good afternoon.
Please tell me how to find the occurrence of the specified number in the numeric field in mongodb
> db.log.find();
{ "_id" : ObjectId("514de4657f15155d4f000009"), "date" : "23.01.2013", "user_id" : 1, "show" : 8614 }
{ "_id" : ObjectId("514de4657f15155d4f000013"), "date" : "23.01.2013", "user_id" : 65, "show" : 58 }
{ "_id" : ObjectId("51527f0d7f15155c28000016"), "date" : "23.01.2013", "user_id" : 14, "show" : 361 }
...
> db.log.find({show: {$regex: /61/i}})
не возвращает результатов
Answer the question
In order to leave comments, you need to log in
I already understood this :) I solved it like this:
db.log.find({$where : function() { return (/61/i).test(this.show)} })
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question