在sailsjs 1.0@beta我有一个模型链接到mysql表中的视图与mysql-sails @ beta适配器 .
该模型按以下方式配置:
attributes: {
id: {type:'number', required: true},
'release_date': { type: 'string', columnType: 'datetime' }
}
虽然我在查询模型时,每个日期列显示一行错误:
Warning: After transforming columnNames back to attribute names, a record
in the result has a value with an unexpected data type for property `release_date`.
The corresponding attribute declares `type: 'string'` but instead
of that, the actual value is:
2016-04-07T05:00:00.000Z
我试图将类型设置为“datetime”,尽管它不再受支持 .
The type "datetime" is no longer supported. To use this type in your model, change
`type` to one of the supported types and set the `columnType` property to a column
type supported by the model's adapter, e.g. { type: 'string', columnType: 'datetime' }
我无法找到任何关于告诉sailsjs模型的正确方法的文档,以便sailsjs 1.0b不会出错,并且有没有办法告诉sails它是一个只读模型视图?
2 回答
经过多次挖掘,在https://github.com/balderdashy/waterline/issues/1497找到了关于此的门票
日期时间问题的修复使用ref而不是string:
解决方法可能是当前在User模型中的SailsJS默认Web应用程序中找到的方法:
然后在UI中,您可以通过执行以下操作轻松地将其转换为人类可读的格式: