I need to find the object whose name is "abc"
from category collection in mongodb. Here is the my code
[{
_id: 728e38e7,
name: 'abc,def,ghi,klm,nmo',
place: "mys"
},
{
_id: 2788,
name: 'djhd',
place: "bang"
}]
I need to find the object whose name is "abc"
from category collection in mongodb. Here is the my code
[{
_id: 728e38e7,
name: 'abc,def,ghi,klm,nmo',
place: "mys"
},
{
_id: 2788,
name: 'djhd',
place: "bang"
}]
try that
var query = { name: new RegExp('^' + abc) };
collection.find(query).toArray(function(err, items))
Using the mongo shell you can use find().
db.collection.find({"name" : /abc/}).
From this post : How to query MongoDB with "like"?
Below is the simplest method of using regex to find element based on name in mongodb :
db.collection.find({name:{$regex:"ABC",$options:"$i"}})
Here $i is used to make the search case insensitive.