【发布时间】:2019-01-21 17:57:41
【问题描述】:
我有一个 Firestore 数据库,其中包含 2 个不同的对象集合,即用户和属性。我希望能够根据用户存储的偏好向用户显示属性提要中的相关属性卡(即,如果他们的城市偏好保存为“都柏林”,则仅显示位于都柏林的属性)。
我的属性提要组件目前如下所示:`
export class PropertyFeedComponent implements OnInit {
Propertys;
filtered;
Property: Observable<any[]>;
filter = new BehaviorSubject(null);
constructor(
public db: DbService,
public modal: ModalController,
public auth: AuthService
) {}
ngOnInit() {
this.Propertys = this.auth.user$.pipe(
switchMap(user =>
this.db.collection$('Propertys', ref =>
ref
.orderBy('createdAt', 'desc')
.limit(100)
)
),
shareReplay(1)
);
// this.filtered = this.filter.pipe(
// switchMap(status => {
// return this.Propertys.pipe(
// );
// })
// );
}
}
` 我有一个过滤函数被注释掉,因为我不确定这是否是最好的方法。 我在我的 HTML 中从数据库中调用属性,如下所示:
<ng-container *ngIf="(auth.user | async) || {} as user">
<ion-card *ngFor="let Property of Propertys | async; trackBy: trackById">
如何查询每个单独的对象以查看它是否与用户存储的偏好匹配。
【问题讨论】:
标签: angular firebase ionic-framework ionic4