I'm trying to make pagination on Node.js, but mongoose with mongoose-paginate not works with like expressions.
I have found Mongoose.js: Find user by username LIKE value, but result is always empty.
My Entity contains 'target' field. There are entities with 'test' in Entity.target. My code is:
var filter = {};
if (req.param('filter')) {
filter = {
target: new RegExp('^'+'test'+'$', "i")
}
}
var params = {
page: getPage(req),
limit: getCount(req)
};
Entity.paginate(filter, params, function (err, result) {
res.json(result);
});
If I run query in mongo console, I get correct result:
{"target":{"$regex":"te","$options":"gi"}}
Do you have some ideas?