CodePudding user response:
If you don't specify document ID in doc(collctionRef)
then it'll generate one automatically. The same was in previous SDK:
// This would add a Document with random ID
// V8
colRef.doc().set({})
// V9
setDoc(doc(colRef))
From the same documentation,
Behind the scenes,
.add(...)
and.doc().set(...)
are completely equivalent, so you can use whichever is more convenient.