I want to search some rows from the database.
Phones.findAndCountAll({
where: {
id: (req.body.id) ? req.body.id : { $ne: null },
description: (req.body.description) ? { $like: '%' + req.body.description.trim() + '%' } : { $ne: null },
price: {
$and: {
{(req.body.st_price) ? {$gte: req.body.st_price} : { $ne: null } },
{(req.body.en_price) ? {$lte: req.body.en_price} : { $ne: null } },
}
}
}
})
But when I run this it doesnt work. I want to search if request.body.? exist. Should I use the between operator? How can I solve this problem?