Reputation: 33994
I have date and time in following format 2018-10-31T10:30
. I want to define a data type for this in loopback model. I have gone through internet and putting my head aroung for hours now but didn't find solution about which data type should I use for this format in loopback.
I tried with
type: "timestamp"
OR
type: "date"
dataType: "timestamp"
OR
type: "datetime"
but none works
While compiling I get below warning
Swagger: skipping unknown type "timestamp".
So what is the correct data type for this format 2018-10-31T10:30
Upvotes: 0
Views: 3333
Reputation: 306
So this is how the createdOn property in my model will look like. the data type in loopback is Date and in MySQL it is datetime. The conversion of javascript date to MySQL datetime format is implicitly done by loopback
"createdon": {
"type": "Date",
"required": true,
"mysql": {
"columnName": "CreatedOn",
"dataType": "datetime",
"nullable": "N"
},
"_selectable": false
}
Upvotes: 1
Reputation: 2246
"myDate": { "type": "string", "dataType": "date", ... }
REf: https://github.com/strongloop/loopback-connector-mysql/issues/149
Upvotes: 2