Is there a way that I can get the auto-generated ID for a document created as part of a batch using Firestore?
When using .add()
I can easily get an ID:
I had similar issue, And I thing there were changes at the API of firestore.
I was getting an error for code like :
const postsRef = db.collection('posts').doc(postKey);
batch.set(postsRef, {title: 'Hello Again, World'});
The change I found that was necessary is to take the ref
of the doc object:
const postsRef = db.collection('posts').doc(postKey).ref;
I hope this helps you all !