I am trying to add INSTITUTE NAME in 1 collection. then in another collection I want to add its EMAIL ID of that institute name and email can be multiple.
What I tried
const registerRef = collection(db, 'instituteList');
const userRef = collection(db, 'usersList');
addDoc(registerRef, { institute })
.then(function (registerRef) {
addDoc(doc(userRef, registerRef.id), { email })
})
My Problem:-
I am getting this ..
Document references must have an even number of segments, but.. has 3
Please help me with this.
2
Answers
The firestore data model follows an alternating pattern of collections and documents. You cannot nest a collection under collection, or document under document. That’s why document references always an even number of references.
You need to change your database model in order to meet this condition of firestore. Learn more about the firestore data model here
The error means that you have wrong
db.collection("/one" + uid + "/three")
syntax.Also try Using 2
addDoc
properties, one for adding institute name and one for emailId so your code will be: