Is FieldPath supported in Flutter?

前端 未结 2 1308
梦毁少年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);
    

    0 讨论(0)
  • 2020-12-18 11:58

    This works for me. (I am not sure this is what you wanted.)

    Firestore.instance.collection('/collection-name')
      .where(FieldPath.documentId, isEqualTo: _someID)
      .snapshots().listen((snapshots){
        /*
    
        */
      });
    
    0 讨论(0)
提交回复
热议问题