Sequelize js - 限制和排序错误 [英] Sequelize js - limit and Sorting bug

查看:55
本文介绍了Sequelize js - 限制和排序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 sequelize js 中对查询进行排序的正确方法是什么?

What is the proper way to sort the query in sequelize js?

示例:

db.model.findAll({ 
    where: conditions, 
    order: 'postDate DESC', 
    limit: 10, 
    offset: 0, 
    include: [model1, model2] 
}).complete(function(err, results){console.log(results); });

导致拉取limit和offset的结果,先进行排序.在限制结果之前我应该​​怎么做先排序?

Resulting in pulling the results of the limit and offset, first and then it does the sorting. What should I do to do the sorting first before limiting the results?

以后谁会遇到这个bug,这是修复

in the future who will encounter this bug, this is the fix

order: [["postDate","DESC"]]

推荐答案

你必须这样指定:order: [["postDate","DESC"]]

这篇关于Sequelize js - 限制和排序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆