Cengkuru Michael
Cengkuru Michael

Reputation: 4790

I keep getting the error: Error: Too many arguments provided to Query.startAt(). when using AngularFire2

I have a simple function that accepts parameters and returns the dataset

search(searchValues , numOfItems, startKey?) {
    return this.db.collection('gppContract', ref => ref
    .where('financialYear', '==', searchValues.financialYear)
    .startAt(startKey)
    .orderBy('amount', 'desc')
    .limit(numOfItems + 1))
      .valueChanges();


  }

What am i doing wrong or missing? am at a loss here.

Upvotes: 4

Views: 4808

Answers (1)

Peter Haddad
Peter Haddad

Reputation: 80934

First, orderBy() needs to be before startAt(), to know according to which node the result should be.

Second, orderBy() only takes one argument and it should be the same field as where(), from the docs:

Range filter and orderBy should be on the same fields:

citiesRef.where("population", ">", 100000).orderBy("population")

Check this:

https://github.com/angular/angularfire2/blob/master/docs/firestore/querying-collections.md

Upvotes: 3

Related Questions