Closed jenokizm closed 9 years ago
"myq" should be a member of "connection":
connection.prototype.myq = function (sql, params, stdCallback) {
connection.query(sql, params, function (err, rows, columns) {
return stdCallback(err, { rows: rows, columns: columns });
});
}
Cordiales Saludos, Lucio M. Tato Socio Gerente www.tecnogob.com
On Mon, Jun 1, 2015 at 3:50 PM, jenokizm notifications@github.com wrote:
var myq = function (sql, params, stdCallback) { connection.query(sql, params, function (err, rows, columns) { return stdCallback(err, { rows: rows, columns: columns }); }); }
and
var titles = null; try { var res = wait.forMethod(connection, "myq", 'SELECT * FROM titles'); titles = res; } catch (err) { console.log(err); }
error: wait.forMethod: second argument must be the async method name (string)
— Reply to this email directly or view it on GitHub https://github.com/luciotato/waitfor/issues/34.
Thank you for your prompt reply. I noticed how you myq on connection.prototype.myq but now a new error (
Debugger listening on port 5858 C:\WebServers\home\nodewebapp\www\server.js:23 connection.prototype.myq = function (sql, params, stdCallback) { ^ TypeError: Cannot set property 'myq' of undefined at Object.
(C:\WebServers\home\nodewebapp\www\server.js:23:26 ) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.runMain as _onTimeout at Timer.listOnTimeout (timers.js:110:15) Press any key to continue...
Obviously "connection" is not defined. I can't help you with that without reading your source... and without a consulting contract. Check my profile to contact my company if you need our services. Best regards.
On Tue, Jun 2, 2015 at 5:16 PM, jenokizm notifications@github.com wrote:
Thank you for your prompt reply. I noticed how you myq on * connection.prototype.myq but now a new error (
Debugger listening on port 5858 C:\WebServers\home\parallelwebapp\www\server.js:23 connection.prototype.myq = function (sql, params, stdCallback) { ^ TypeError: Cannot set property 'myq' of undefined at Object. (C:\WebServers\home\parallelwebapp\www\server.js:23:26 ) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.runMain as _onTimeout at Timer.listOnTimeout (timers.js:110:15) Press any key to continue...
— Reply to this email directly or view it on GitHub https://github.com/luciotato/waitfor/issues/34#issuecomment-108084573.
I do not want paid services. I'm just about to report a bug and would like to fix it. Here in that order I install a prototype:
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret'
});
connection.connect();
connection.prototype.myq = function (sql, params, stdCallback) {
connection.query(sql, params, function (err, rows, columns) {
return stdCallback(err, { rows: rows, columns: columns });
});
}
TypeError: Cannot set property 'myq' of undefined
Sorry. This is not a bug in wait.for
Explaining to you what: "TypeError: Cannot set property 'myq' of undefined" means, it is outside the limits of my goodwill, (it is teaching you js) and sounds a lot like doing your job.
From your question, it seems that you are not an expert in javascript and or node.
I'm offering to do the job you're trying to do, for a fee.
Try this (last free lesson on javascript):
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret'
});
connection.connect();
console.log(connection);
connection.myq = function (sql, params, stdCallback) {
this.query(sql, params, function (err, rows, columns) {
return stdCallback(err, { rows: rows, columns: columns });
});
}
I'm really new to Node. Literally just went at it with php... But it is not the only case of an error. Also, I naturally appropriated prototype after direct connection to the database, at the time when the object was clearly defined and not empty:
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
connection.prototype.myq = function (sql, params, stdCallback) {
connection.query(sql, params, function (err, rows, columns) {
return stdCallback(err, { rows: rows, columns: columns });
});
}
});
TypeError: Cannot set property 'myq' of undefined
and
error: wait.forMethod: second argument must be the async method name (string)