Query a Map containing an ID saved in Cloud Firestore with Dart/Flutter

后端 未结 3 1147
广开言路
广开言路 2021-01-26 12:45

How to get a Map stored in Cloud Firestore with Dart/Flutter ? I tried this but it only works with Array :

Firestore.instance
            .collection(\'posts\')
          


        
3条回答
  •  后悔当初
    2021-01-26 13:18

    It doesn't really make sense for userlist to be an array here. Firestore doesn't let you query for values of maps inside an array. Just store it as a map. If userlist was just a map of uid/value pairs, you could query it like this using dot notation:

    Firestore.instance
            .collection('posts')
            .orderBy('createdAt', descending: true)
            .where('userlist.' + userId, isEqualTo: true)
            .snapshots(),
    

提交回复
热议问题