0

I'm making a whiteboard app using Flutter and Firestore. This whiteboard app creates a room first, then creates pages, and then draws inside the page.

Firestore has the following configuration:

enter image description here

I need to be able to get the number of subcollections in Firestore to get the number of pages.

How do I get the number of these subcollections(pages)?

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
Kevin Yang
  • 629
  • 1
  • 5
  • 19

2 Answers2

1

There is no function that can return the number of sub-collections that exist within a document. If you need such a count, you need to create this mechanism yourself. But it's pretty simple, you can create a document in which you can increment/decrement a numeric value, each time a new sub-collection is added or deleted from the document.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
1

You can't get all collection from one doc in dart.

Retrieving a list of collections is not possible with the mobile/web client libraries. You should only look up collection names as part of administrative tasks in trusted server environments. If you find that you need this capability in the mobile/web client libraries, consider restructuring your data so that subcollection names are predictable.

Here is the document link.

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
Pratik Dudhatratra
  • 342
  • 1
  • 3
  • 9