I need to get a list of an object created between two times;
I am able to get data by writing SQL Query;
But I need to write this query by Bookshelf;
My simple query:
router.route('/locations')
// fetch all locations
.get(function (req, res) {
Locations.forge()
.fetch()
.then(function (collection) {
res.json({error: false, data: collection.toJSON()});
})
.catch(function (err) {
res.status(500).json({error: true, data: {message: err.message}});
});
})
how can I get location between two dates like above query?
Try adding a
query()
call to the chain, likeSee Bookshelf Collection.query() and Knex Query Builder and whereBetween()