【发布时间】:2018-01-03 23:35:00
【问题描述】:
我正在尝试排序 id
模态:
module.exports = {
autoPK: false,
attributes: {
id: {
type: 'integer',
autoIncrement:true,
primaryKey: true
},
}
}
查询:
mymodal.find().sort({id: 'asc'}).exec(function (err, res) {
console.log(res)
});
数据:
[ { id: '2', },{ id: '1'},{ id: '11' } ]
实际:
[ { id: '1', },{ id: '11'},{ id: '2' } ]
**预期:
[ { id: '1', },{ id: '2'},{ id: '11' } ]**
谁能帮帮我。请..
按字符串排序,但按数字(整数)排序。
帆水线标准排序
是否有我的查询或问题【问题讨论】:
-
当你在你的数据库中观察时,你确定如果“id”是整数类型,你在local.js中的migrate等于“alter”吗?你应该复制你的 JSON 结果,只有 find()。
-
是的.. 我确定在我的模型 ID -> 类型:'integer',autoIncrement:true,primaryKey:true。您是否尝试过按 id 排序,其中 id 是数字。使用sails-redis。请帮帮我?
标签: sorting sails.js waterline sails-redis