Replace Firestore module `doc` with `document`?

Viewed 35

I like the Firebase version 9 modules but I don't like doc. It should be document. This would match collection, which isn't col.

This code doesn't run:

import { doc, collection, deleteDoc } from '@angular/fire/firestore';

this.querySnapshot.forEach((doc) => {
  deleteDoc(doc(this.firestore, 'users', doc.id));
});

I have to change it to

import { doc, collection, deleteDoc } from '@angular/fire/firestore';

this.querySnapshot.forEach((docElement) => {
  deleteDoc(doc(this.firestore, 'users', docElement.id));
});

I'd rather change it to

import { document, collection, deleteDocument } from '@angular/fire/firestore';

this.querySnapshot.forEach((doc) => {
  deleteDocument(document(this.firestore, 'users', doc.id));
});

I have two questions. First, how do I make this request to the Firebase team? Second, can I make an alias for the doc module? I tried this but it didn't work.

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));
  });
}

That didn't work. :-)

1 Answers

You can use set an alias when importing:

import { doc as fireDoc } from '@angular/fire/firestore';

this.querySnapshot.forEach((doc) => {
  // use fireDoc() here 
  deleteDoc(fireDoc(this.firestore, 'users', doc.id));
});
Related