Skip to content

startAt to support key #1114

Closed
Closed
@bob-lee

Description

@bob-lee

Version info

Angular: 4.3.5

Firebase: 4.3.0

AngularFire: 4.0.0-rc.2

Other (e.g. Ionic/Cordova, Node, browser, operating system): Chrome 60, Windows 7

How to reproduce these conditions

Failing test unit, Plunkr, or JSFiddle demonstrating the problem

Steps to set up and reproduce
Have read a bit old issue #362 but I am raising here again with some info. For pagination, I need to use startAt with optional key combined with orderByChild.

To emulate the behavior that gets the next page content, I ran below code with some hard coded values found in my notes database and it gives me what I expected - two notes under 'Issues' group starting with the one with given key:

    const query = this.db.database.ref('notes')
      .orderByChild('group')
      .limitToFirst(2)
      .startAt('Issues', '-KqFzkJy-DCM7mmH3jo5');
    query.on('child_added', (snap) => {
      console.log(snap.val(), snap.key);
    });

But if run below code, I got nothing:

    this.notes = this.db.list(`notes`, {
      query: {
        orderByChild: 'group',
        equalTo: 'Issues',
        limitToFirst: 2,
        startAt: { value: 'Issues', key: '-KqFzkJy-DCM7mmH3jo5' } // need this feature..
      }
    });

If I comment out startAt line above, it gives me first two notes under 'Issues' group.

Sample data and security rules

<-- include/attach/link to some json sample data (or provide credentials to a sanitized, test Firebase project) -->

Debug output

** Errors in the JavaScript console **

** Output from firebase.database().enableLogging(true); **

** Screenshots **

Expected behavior

Get the same result that Firebase SDK gives.

Actual behavior

No console errors, no result.

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