I am facing an issue with a query that I run on various data types. Recently, one of the collections stopped returning results after I included orderBy
clauses.
getEntitiesOfType(entityType: EntityType): Observable<StructuralEntity[]> {
const collection = this.findCollection(entityType);
const entities$ = this.afs
.collection(collection, (ref) =>
ref.orderBy('disabled').orderBy('title').orderBy('id') // The problem lies here
)
.snapshotChanges()
.pipe(
map((docs) =>
docs.map((dca) => {
const data = dca.payload.doc.data() as StructuralEntity;
return {
id: dca.payload.doc.id,
title: data.title,
name: data.name,
type: data.type,
icon: data.icon,
model: data.model,
context: data.context,
disabled: data.disabled,
} as StructuralEntity;
})
)
);
return entities$;
}
The specific collection that stopped displaying results does not contain fields like disabled
or title
, which I recently added for ordering purposes. To troubleshoot, I even updated the index to include field id
, but it still doesn't return any results.
I am puzzled as to why Firestore is not returning results based on this index. Can anyone offer insights into this?
disabled | title | id |
---|---|---|
undefined | undefined | "1" |
undefined | undefined | "2" |