0

I am trying to create a document and collection following each other

with this reference

    CollectionReference att = FirebaseFirestore.instance
    .collection('attendance/$_currentClass/pieces');

but when it is created it is shown like that image below

and i can't see documents that has name of "_currentClass" variable.

If we create create it by ourselves it creates properly.

Here top one was created by me and bottom one created inside flutter

What am i doing wrong?

armancj2
  • 108
  • 1
  • 4

1 Answers1

0

Based on your path your CollectionReference to this subcollection is:

CollectionReference att = FirebaseFirestore.instance
                                           .collection('attendance')
                                           .doc(_currentClass)
                                           .collection('pieces');

Document, you are pointing with italic font does not exist, it was deleted, but before that it had a collection, and pointing that documents on that subcollection were not deleted and they still exist.If you create documents with sub-documents and then delete the top level document from an SDK, the delete is not recursive. So while the top-level document is gone, its sub-documents remain.

Since there is no document anymore, the document itself will not show up in query results. If you need to find this document in query results, you'll want to create an empty document as a workaround.

Simon Sot
  • 2,748
  • 2
  • 10
  • 23
  • It is still invisibile when i try to retrieve it. I cannot get it with that code. It is written in italic and seems a little bit invisible in firestore. CollectionReference ref = FirebaseFirestore.instance.collection("attendance/11-c"); QuerySnapshot snapshot = await ref.get(); print(snapshot.docs); – armancj2 Apr 08 '21 at 10:02
  • E/flutter (17833): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: 'package:cloud_firestore/src/firestore.dart': Failed assertion: line 62 pos 12: 'isValidCollectionPath(collectionPath)': a collection path must point to a valid collection. – armancj2 Apr 08 '21 at 10:03
  • @armancj2 this is another question, here is an answer for it https://stackoverflow.com/a/48138953/13701546 – Simon Sot Apr 08 '21 at 10:05
  • Thanks. If you write it as answer i will accept. – armancj2 Apr 08 '21 at 10:40