Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add a sub collection to a collection without creating document in firestore in android?

I am new to cloud firestore in firebase. In my project I created category as collection which is common to all users. But I need to create category as sub collection for each collection. Is it possible?

Any help will be highly appreciated.

like image 305
Gopinathan B Avatar asked Jul 24 '18 15:07

Gopinathan B


1 Answers

It is possible to add sub collection to collection without creating document in firestore in android?

Definitely not! According to the official documentation, the only structure that is permited is as follows:

db.collection('coll').doc('doc').collection('subcoll').doc('subdoc')

There is no way in Firestore to store a collection beneath other collection. So the following line of code is not allowed:

db.collection('coll').collection('subcoll').doc('subdoc') //Not allowed

As there is no way to store a document beneath other document.

db.collection('coll').doc('doc').doc('subdoc') //Not allowed
like image 69
Alex Mamo Avatar answered Oct 16 '22 18:10

Alex Mamo