Skip to content

Instantly share code, notes, and snippets.

@fpapado
Last active December 19, 2017 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fpapado/073fd886ea2dab4669b01eae8208c53a to your computer and use it in GitHub Desktop.
Save fpapado/073fd886ea2dab4669b01eae8208c53a to your computer and use it in GitHub Desktop.
PouchDB Replication Check
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>PouchDB Replication</title>
</head>
<body>
<script src="https://unpkg.com/pouchdb@6.1.0/dist/pouchdb.js"></script>
<script src="https://unpkg.com/pouchdb@6.1.0/dist/pouchdb.memory.js"></script>
<script src="index.js"></script>
</body>
</html>
const localDB = new PouchDB('localDB');
const remoteDB = new PouchDB('remoteDB');
localDB.sync(remoteDB).on('change', change => {
console.log(change);
change.docs.forEach(doc => console.log(doc, doc._deleted));
});
localDB.put({_id: 'mydoc', message: 'helllo'});
// expect the document to show up as added, without _deleted
localDB.get('mydoc').then(function(doc) {
return localDB.remove(doc);
});
// expect the document to show up with _deleted: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment