HarryShotta
HarryShotta

Reputation: 347

Firebase .limit() function

I have a long list of entries that are pushed into Firebase. I am trying to conduct a query on them:

firebase.database().ref('/Ocean/').orderByChild(child).equalTo(search).once('value').then((snapshot) => { 
  ... Do Stuff
})

The above line works, however I am now trying to a) limit the original database before it gets ordered (say to 1000) and b) limit the results of the query to show only 25 results.

For part a) I have tried inserting .limit(1000) into the above line with no success:

firebase.default.database(...).ref(...).limit is not a function.

Am I misunderstanding how to use .limit()?

Upvotes: 2

Views: 2192

Answers (1)

Peter Haddad
Peter Haddad

Reputation: 80934

limit() should be used after equal():

firebase.database().ref('/Ocean/').orderByChild(child).limitToLast(1000).once

Upvotes: 3

Related Questions