Search in MongoDB with multiple field using $or
0
I have student data in MongoDB and I am using mongoose as orm. I want to search all the students with the search param matching any of the student fields. query = { find: { $or: [ { 'first_name': '/' + req.body.search_text + '/' }, { 'last_name': '/' + req.body.search_text + '/' }, { 'email': '/' + req.body.search_text + '/' }, { 'city': '/' + req.body.search_text + '/' }, ] } } But it's not working as expected.
regex mongodb mongoose
share | improve this qu...