gpt4 book ai didi

node.js - 如何使用计算字段在 Waterline 中进行排序

转载 作者:太空宇宙 更新时间:2023-11-04 02:31:26 25 4
gpt4 key购买 nike

我正在尝试对 Reddit 热门算法的查询进行排序。它基于时间,我不能使用 beforeUpdate 或 beforeCreate Hook 。我在查询时需要进行计算排序,但找不到解决方案。

假设我的模型是这样的;

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

感谢您的帮助。

最佳答案

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

https://github.com/balderdashy/waterline/blob/master/README.md#custom-types

关于node.js - 如何使用计算字段在 Waterline 中进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26376896/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com