Created
July 19, 2014 01:03
-
-
Save nolanlawson/118ce6bd7be863c9a8a0 to your computer and use it in GitHub Desktop.
PouchDB issue 2493
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
<html> | |
<body> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/pouchdb/2.2.3/pouchdb.min.js"></script> | |
<script src="index.js"></script> | |
<button onclick="edit()">Edit</button> | |
</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
var todo = null; | |
var db = new PouchDB('todos'); | |
var remoteCouch = 'http://user:password@127.0.0.1:5984/todos'; | |
db.info(function(err, info) { | |
db.changes({ | |
since: info.update_seq, | |
live: true | |
}); | |
}); | |
db.allDocs({include_docs: true, descending: true}, function(err, doc) { | |
if (doc.rows.length == 0) { | |
db.post({title: 'clean dishes'}); | |
} else { | |
todo = doc.rows[0].doc; | |
} | |
}); | |
var opts = {live: true}; | |
db.replicate.to(remoteCouch, opts); | |
db.replicate.from(remoteCouch, opts); | |
function edit() { | |
todo.title = 'take out trash at ' + (new Date()).toUTCString(); | |
console.log(todo); | |
db.put(todo); | |
// This doesn't solve the problem either | |
// db.put(todo).then(function(response) { | |
// todo._rev = response.rev; | |
// }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment