Is possible to check if a collection or sub collection exists?

前端 未结 3 2038
我寻月下人不归
我寻月下人不归 2020-11-27 21:35

Is there a way to check if a sub collection exists in firestore for nodejs?

Currently I am using doc.exists for documents but I need to check if a subco

3条回答
  •  渐次进展
    2020-11-27 22:05

    Mateus' Answer didn't help me. Probably it has been changed over the time.

    .collection(..).get() returns a QuerySnapshot which has the property size, so I just did:

    admin.firestore
         .collection('users')
         .doc('uid')
         .collection('sub-collection')
         .limit(1)
         .get()
         .then(query => query.size);
    

提交回复
热议问题