Monday 1 May 2017

How i can use "LIKE" operator on mongoose?

I have a problem when i query using mongoose.I coding follow this Mongoose.js: Find user by username LIKE value. But it return blank.

This my code return blank.

 var promise = UserSchema.find({name: /req.params.keyword/ }).limit(5);

I tried this return blank seem.

var n = john; var promise = UserSchema.find({name: /n/ }).limit(5);

But i tried this is working

 var promise = UserSchema.find({name: /john/ }).limit(5);

Why I use variable then return blank



via devnext

No comments:

Post a Comment