Is FieldPath supported in Flutter?

前端 未结 2 1320
梦毁少年i
梦毁少年i 2020-12-18 11:07

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 impleme

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-18 11:49

    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);
    

提交回复
热议问题