I enjoy using the Firebase version 9 modules, however, I find that doc
is not to my liking. It would be better if it were document
, similar to how collection
is not shortened to col
.
The following code does not function as expected:
import { doc, collection, deleteDoc } from '@angular/fire/firestore';
this.querySnapshot.forEach((doc) => {
deleteDoc(doc(this.firestore, 'users', doc.id));
});
To make it work properly, I have to modify it like this:
import { doc, collection, deleteDoc } from '@angular/fire/firestore';
this.querySnapshot.forEach((docElement) => {
deleteDoc(doc(this.firestore, 'users', docElement.id));
});
Alternatively, I prefer changing it to:
import { document, collection, deleteDocument } from '@angular/fire/firestore';
this.querySnapshot.forEach((doc) => {
deleteDocument(document(this.firestore, 'users', doc.id));
});
I have two inquiries. Firstly, how can I address this issue with the Firebase team? And secondly, is it possible to create an alias for the doc
module? I attempted to do so without success.
import { doc, collection, deleteDoc } from '@angular/fire/firestore';
export class AppComponent {
document: Function = doc;
this.querySnapshot.forEach((doc) => {
deleteDoc(document(this.firestore, 'users', doc.id));
});
}
Unfortunately, that attempt was unsuccessful. :-)