In sailsjs 1.0@beta I have a model linked to a view in mysql table with mysql-sails@beta adapter.
The model is configured the following way:
attributes: {
id: {type:'number', required: true},
'release_date': { type: 'string', columnType: 'datetime' }
}
Although when ever i query the model, sails display a wall of errors per date column:
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
```
I have tried to set the type to "datetime" although its no longer supported.
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' }
I was not able to find any documentation on what is the proper way to tell sailsjs model that its a date so that sailsjs 1.0b doesn't error out, and is there a way to tell sails its a read only model view?
After more digging, found a ticket about this on https://github.com/balderdashy/waterline/issues/1497
The fix for the datetime issue to use ref instead of string:
attributes: {
id: {type:'number', required: true},
'release_date': { type: 'ref', columnType: 'datetime' }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With