Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model to json payload #79

Open
steventhan opened this issue Sep 21, 2020 · 2 comments
Open

Model to json payload #79

steventhan opened this issue Sep 21, 2020 · 2 comments

Comments

@steventhan
Copy link

Is there a way to generate json payload from a model's instance? Right now I have this in my code which seems to work, but curious if an alternative exists

import { WritePayload } from 'spraypaint/lib-esm/util/write-payload';

@Model()
class Model extends SpraypaintBase {
  toJsonPayload = () => {
    return new WritePayload(this).asJSON();
  };
}
@richmolj
Copy link
Contributor

I think this is easier for read operations, but what you have is probably the only way to go for writes. I'd accept a PR for it if you'd like to add it with some tests!

@steventhan
Copy link
Author

I'll try to find some time to send a pr, thanks @richmolj !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants