0

I want to know if sub collection 'categories' is created inside my users collection in Firestore and return true if created and false if not

Shakar Bakr
  • 57
  • 1
  • 10

1 Answers1

1

Subcollections are not really created. They simply appear to exist as soon as a document is first added to it, and they appear to be removed as soon as the last document is deleted.

If you want to know if a subcollection appears to exist, then all you have to do is query it. If it returns documents, then you know it exists. You can limit the query to 1 document to be efficient about it.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441