Skip to content

Instantly share code, notes, and snippets.

@vicatcu
Created January 13, 2016 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vicatcu/5a843801a3b0e3f919f6 to your computer and use it in GitHub Desktop.
Save vicatcu/5a843801a3b0e3f919f6 to your computer and use it in GitHub Desktop.
return Promise.try(function () {
//return fs.readFileAsync(status.filename, 'utf8');
return MongoClient.connectAsync(MONGODB_CONNECTION_STRING).then(function(db){
var results = null;
return Promise.try(function(){
return db.collection("downloads").findOneAsync({key: status.filename});
}).then(function(item){
results = item;
return db.closeAsync();
}).then(function(){
return results;
});
});
}).then(function(content) {
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment