jsonapi-datastore icon indicating copy to clipboard operation
jsonapi-datastore copied to clipboard

serialize to plain object?

Open jamesdixon opened this issue 8 years ago • 8 comments

Hi,

In my other issue, I mentioned that my fork was customized to add another serialize() method that would serialize the contents of the store to plain javascript objects that could be then used to pass into my ORM. I know it may be an edge case, but wanted to see if there was any interest in supporting such a thing? Essentially, I'm just creating a plain javascript object that contains attributes and relationships and can then be passed almost directly into my ORM (Bookshelf). The reason for doing this was because the JsonApiDataStoreModel contained a handful of methods and properties that were clogging things up a bit when I passed it around, which means I would have to rip those out before passing them in.

If this is something that you can see to be valuable, more than willing to create a PR with the code I created.

Best, James

jamesdixon avatar Nov 05 '15 22:11 jamesdixon

Hi James,

Thanks for your interest and work! I personally also think this is an edge case, but let's see if there is traction, in which case I'm not opposed to having it merged.

Cheers,

beauby avatar Nov 05 '15 23:11 beauby

Sounds great! Thanks!

jamesdixon avatar Nov 05 '15 23:11 jamesdixon

Let's leave this open in the meantime so that it gets more visibility!

beauby avatar Nov 05 '15 23:11 beauby

+1

benaubin avatar Jan 29 '16 03:01 benaubin

@penne12 you can use my fork, which contains a new method called serializeGeneric() that will output the plain object.

@beauby I know this is only one additional request for this feature, but would there be any harm in including it as an official part of the repo? I'd prefer to use the official repo rather than my own fork going forward. Also, any updates on 3.0?

Cheers.

jamesdixon avatar Jan 29 '16 18:01 jamesdixon

Hi guys, As it seems this feature is needed by quite some people, I'll merge it soon. @jamesdixon would you mind issuing a PR?

beauby avatar Jan 29 '16 20:01 beauby

@beauby I'll do my best to get this in soon. I need to merge in upstream changes and make sure everything still functions as expected.

jamesdixon avatar Jan 29 '16 20:01 jamesdixon

Awesome, thanks a lot! As far as the next version is concerned, I'll cut 0.3.3-beta as soon as your PR is merged, and then clean out some stuff before cutting 1.0.

beauby avatar Jan 29 '16 20:01 beauby