Bookshelf: Is it possible to create a formatter?

Created on 21 Jul 2017  路  3Comments  路  Source: bookshelf/bookshelf

So I found this on the docs right:
http://bookshelfjs.org/#Model-instance-format

Which says...

The format method is used to modify the current state of the model before it is persisted to the database. The attributes passed are a shallow clone of the model, and are only used for inserting/updating - the current values of the model are left intact.

but based on what that says, I'm not sure it's what I need. So I'll explain here what I'm trying to accomplish, and if someone could point me in the right direction, I'd appreciate it.

So I basically saving an "array" in a column using a , as a delimiter (I know it's bad practice, so sue me).
The thing is, when I'm retrieving this data later on, I need it to be back in it's array form. Whats the best way to achieve this?

question

Most helpful comment

@KieronWiltshire Seems like this issue is resolved, I'm going to close.

Also, it's @ricardograca. They keep messing up your handle because of the other Ricardo 馃槀

All 3 comments

I think you're looking for the opposite operation, which is parse.

That's exactly what I need @ricardogama thanks very much for your help :)

@KieronWiltshire Seems like this issue is resolved, I'm going to close.

Also, it's @ricardograca. They keep messing up your handle because of the other Ricardo 馃槀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Wtower picture Wtower  路  4Comments

cuteboi picture cuteboi  路  4Comments

martinmurciego picture martinmurciego  路  3Comments

leebenson picture leebenson  路  4Comments

Playrom picture Playrom  路  4Comments