samedi 28 février 2015

How can I make use of LOCAL VARIABLES within a heroku postgres query?

I have looked around in many MANY threads, and through various documentation however for what seems like such an incredibly SIMPLE task, this is driving me insane.


I have a node.js webapp which generates a userId upon login, and is stored within a session object.


req.user.id <== my local variable for the user id.


The code I have so far is along these lines:



var query = client.query("SELECT * FROM programs WHERE authorid = req.user.id", function (err, result) {

if (err){
//Do erranous things
} else {
// Do good things
}
});


What am I doing wrong? How can I do this simple task of comparing a database entry to a value stored in a local variable?


Any / all help appreciated - I've been trying to do this for 6 hours.


Aucun commentaire:

Enregistrer un commentaire