Skip to content

Instantly share code, notes, and snippets.

@hiun
Last active August 29, 2015 13:57
Show Gist options
  • Save hiun/9860532 to your computer and use it in GitHub Desktop.
Save hiun/9860532 to your computer and use it in GitHub Desktop.
global.loadTagInfo = (function (tagName, callback) {
connection.query('SELECT `Id`, `Desc` FROM `Tags` WHERE `Name` = ?;', [tagName], function (err, row) {
callback([JSON.stringify(row[0]['Id']), JSON.stringify(row[0]['Desc'])]);
});
});
global.countTagMembers = (function (tagId, callback) {
connection.query('SELECT COUNT(UserId) FROM `TagMembership` WHERE TagId = ?;', [tagId[0]], function (err, row) {
callback(JSON.stringify(row[0]['COUNT(UserId)']));
});
});
var Id = 1;
connection.query('SELECT Name FROM Tags WHERE Id = ?;', [Id], function(row) {
connection.query('SELECT Desc FROM Products WHERE Name = ?;', [row], function(row) {
connection.query('SELECT Desc FROM Product WHERE Desc = ?;', [row], function(row) {
connection.query('SELECT Id FROM Products WHERE Desc = ?;', [row], function(row) {
connection.query('SELECT Id FROM Enterprises WHERE = ?;', [row], function(row) {
});
});
});
});
});
async.waterfall([
function(callback){
loadTagInfo(tagName, function (queryResult) {
console.log(queryResult);
callback(null, queryResult.replace(/"/g, ""));
});
},
function(tagId, callback){
countTagMembers(tagId, function (queryResult) {
console.log(queryResult);
callback(null, queryResult, tagId[1]);
});
}
], function (err, tagMembers, tagDesc) {
console.log(tagMembers);
console.log(tagDesc);
res.send(tagMembers, tagDesc);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment