Node.js 如何使用计算字段在吃水线中进行排序

Node.js 如何使用计算字段在吃水线中进行排序,node.js,sails.js,waterline,Node.js,Sails.js,Waterline,我正在尝试为reddit hot算法对查询进行排序。它基于时间,我不能使用beforeUpdate或beforeCreate挂钩。当我查询时,我需要使用计算进行排序,但我找不到解决方案 假设我的模型是这样的 var myModel = Waterline.Collection.extend({ attributes: { up: { type: 'integer', }, downs: { type: 'integer', } } }

我正在尝试为reddit hot算法对查询进行排序。它基于时间,我不能使用beforeUpdate或beforeCreate挂钩。当我查询时,我需要使用计算进行排序,但我找不到解决方案

假设我的模型是这样的

var myModel = Waterline.Collection.extend({
  attributes: {
    up: {
      type: 'integer',
    },
    downs: {
     type: 'integer',
    }
  }
});

感谢您的帮助。

您可以在模型中创建任何类型的函数帮助器或自定义属性,以帮助您进行正确的查询