I'm working with SailsJS and MongoDB and I have an API that has two models and I want to store Date and Time separately
but as in the official documentation said it doesn't have a typeof Time
attribute, just Date
and DateTime
. So, I'm using DateTime to store Time values.
I send the values in the request to be stored in the database, I have no problem to store dates
, I just send a value like:
2015-12-16
and that's it, it is stored in the table with no problem, but when I want to store a Time
value like:
19:23:12
it doesn't works. The error is:
{
"error": "E_VALIDATION",
"status": 400,
"summary": "1 attribute is invalid",
"model": "ReTime",
"invalidAttributes": {
"value": [
{
"rule": "datetime",
"message": "`undefined` should be a datetime (instead of \"19:23:12\", which is a string)"
}
]
}
}
So, any idea how to send the time value to be stored in a DateTime
attribute?
I also have tried to send it in different formats like:
0000-00-00T19:23:12.000Z
0000-00-00T19:23:12
T19:23:12.000Z
19:23:12.000Z
19:23:12
But any of them works fine.
Also I was thinking to store both values (Date and Time) in plain text, I mean typeof String
attributes. But I need to make some queries and I don't know if it will affect the performance with the waterline ORM.
Please any kind of help will come in handy. Thanks a lot!