Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    fs.readFile("person.json")
    .then(function(e, personJson) {
        var person = JSON.parse(personJson);
        return myDB.query("lastname", person.name);
    })
    .then(function(matched) {
        return msgQueue.push(JSON.stringify(matchesLastname));
    })
    .then(function(id) {
        log.info("Message sent to queue: " + id);
    });


That's part of it. What about creating the promises?


that's in there, with the assumption that you're using the promises based node.js api, but if you aren't, and you're using Q, that part looks like this

    var readFile = Q.denodeify(FS.readFile);
which doesn't create the promise. it just wraps the readFile method so that it returns a promise when you call it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: