jsonapi-datastore
jsonapi-datastore copied to clipboard
serialize to plain object?
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
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,
Sounds great! Thanks!
Let's leave this open in the meantime so that it gets more visibility!
+1
@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.
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 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.
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.