Is it possible to create an Observable that is limited to a single document?
While the code provided creates an Observable for querying multiple documents:
foo.component.ts
import { AngularFirestore } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
...
export class FooComponent implements OnInit {
...
docs: Observable<any[]>;
constructor(private db: AngularFirestore) {
this.docs = db.collection('myCollection', ref => ref.where('name', '==', 'foobar')).valueChanges();
}
foo.component.html
<div *ngFor="let doc of docs | async">
{{ doc.name }}, {{ doc.address }}
</div>
If I know there will only be 1 document returned, how can I achieve the same result without using an *ngFor loop?
I attempted
this.doc = db.collection('myCollection', ref => ref.where('name', '==', 'foobar').limit(1)).valueChanges();