Skip to content

Instantly share code, notes, and snippets.

@klaemo
Created November 17, 2011 20:25
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 klaemo/1374408 to your computer and use it in GitHub Desktop.
Save klaemo/1374408 to your computer and use it in GitHub Desktop.
klaemo's couch problem
// 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