This repository was archived by the owner on Jan 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
This repository was archived by the owner on Jan 12, 2019. It is now read-only.
NormalizedCollection orderBy #98
Copy link
Copy link
Open
Description
Hello,
I blocked for some days to retrieve data from Firebase in descending order and in relation to the connected user:
Firebase :
{
"Chats": {
"chats_1000": {
"FriendChat": {
"user_1": true,
"user_2": true
},
"chatDate": 1466755200,
"chatId": "chats_1000"
}
},
"user": {
"user_1": {
"name": "test",
"chats": {
"chats_1000": true
}
}
}
}
Controller
var ref = new Firebase("https://name.firebaseio.com/");
var norm = new Firebase.util.NormalizedCollection(
[ref.child('user/' + userId + '/chats'), 'chat'],
[ref.child('Chats').orderByChild("dateTime"), 'Chats.chatId', 'chat']
);
var ref = norm.select('chat.chatId').ref();
ref.once("value", function (snap) {
console.log('chat'+snap.val());
});
I have no error but no return Firebase .
If I exchange the two links Firebase I 'm conversation sorted in chronological order , but I have every conversation. I would just have the user logged conversations :
Controller
var ref = new Firebase("https://name.firebaseio.com/");
var norm = new Firebase.util.NormalizedCollection(
[ref.child('Chats').orderByChild("dateTime"), 'Chats'],
[ref.child('user/' + userId + '/chats'), 'chat', 'Chats.chatId']
);
var ref = norm.select('Chats.chatId').ref();
ref.once("value", function (snap) {
console.log('chat'+snap.val());
});
I thank you in advance
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels