Hello so I'm trying to combine data retrieved from 3 different locations in my firebase. The data is structured as follows:
dashboard.data.post
dashboard.data.post.image
dashboard.data.post.audio
dashboard.data.post.text
When any user posts they are able to make a post underneath one of those blocks. I would like to be able to search underneath that block for all of the users posts and retrieve that information, combine it all, ordered by the data it was post and display it to the user. So far My method i feel is rudimentary and would appreciate as much help an advice as possible, even if it means restructuring my data.
info.block = $firebaseArray of the id's which the users have of their post
info.text is $firebaseArray of the texts post
info.image is $firebaseArray of the image post
info.audio is $firebaseArray of the audio post
var storage = function(text, image, audio, value, listStore) {
var postkey = value.postid;
angular.forEach(info.text, function(curr, key) {
if (postkey === curr.$id) {
listStore.push(curr);
return true;
}
});
angular.forEach(info.image, function(curr, key) {
if (postkey === curr.$id) {
listStore.push(curr);
return true;
}
});
angular.forEach(info.audio, function(curr, key) {
if (postkey === curr.$id) {
listStore.push(curr);
return true;
}
});
};
info.blog.$loaded().then(function() {
info.text.$loaded().then(function() {
info.image.$loaded().then(function() {
info.audio.$loaded().then(function() {
angular.forEach(info.blog, function(value, key) {
storage(info.text,info.image,info.audio,value,this);
}, $scope.randomObj);
});
});
});
});