Hello,
How is the best way to query the DB (mysql in my case).
I can see in several plugins that the easy way to query the db was like this:
var db = require('../../src/node/db/DB').db,
...
db.get("emailSubscription:"+context.message.data.padId, function(err, userIds)
(or)
db.get("session:" + sessionID, function (err, session)
But it only works for the table 'store'.
How can I ask to query another table, like users, groups,..?
(I couldn't find a param to do that)
The plugin I'm trying to fix (ep_user_pad) manages it this way:
var mysql = require('mysql');
...
var connection = mysql.createConnection(dbAuthParams);
connection.connect(connectFkt);
exports.expressCreateServer = function (hook_name, args, cb) {
...
var userSql = "Select * from User where User.name = ?";
var queryUser = connection.query(userSql, [username]);
...
}
But that way, etherpad crashes every x min (depending of the directive 'wait_timeout' of mysql)
[ERROR] console - Error: Connection lost: The server closed the connection.
at Protocol.end (/home/etherpad/node_modules/ep_user_pad/node_modules/mysql/lib/protocol/Protocol.js:73:13)
at Socket.onend (stream.js:66:10)
at Socket.EventEmitter.emit (events.js:123:20)
at TCP.onread (net.js:417:51)
I tried to fix the problem by closing the connection at the end of "exports.expressCreateServer", but then, it doesn't have an active connection on the next call and that creates a problem.
Maybe it's possible to create and destroy the connection on each call, but it's a big file that manage lots of "args.app.get" & "args.app.post" calls.
As, by using the DB lib instead of mysql lib, etherpad doesn't crash because of the wait_timeout directive, I was wondering if it's possible to choose the table on which you want to make the query?
Thanks
Hello,
How is the best way to query the DB (mysql in my case).
I can see in several plugins that the easy way to query the db was like this:
But it only works for the table 'store'.
How can I ask to query another table, like users, groups,..?
(I couldn't find a param to do that)
The plugin I'm trying to fix (ep_user_pad) manages it this way:
But that way, etherpad crashes every x min (depending of the directive 'wait_timeout' of mysql)
I tried to fix the problem by closing the connection at the end of "exports.expressCreateServer", but then, it doesn't have an active connection on the next call and that creates a problem.
Maybe it's possible to create and destroy the connection on each call, but it's a big file that manage lots of "args.app.get" & "args.app.post" calls.
As, by using the DB lib instead of mysql lib, etherpad doesn't crash because of the wait_timeout directive, I was wondering if it's possible to choose the table on which you want to make the query?
Thanks