DocumentId
This section discusses how where
and field path sentinel documentId()
types works.
__name__
documentId
return __name__
, you can use documentId()
and __name__
interchangeably.
// filter
where('__name__', '==', 'abc') // equivalent to where(documentId(),'==','abc')
// orderBy
orderBy('__name__') // equivalent to orderBy(documentId())
Collection
When querying a collection by documentId(), you must provide a plain document ID, without any forward slash.
FirelordJS displays error mesagae in the hint if it detects any invalid character.
Collection Group
When querying a collection group by documentId(), FirelorsJS rejects the value if the value is not a valid full document path.
FirelordJS displays error mesagae in the hint if it detects path is wrong.
FirelordJS counts and compares the number of slash and displays it in the hint
With OrderBy
The field path of documentId()
is __name__
, this is how you use it with orderBy(to order document by id).
Order by document Id