I am using fb-util for infinite scroll and everything looks good. However, once I hit 250 elements, I am seeing the following error. Any idea what this is about ?
Error: Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo(). at Jh (https://www.gstatic.com/firebasejs/3.2.1/firebase.js:431:117) at X.g.Nd (https://www.gstatic.com/firebasejs/3.2.1/firebase.js:441:298) at r._grow (https://<>/content/script/firebase-util.min.js:10:8979) at r._listen (https://<>/content/script/firebase-util.min.js:10:10961) at r.goTo (https://<>/content/script/firebase-util.min.js:10:8062) at r.moveTo (https://<>/content/script/firebase-util.min.js:10:3672) at r.next (https://<>/content/script/firebase-util.min.js:10:17083) at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:198:424 at xa.(anonymous function) (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:59:133) at l.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js:126:84)
Code:
var baseRef = firebase.database().ref().child(refPath);
var scrollRef = new firebase.util.Scroll(baseRef, '$key');
scrollRef.scroll.next(25);
var list = $firebaseArray(scrollRef);
list.scroll = scrollRef.scroll;
Front-end code:
<div infinite-scroll="vm.products.scroll.next(10)" infinite-scroll-distance="1">
nb: Changing the key from $key to $priority or name or productid, stopped producing the error. But, this caused the earlier elements to be replaced.
So, while I do not have an answer for the first part of the question, based on the additional note, I have this fix:
Setting the maxCacheSize and windowSize to a higher value should solve the issue. As per documentation, if we exceed windowSize then the start of the array is trimmed to keep the size under limit.
Documentation: