ensureFirestoreRoot function

Future<void> ensureFirestoreRoot(
  1. FirebaseFirestore firestore,
  2. String root,
  3. String projectId
)

Creates the project's root document (root) when missing.

Implementation

Future<void> ensureFirestoreRoot(FirebaseFirestore firestore, String root, String projectId) async {
  final ref = firestore.doc(root);
  if ((await ref.get()).exists) return;
  await ref.set({'project': projectId});
}