I am using bluebird and sails to build my application. When I use a database call inside the promise, it show me the warning like
Warning: a promise was created in a handler but was not returned from it
var P = require('bluebird');
return new P(function (resolve, reject) {
Product.find({
or: [
{barcode: {'contains': q}},
{name: {'contains': q}},
{registrationCode: {'contains': q}}
]
})
.populate('batches')
.exec(function (err, products) {
if (err) return reject(err);
return resolve(products);
});
}); //- end promise