I'm using mongodb 4.4 and making aggregate query to find data from the collection.
Here is my code:
db.getCollection('users').aggregate([
{
$match: {
$or: [{
"name": {
$regex: /a/,
$options: 'i'
},
"email": {
$regex: /a/,
$options: 'i'
}
}]
}
}
])
I want to do query just like SQL like
on all column of the user collection. I am not getting any result with this.
CASE 1: If I use /(:?)/
it does return me all the collection and that works fine
CASE 2: If i user /ad/
it does not return anything even though there is email and name containing admin
string.