Reputation: 1401
I´m building kind of a social network where users may send requests to other users.
The controller which gets loaded if the user checks his messages page:
$scope.requestedProfileTrips = Requests.getRequests(user.id).then(function (requests) {
$scope.requestedProfileTrips = [];
for (var i = 0; i < requests.length; i++) {
// this function loads additional data depending on the request from firebase
// from another database
loadProfileTrips(requests[i]);
}
});
The service which gets the requests from firebase:
getRequests: function(userId){
// get requests
var sync = $firebase(ref.child("requests").child(userId));
var requestObject = sync.$asArray();
// add requests to object
return requestObject;
}
The request object includes a userId, a messageId and so on. In the then
function of the controller I get the userId from another database. This should update in realtime.
If I do:
$scope.requestedProfileTrips = Requests.getRequests(user.id);
the updating in realtime works! But I only got the user id and the message id. Is it possible to get the data from the other database which stores the usernames etc. in realtime? So everytime a request is added from firebase, the content in the then
function of getRequests is triggered?
Upvotes: 0
Views: 277
Reputation: 965
Firebase is good in real time sync but other than that as far as I know there is no ready to use database offering the same.
You could however go for a hybrid approach like manually fetching the data from tradition SQL or NoSQL database when your firebase dataset/event get updates/fired. This way you could use both realtime sync of firebase and your traditional database.
Or if you require to integrate realtime sync with traditional databases, then would suggest you look at sockets. Preferably sockets.io would let you get started pretty fast.
Upvotes: 1