When calling orderByChild() any subsequent call to startAt() , endAt() or equalTo() expects the value you pass to be a child. You pass the index. If the domain value is a sequential index (highly unlikely), this will not work.
What you need to do is remember the domain value for your last child, and then pass this to startAt() for the next "page".
var productsRef = ref.child('products'); var lastKnownDomainValue = null; var pageQuery = productsRef.orderByChild('domain').limitToFirst(100); pageQuery.once('value', function(snapshot) { snapshot.forEach(function(childSnapshot) { lastKnownDomainValue = childSnapshot.child('domain').val(); }); });
Now you have the lastKnownDomainValue variable, which has the last domain you have ever seen. To get the following batch of children, you pass this value to startAt() :
var nextQuery = productsRef.orderByChild('domain').startAt(lastKnownDomainValue).limitToFirst(100);
And then you update lastKnownDomainValue when you loop back on them again.
source share