How I can use “LIKE” operator on mongoose?

use $regex in mongodb

how to use regex

example

select * from table where abc like %v%

in mongo

 var colName="v";
 models.customer.find({ "abc": { $regex: '.*' + colName + '.*' } },
   function(err,data){
         console.log('data',data);
  });

Your query look like

var name="john";
UserSchema.find({name: { $regex: '.*' + name + '.*' } }).limit(5);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)