Last active
December 19, 2017 23:39
-
-
Save fpapado/073fd886ea2dab4669b01eae8208c53a to your computer and use it in GitHub Desktop.
PouchDB Replication Check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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/[email protected]/dist/pouchdb.js"></script> | |
<script src="https://unpkg.com/[email protected]/dist/pouchdb.memory.js"></script> | |
<script src="index.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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