Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Query range with START_AT not fetching data as expected #328

Closed
NordlingDev opened this issue Mar 23, 2017 · 2 comments
Closed

Query range with START_AT not fetching data as expected #328

NordlingDev opened this issue Mar 23, 2017 · 2 comments

Comments

@NordlingDev
Copy link

NordlingDev commented Mar 23, 2017

I left another issue (#319) about null not working with EQUAL_TO. This is somewhat related to that issue, but with START_AT. I'm trying to fetch data based on price property. The value of price can either go from 0 (free article) to anything higher.

I have these articles in my database:

{
  "articles": {
    "-article1": {
      "title": "Article 1",
      "price": 0
    },
    "-article2": {
      "title": "Article 2",
      "price": 50
    },
    "-article3": {
      "title": "Article 3",
      "price": 100
    }
  }
}

If I put 0 to the START_AT range, the snapshot function will never fire (neither does the then promise):

firebase.query(snapshot => {
  console.dump(snapshot); // This never fires
}, "/articles", {
  singleEvent: true,
  orderBy: { type: firebase.QueryOrderByType.CHILD, value: "price" },
  range: { type: firebase.QueryRangeType.START_AT, value: 0 }
}).then(() => {
  console.log("TEST"); // This never fires either!
});

If I set the START_AT value to 1 instead, it works. The same type of query works with the official Firebase Node.js (Admin):

admin.database().ref("/articles").orderByChild("price").startAt(0).once("value").then(snapshot => {
  console.log(snapshot.val()); // Logs all articles
});
@NordlingDev NordlingDev changed the title Query range with START_AT fetching data as expected Query range with START_AT not fetching data as expected Mar 23, 2017
@EddyVerbruggen
Copy link
Owner

Does this happen on iOS, Android, or both?

@NordlingDev
Copy link
Author

NordlingDev commented Mar 23, 2017

@EddyVerbruggen - Can only speak for iOS. Never tried on Android.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants