Skip to content

Instantly share code, notes, and snippets.

@StephenFluin
Created October 9, 2015 23:26
Show Gist options
  • Save StephenFluin/78651116e9ba922e0d9c to your computer and use it in GitHub Desktop.
Save StephenFluin/78651116e9ba922e0d9c to your computer and use it in GitHub Desktop.
Firebase Join Tool
// I'd love a mixin capability where I supply a route
// This route has an object of id=>true's, and for each ID we map on another route
// And save it as the data on the object.
app.factory("Mixer", ['$firebaseAuth', '$firebaseObject',
function($firebaseAuth, $firebaseObject) {
var mixer = function(sparseList, verboseList) {
var sparseRef = FB.child(sparseList);
var verboseRef = FB.child(verboseList);
var list = $firebaseObject(sparseRef);
list.$loaded(function() {
for(var key in list) {
if(key[0] === '$' || key === "forEach") {
continue;
}
list[key] = {data: $firebaseObject(verboseRef.child(key))};
}
});
return list;
};
return mixer;
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment