Skip to content

V3: orderByChild + startAt or endAt #174

Closed
@florianbepunkt

Description

@florianbepunkt

@Salakar Sorry to bother you again. It seems like orderByChild is not working, at least when used with startAt or endAt. I have a list of message objects that I want to query based on their timestamp.

This code returns zero results

firestack
  .database()
  .ref('messages/-KXlqrDgbJg_-FJCoDfE/')
  .orderByChild('createdAt')
  .startAt(1480609558242)
  .once('value')
  .then((snapshot) => {
    console.log('my snap', snapshot);
  })

while this code returns all results

firestack
  .database()
  .ref('messages/-KXlqrDgbJg_-FJCoDfE/')
  .orderByChild('createdAt')
  .endAt(1480609558242)
  .once('value')
  .then((snapshot) => {
    console.log('my snap', snapshot);
  })

Based on my sample data below…both results are wrong. The first example should return the first last two objects, the second example should return the first two objects.

I tried both the v3 branch of this repo as well as master branch of your fork. Based on the sample data the query above should return the first object. But nothing is returned


{
  "-KXlqrDgbJg_-FJCoDfE" : {
    "-KXv8Uvyix9Ns5FeF1O1" : {
      "_id" : "-KXv8Uvyix9Ns5FeF1O1",
      "createdAt" : 1480608580717,
      "text" : "Test123",
      "user" : {
        "_id" : "If2AZYNhruXa4ELtYoviNe7JS2S2"
      },
      "wasSeen" : false
    },
    "-KXvCCjPLePNohIkjSw3" : {
      "_id" : "-KXvCCjPLePNohIkjSw3",
      "createdAt" : 1480609553540,
      "text" : "Test456",
      "user" : {
        "_id" : "If2AZYNhruXa4ELtYoviNe7JS2S2"
      },
      "wasSeen" : false
    },
    "-KXvCDsZq__24IkB6zGs" : {
      "_id" : "-KXvCDsZq__24IkB6zGs",
      "createdAt" : 1480609558242,
      "text" : "Test789",
      "user" : {
        "_id" : "If2AZYNhruXa4ELtYoviNe7JS2S2"
      },
      "wasSeen" : false
    },
    "-KXvQisiS1bsm3oYCdll" : {
      "_id" : "-KXvQisiS1bsm3oYCdll",
      "createdAt" : 1480613359327,
      "text" : "Test101112",
      "user" : {
        "_id" : "If2AZYNhruXa4ELtYoviNe7JS2S2"
      },
      "wasSeen" : false
    }
  }
}

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