How can i set a custom ID to a doc in the new Angularfire 7?
i DONT want the auto genereted one..
my code: (this creates a automatic ID, a want to put my own ID)
addInfos(infos: any) {
const notesRef = collection(this.firestore, "infos");
return addDoc(notesRef, infos)
}
You can specify your own document ID and then call setDoc
instead of addDoc
.
addInfos(infos: any) {
const notesRef = collection(this.firestore, "infos");
return setDoc(doc(notesRef, "your-id"), infos)
}
This is pretty much a direct copy from the Firebase documentation on setting a document, so I recommend spending some time in there to get up to speed.