I could not find FieldPath
in the cloud_firestore
Flutter plugin, however, I would assume that this is a very common tool that would be one of the first implementations for such a plugin.
FieldValue
was recently added, but I could not find anything on FieldPath
.
If I wanted to use the documentId
in a query currently, would there be a way to achieve this?
I actually forgot about this, but I added FieldPath.documentId
as part of a pull request to cloud_firestore
at some point.
This means that you can simply use it like this:
Firestore.instance.collection('movies').orderBy('rating').orderBy(FieldPath.documentId);
Obsolent
__name__
works if you want to target the document id.
You can use '__name__'
as a String
, which is equivalent to FieldPath.documentId()
.
String fieldPathDocumentId = '__name__';
Firestore.instance.collection('movies').orderBy('rating').orderBy(fieldPathDocumentId);