我正在使用 Sails 和它的 Waterline ORM for PostgreSQL。我defaultsTo
对模型属性定义中的参数有疑问。
这是我的模型定义的一部分:
module.exports = {
tableName: 'table',
attributes: {
[...]
reach: {
type: 'number',
defaultsTo: 0,
}
[...]
}
}
使用时Model.create()
,我收到此控制台警告:
Warning: After transforming columnNames back to attribute names for model `model`,
a record in the result has a value with an unexpected data type for property `reach`.
The corresponding attribute declares `type: 'number'` but instead
of that, the actual value is:
` ` `
'0'
` ` `
我有一堆number
类型属性,所以这会导致我的控制台中出现很多警告。
在这一点上,我认为这是一个水线问题,但您有避免此警告的解决方法吗?
编辑
我的警告仅出现在 Postgres“BIGINT”列中,我开始理解 JS 无法将 postgres BIGINT 处理为数字,因此必须将其转换为字符串。