Expected behavior
Getting from the firestore a nested collection orderBy('seqNo', sortOrder)
Actual behavior
I can easily fetch the data if I do:
getAll(collectioName: string) {
const response: AngularFirestoreCollection<ID> = this.db.collection(collectioName);
return response.snapshotChanges()
.pipe(
map(snaps => snapsCoverter(snaps))
)
}
but as soon as I do:
getCollectionPaginated(collectioName: string, sortOrder: OrderByDirection, pagesize: number, pageNumber: number) {
const response: AngularFirestoreCollection<ID> = this.db.collection(
collectioName,
ref => ref
.orderBy('seqNo', sortOrder)
.limit(pagesize)
.startAfter(pageNumber * pagesize)
);
return response.snapshotChanges()
.pipe(
map(snaps => snapsCoverter(snaps))
)
}
It returns an []
here's I invoke the method:
this.service.getCollectionPaginated(`courses/${id}/${nestedCollectionPath}`, "asc", 3, 0)
.subscribe(x => console.log(x))
Information about the Issue
I am sure as hell the problem is here:
ref => ref
.orderBy('seqNo', sortOrder)
.limit(pagesize)
.startAfter(pageNumber * pagesize)
It works fine as long as I try to apply this logic to the main collection but it does't work on a nested one.
Could you please have a look?
Many Thanks.