seegno / bookshelf-json-columns

Parse JSON columns with Bookshelf.js

Home Page:http://seegno.github.io/bookshelf-json-columns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Idea: automatic string to Date conversion

MarkHerhold opened this issue · comments

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?

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.

@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.