Last active
August 29, 2015 13:57
-
-
Save hiun/9860532 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)'])); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
}); | |
}); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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