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

How are you handling updates on the store? #3

Open
brunoreis opened this issue Aug 25, 2017 · 2 comments
Open

How are you handling updates on the store? #3

brunoreis opened this issue Aug 25, 2017 · 2 comments

Comments

@brunoreis
Copy link

Please, how are you replicating the updates on the store to your local pouch? Sorry if the question is off-topic, but I read you created this to work in a project you were considering pouch-redux-middleware. Since this will solve the pouch->state sync I'm wondering if you came up with something for state->pouch syncing.

@colinskow
Copy link
Owner

You've got a couple options:

  1. Manually put each document that is added to the live query and delete if it is removed. You can specify the _rev field and use force: true in the options to make sure the saved doc keeps the same rev as the original.

  2. Use filtered replication with the new selector option. This will replicate all documents that match the query, but won't remove them when they no longer match. If you want documents removed, the above is probably better.

This is a good idea though, and I'd definitely welcome a pull request to implement selective replication with correct removal of docs that no longer match.

@brunoreis
Copy link
Author

brunoreis commented Sep 29, 2017

Hey @colinskow, sorry, I don't understand your answer. If something is added to the live query, I understand it's already on Pouch. Please clarify.

My main concern here is how to replicate something I do on my store to my local pouch instance. Let's say I add a new item to the store. When should I add it to pouch? Right now I'm adding an object to pouch first and just after receiving that in the live query I'm adding this object to the store. This was working fine, but now I started to think about some business rules and interactions of objects in the state and this is not working anymore.

I'm thinking about adding those objects to a queue on the state and persisting them on pouch by a middleware after the store is updated. But this would probably require me to add some extra state fields to my objects....

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