通过包含的模型属性续订订单

时间:2016-11-05 05:44:44

标签: sequelize.js sequelize-cli

我试图通过belongsToMany关系订购。我想按firstName表的Subscriptions列进行排序,该表与event.getSubscriptions()查询一起返回。我现在就在这里:

return event.getSubscriptions({
  where: {
    id: {
      $ne: event.currentUserId
    }
  },
  order: // I would like to order by the Subscription.firstName column
})

我该怎么做呢?

提前致谢!

1 个答案:

答案 0 :(得分:3)

你可以这样做

return event.getSubscriptions({
  where: {
    id: {
      $ne: event.currentUserId
    }
  },
      order: 'firstName'
})

仅降序变更顺序:' firstName DESC'