1 point

mongodb - How to find items using regex in Mongoose for partial text search


dashboard

Wed Jun 10 2020 12:20:30 GMT+0000 (UTC)

Posted by @mishka #javascript #mongoose #mongodb #mean

   var Person = mongoose.model('Person', yourSchema);
   // find each person with a name contains 'Ghost'
   Person.findOne({ "name" : { $regex: /Ghost/, $options: 'i' } },
          function (err, person) {
                 if (err) return handleError(err);
                 console.log('%s %s is a %s.', person.name.first, person.name.last, person.occupation);

   });
content_copy Copy

https://stackoverflow.com/questions/38497650/how-to-find-items-using-regex-in-mongoose/38498075