Created
April 17, 2017 10:03
-
-
Save pionize/f9fdf75ff0b42fd4aa26db8c031c55b2 to your computer and use it in GitHub Desktop.
Rookie Mistake 1: Promise Pyramid
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
db.allDocs({ | |
include_docs: true, | |
attachments: true | |
}).then(function (result) { | |
var docs = result.rows; | |
docs.forEach(function(element) { | |
localdb.put(element.doc).then(function(response) { | |
alert("Pulled doc with id " + element.doc._id + " and added to local db."); | |
}).catch(function (err) { | |
if (err.name == 'conflict') { | |
localdb.get(element.doc._id).then(function (resp) { | |
localdb.remove(resp._id, resp._rev).then(function (resp) { | |
// etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment