beauby / jsonapi-datastore

JavaScript client-side JSON API data handling made easy.
MIT License
195 stars 40 forks source link

serialize to plain object? #13

Open jamesdixon opened 8 years ago

jamesdixon commented 8 years ago

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

beauby commented 8 years ago

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,

jamesdixon commented 8 years ago

Sounds great! Thanks!

beauby commented 8 years ago

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

benaubin commented 8 years ago

+1

jamesdixon commented 8 years ago

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

beauby commented 8 years ago

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?

jamesdixon commented 8 years ago

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

beauby commented 8 years ago

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.