The title is not enough maybe. Here let me explain.
Assume I have database structure as
{
name: "alex",
age: "21",
location: "university-alex"
}
I am aware that this database structure is not rational but I just want to show my problem in a shortest way.
I want to get the documents where location
includes name
field value. Here university-alex
includes ,alex
so it should return as a result of the query.
What have I done so far? I wrote this query but couldn't get a result.
db.collection.find({location: {$regex: "$name"}})
How can I edit it?
via mmu36478
No comments:
Post a Comment