mongoose search by name

Solutions on MaxInterview for mongoose search by name by the best coders in the world

showing results for - "mongoose search by name"
Abdoulaye
10 Jan 2021
1var name = 'Peter';
2model.findOne({name: new RegExp('^'+name+'$', "i")}, function(err, doc) {
3  //Do your action here..
4});
5
James
27 Aug 2020
1let ids = ['id1','id2','id3']
2let data = await MyModel.find(
3  {'_id': { $in: ids}}
4);