Select object created between two dates by Bookshelf, MySQL, Knex on node.js

不羁的心 提交于 2019-12-07 03:51:27

Try adding a query() call to the chain, like

Locations
  .forge()
  .query(function(qb) {
    qb.whereBetween('creation', [initialDate, finalDate]);
  })
  .fetch()
  .then(function (collection) {
    res.json({error: false, data: collection.toJSON()});
  })
  .catch(function (err) {
    res.status(500).json({error: true, data: {message: err.message}});
  });

See Bookshelf Collection.query() and Knex Query Builder and whereBetween()

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!