Hello,
I'm a Node Nubie. I've been playing with it about a week and I love it. I have come across one problem that I can't seem to parse through.
I'm using the latest version of Node, node-mysql and connect (freshened through npm today). The node-mysql readme doesn't show an example of an UPDATE statement, and I could not find an example anywhere else on the web, surprising as that may seem. So my confidence is not 100% that I'm doing it correctly.
Below are the relevant parts my application, this.dbConnect() is called early on and set to this.DB. When I call this.assignToken(), I get no errors, both expires and fields are logged to the console and the callback, callback(params), is executed. It seems to work fine except the record doesn't update.
I have select statements that work fine on the same table in other parts of the application. Yes, I have confirmed that the user has write access to the table.
Am I missing something? Is the update correct? Have I found a bug? I appreciate any help provided either specifically about this problem or with my code in general.
var sso = (function(){
this.db = {};
this.DB = {};
this.db.user = "[REDACTED]";
this.db.pass = "[REDACTED]";
this.db.db = "[REDACTED]";
this.dbConnect = function () {
var Client = require('mysql').Client;
client = new Client();
client.debug = false;
client.user = this.db.user;
client.password = this.db.pass;
client.connect();
client.query('USE ' + this.db.db);
return client;
};
this.assignToken = function (params, callback){
var now = new Date().getTime();
params.SESS.token = this.mkToken();
params.SESS.cookie.expires = new Date(Date.now() + 60*60*3);
var expires = new Date(Date.now() + 60*60*2);
this.DB.query(
"update appsys_users set token=?, expires=? where user_pk = ?",
[params.SESS.token, expires, params.data.user_pk],
function(err, fields, files) {
if (err) throw err;
console.log(expires);
console.log(fields);
callback(params);
}
);
return;
};
return this;
})();
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.