【发布时间】:2019-09-16 06:59:18
【问题描述】:
我正在构建这样的查询
let searchData = request.all()
let products = Product.query().where('product_type', searchData.type).with('singleImage').paginate(1, 20)
if(parseInt(searchData.minPrice) > 0 && parseInt(searchData.maxPrice) > 0) {
products.where("lowerPrice", ">=", searchData.minPrice).where("upperPrice", "<=", searchData.maxPrice)
}
// more conditions and query goes here
因为.paginate(1, 20) 它不起作用,如果我删除分页它就起作用。
【问题讨论】:
-
你有什么解决办法??
-
是的。分页和获取是一回事。所以我们必须在最后使用 await products.paginate(page, 1) 。 paginate 将作为 fetch 工作。
-
非常感谢您告诉我
标签: adonis.js