Quering collection with a nonexistent document's property
Overview of the Issue When ordering by a non existent document property (like 'transferDate', when there is a 'date' property instead) like in the next sentence example
this.filesCollection = afs.collection('myfiles', ref => ref.orderBy('transferDate', 'desc'));
... snapshotChanges() method fires an empty array on the payload, when document changes happend. No error message is returned or logged and an empty result array is returned.
this.filesCollection.snapshotChanges()
Angular Version Angular CLI: 9.1.3 Node: 12.16.1 OS: win32 x64 Angular: 9.1.3 Package Version
@angular/fire 6.0.0
Motivation for or Use Case Avoid difficult to spot bugs.
Browsers and Operating System N/A
Reproduce the Error In collection query, just use a property that doesn't exist in the document. No error message will be returned nor log message displayed. Still, query results will be affected.
Related Issues None
Suggest a Fix If I didn't miss something in the documentation, I would suggest that if nonexistent properties (used in orderBy, where) are having effects on query results, it might be better to return an error or print a warning also, or instead. Having said that, please notice that i'm new to Javascript and Firebase, so probable I missed some background or documentation reading. I don't even know in which layer this could be accomplished.
We have no way of telling that. The Firestore query just returns a null set per the design of Firestore.