changes trigger on doc just created - duplicated

12 views
Skip to first unread message

Jeremy Vuillermet

unread,
Oct 1, 2015, 5:45:07 PM10/1/15
to PouchDB
Hello,
I'm using the replicate features of my pouch local db to a couchdb remote.

I would also like to get notified when a new change happened on the remote.  (live: true, since: now)

It's ok a that point but when I put a new doc, it get replicated on the remote and I get a change event with the same doc I just created.
I already have this doc locally so I would like not to create it again in my app. 
Should I check the rev and id locally before updating or am I doing something wrong ?

(I think it doesn't matter but I'm using react and redux) 

Thanks

Nolan Lawson

unread,
Oct 2, 2015, 1:29:45 PM10/2/15
to PouchDB
Hi Jeremy,

Checking the rev is a fine way to do it; also FWIW you can get by with just a changes() listener on the local database. (Assuming you are syncing, the changes are going to get there eventually anyway.)

Also when it comes to syncing a PouchDB between the local DB and your UI, it's very very easy; I wrote a blog post about how to do it: http://pouchdb.com/2015/02/28/efficiently-managing-ui-state-in-pouchdb.html

Cheers,
Nolan
Reply all
Reply to author
Forward
0 new messages