in Web (actually it support offline usage, but limited functions) • No search function (Require third party indexing service) • No self-host solution (some users concern privacy)
Database (Availability, Partition-Tolerance) • In Note App use case: • Always can write and read the notes any time even it is offline • Notes across clients (e.g. Desktop, mobile) will be in-sync (eventually consistent) when get back online CAP Theorem
(revision) in the document to update • the “_rev” in update document should match the one in database, otherwise will raise conflict • For success update, new “_rev” will be assigned Fail: if provide _rev different from current db one Success: a new _rev will be assigned to document
offline • client 1 updated document, rev become “rev 3-a” • client 2 updated document, rev become “rev 3-b” • When both clients get back online and “sync” Offline client 1 Offline client 2 What will happen?
winner based on a deterministic algorithm* • Both clients will see the same winner once they're back online 1. The revision with the longest revision history list becomes the winning revision. 2. If they are the same, the _rev values are compared in ASCII sort order, * Usually, we don’t need to care about the algorithm, just for your interest about the implementation
just use the winner version • Or handle the conflict: in note app case, • Display both version of notes to user and let user decide which to keep Note1-rev-A.md Note1-rev-B.md
• Replicates with a local PouchDB, acting as a cache • Peer Pouch: Allow PouchDB instances transfer data over WebRTC • Databases in different clients can sync with each other without Server • PouchDB Quick Search: Full text search engine for PouchDB