How to check if Cloud Firestore collection exists? ( querysnapshot)

前端 未结 2 959
盖世英雄少女心
盖世英雄少女心 2021-01-21 17:37

I\'m having trouble with checking if my collections exists in Firestore database. When I was working with Firebase Realtime database i could have used:

if(databa         


        
2条回答
  •  盖世英雄少女心
    2021-01-21 17:56

    exists() applies to DocumentSnapshot while you're dealing with QuerySnapshot

    Call task.result for getting QuerySnapshot out of Task.

    From that, call result.getDocuments() and iterate through each of the DocumentSnapshot calling exists() on them.

提交回复
热议问题