Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: automatic string to Date conversion #34

Closed
MarkHerhold opened this issue Oct 21, 2016 · 2 comments
Closed

Idea: automatic string to Date conversion #34

MarkHerhold opened this issue Oct 21, 2016 · 2 comments

Comments

@MarkHerhold
Copy link
Contributor

It would be nice if this library could somehow identify Date strings (perhaps ISO 8601) and automatically convert to a date when deserializing from the DB to Node.js.

Another thought is that Date objects could be converted to a special object before being saved to help the deserialization back to a Date process.

RethinkDB represents dates like so:

{"$reql_type$":"TIME","epoch_time":1470532698.795,"timezone":"+00:00"}

I believe MongoDB represents dates like so:

{"$date":"2015-09-09T09:09:09.090Z"}

Thoughts?

@ricardogama
Copy link
Collaborator

Hi @MarkHerhold.

I think that's too much for this plugin to handle, its purpose is solely stringify/parse JSON columns on save/fetch. Also I don't understand the database engines date representation reference, the least we could do is to parse back a Javascript Date object, since what is stored is always a stringified JSON object.

I suggest to handle that on saving and fetched hooks of your models.

@MarkHerhold
Copy link
Contributor Author

@ricardogama The reason for the DB date representation reference is so the plugin can identify what values to parse back into a Date object. Just having a string would make it difficult to know what fields to convert back into a Date.

I'm closing this since you are not interested in including the feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants