Skip to content
This repository was archived by the owner on Jan 12, 2019. It is now read-only.
This repository was archived by the owner on Jan 12, 2019. It is now read-only.

NormalizedCollection orderBy #98

@KyDenZ

Description

@KyDenZ

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions