I have following collection
{
"_id" : ObjectId("5b1fd21cc1448a422a21b3cc"),
"amount" : 500,
"bank" : "ICICI",
"status" : "draft",
"currency" : "EURO",
"senderId" : ObjectId("5a16ca832bedaa6c4cb4ad97"),
"created_date" : ISODate("2018-06-12T00:00:00.000Z")
}
I am searching for multiple criteria in it such like
const array = [
{ "status": { "$regex": searchString }},
{ "amount": { "$regex": parseInt(searchString) }},
{ "created_date": searchString },
{ "currency": { "$regex": searchString }},
]
Invoice.aggregate([
{ "$match": { "$and":[{ "$or": array }] }}
])
But In above case $regex
on amount searching in not working... It throws me an error...
How can I do this? I need to do this in aggregate query because I have to run $lookup
for senderId