AngularFirestore Get a document by field

17 Views Asked by At

How can i get a document by field, i am already getting a document by id with this code

export class FileService {

  recordDoc!: AngularFirestoreDocument<Fileobject>;

  constructor(public db: AngularFirestore) {
     
  }

  getById(id: string) {
      this.recordDoc = this.db.doc(`files/${id}`)
      return this.recordDoc.valueChanges({ idField: 'id' });
  }

but i cant find how to get a document for a field "name"

i tried

getByName(name: string) {
   this.recordDoc = this.db.doc(`files/${name}`)
   return this.recordDoc.valueChanges({ idField: 'id' });
}
0

There are 0 best solutions below