Created
November 17, 2011 20:25
-
-
Save klaemo/1374408 to your computer and use it in GitHub Desktop.
klaemo's couch problem
This file contains hidden or 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
// this is a very simplified version of what's going on in my app | |
// First I parse some CSV file (into valid JSON) | |
parseFile(myfile, function(err, fileJSON) { | |
if(err) { | |
throw err; | |
} else { | |
// db is the connection to my couch server | |
db.save(fileJSON, function(err, response) { | |
// then I need to do some calculations... | |
calcResults(response.id); | |
}); | |
}); | |
function calcResults(docId) { | |
// ...query the view to get the data needed to do those calculations | |
db.view('ddoc/myView', { key: docId }, function (err, couchRes) { | |
// and this is the point where I seem to get an empty result | |
if(err) { | |
throw err; | |
} else { | |
couchRes.forEach(function (row) { | |
// do something | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment