I wish to be able to add projects in a subcollection called projects. Currently my tree is: db/membres/[membreID]/projects/(here I want project ID that firebase generates)/(information of project)
Here is my firebase:
This is the error I get: Invalid document reference. Document references must have an even number of segments, but membres/UVLPL9kxP1hGuiwCStS4oDLJvxo1/projets has 3.
2
Answers
The error message is quite clear: you are trying to write to a document at path
/membres/$uid/projects
, but that is the path of a collection.If you want to add a document to that subcollection, use
addDoc
instead ofsetDoc
.addDoc works like that: