-
-
Save michaelklishin/2880071 to your computer and use it in GitHub Desktop.
Activity Query with Relational DB
This file contains hidden or 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
// no, node.js does not suffer from the callback spaghetti. Never. | |
Bug | |
.select('createdAt', 'creatorId', 'name', 'url', 'description') | |
.page(0, 10) | |
.order('createdAt DESC') | |
.all(function(err, bugs) { | |
Commit | |
.select('createdAt', 'creatorId', 'name', 'url', 'description') | |
.page(0, 10) | |
.order('createdAt DESC') | |
.all(function(err, commits) { | |
// coalesce | |
ordered = coalesce(bugs, commits, 10); | |
uniqueUsers = findUniqueUsers(ordered); | |
uniqueProjects = findUniqueProjects(ordered); | |
User | |
.select('id', 'name', 'url', 'avatar_url') | |
.where({ 'id.in': uniqueUsers }) | |
.all(function(err, users) { | |
Project | |
.select('id', 'name', 'url', 'avatar_url') | |
.where({ 'id.in': uniqueProjects }) | |
.all(function(err, projects) { | |
// finally, now correlate all the data back together | |
var activities = []; | |
//... | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment