Flutter是否支持FieldPath?
问题内容:
我FieldPath
在cloud_firestore
Flutter插件中找不到,但是,我认为这是一个非常通用的工具,将是此类插件的首批实现之一。
FieldValue
是最近添加的,但我在上找不到任何内容FieldPath
。
如果我当前要documentId
在 查询中 使用,是否可以实现?
问题答案:
我居然忘了这一点,但我加FieldPath.documentId
为部分拉入请求,以cloud_firestore
在某些时候。
这意味着您可以像这样简单地使用它:
Firestore.instance.collection('movies').orderBy('rating').orderBy(FieldPath.documentId);
过时的
__name__
如果要 定位 文档ID则可以使用 。
您可以将'__name__'
用作String
,等效于FieldPath.documentId()
。
~~~~
String fieldPathDocumentId = '__name__';
Firestore.instance.collection('movies').orderBy('rating').orderBy(fieldPathDocumentId);