Reputation: 153
I have a Firestore query that looks like this:
query = query.where(fieldName)
);
this.subscription = query
.orderBy("time", "desc")
.endAt(this.firstReference)
.limit(3);
Let's say I have 3 items in my list: q1, q2, and q3. The firstReference variable is set to q1 (using this.firstReference = querySnapshot.docs[0];)
When I add 3 new items (q11, q12, and q13 (q11 is the oldest item added after q1)) to the list, the query returns the expected output:
q13
q12
q11
-----
q1 (first reference)
q2
q3
Now let's assume instead of 3 I pass 6 items (q11,q12,q13,q14,q15,q16) (q11 being the oldest item added after q1) when the items present in the list are q1,q1,q3 , The query returns this output:
q16
q15
q14
-----
q1 (first reference)
q2
q3
It should have returned
q13
q12
q11
-----
q1 (first reference)
q2
q3
If I run the query again it should return this output :
q16
q15
q14
-----
q13 (first reference)
q12
q11
Why is the query behavior changing when the number of items returned exceeds the limit, and how can I achieve the desired output?
Upvotes: 0
Views: 22