【发布时间】:2018-03-20 08:05:20
【问题描述】:
在sailsjs 1.0@beta 中,我使用mysql-sails@beta 适配器将模型链接到mysql 表中的视图。
模型配置如下:
attributes: {
id: {type:'number', required: true},
'release_date': { type: 'string', columnType: 'datetime' }
}
尽管当我查询模型时,sails 会在每个日期列显示一堵错误墙:
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
```
我已尝试将类型设置为“日期时间”,尽管不再受支持。
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 它是一个只读模型视图?
【问题讨论】:
标签: mysql datetime model sails.js