amdelamar / oddox-dashboard

Apache License 2.0
2 stars 0 forks source link

Handle document conflicts #28

Closed amdelamar closed 5 years ago

amdelamar commented 6 years ago

Because CouchDB is a "master-master" replication database, there sometimes can be an update to a document that conflicts with another. These conflicts have to be resolved gracefully.

GET /db/bob?conflicts=true
amdelamar commented 6 years ago

Adding {conflicts: true} is an easy way to see doc conflicts. Then all you have to do is check if the field is not null and not empty.

db.postsdb.get(id, {conflicts: true})
.then(result => {
  // result doc
}).catch(err => {
  // err.message
})

See https://pouchdb.com/guides/conflicts.html

Note: _conflicts is an array of rev numbers.