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

Reset flags on a single model instance when persisting #4

Open
johnrix opened this issue Nov 20, 2019 · 2 comments
Open

Reset flags on a single model instance when persisting #4

johnrix opened this issue Nov 20, 2019 · 2 comments

Comments

@johnrix
Copy link

johnrix commented Nov 20, 2019

I want to reset both flags on a single model instance when persisting it to a back-end database. (Presently, I'm using the Vuex ORM GraphQL plugin for the latter purpose, but that is somewhat orthogonal.)

I've tried the following (I haven't tried working with updates to $isNew yet):

        myModelInstance.$update({ '$isDirty': false, preventDirtyFlag: true }).then(result => {
            console.log('update result: ', result)
            myModelInstance.$push()
        })

However, the output from the log statement indicates my update had no effect. What am I doing wrong here?

It seems to me there should be a more explicit means of resetting flags for just a single instance, rather than just for all instances as is presently the case.

@johnrix
Copy link
Author

johnrix commented Nov 20, 2019

I see now it is just that instance.$update() currently doesn't work. Switching to the following allowed the update to work:

MyModel.update({ data: { id: myModelInstance.id, '$isDirty': false }, preventDirtyFlag: true }).then(result => {

That said, I still feel it would be useful to have a reset method for individual instances to make this simpler. Perhaps I'm missing something though.

@kiaking
Copy link
Member

kiaking commented Nov 25, 2019

Ah, good point! Thanks for the feedback. Yeah I think it should work with $update as well.

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