[英]Query inner object id in a collection using Firestore/ Angularfire2 or Firestore SDK
您能告訴我如何在budgets
集合中查詢budgetGroup
對象的id
嗎?
我可以進行如下基本查詢。 但是,如何如上所述查詢內部對象?
provider.ts
getSpecificBudget(id:string;budgetGroup: BudgetGroup, projectId: string): AngularFirestoreCollection<Budget> {
return this.fireStore.collection<Budget>(`projects/${projectId}/budgets`, ref => ref
.where('id', '==', id)
);
}
模型
export class Budget {
id: string;
amount: number;
contingency: number = 20;
budgetGroup: BudgetGroup = new BudgetGroup();
creationTime: string;
}
export class BudgetGroup {
id: string;
name: string;
creationTime: string;
}
消防站:
這是解決方案。我們可以簡單地如下所示。 即 .where('budgetGroup.id', '==', budgetGroup.id)
getSpecificBudgetGroupBudget(budgetGroup: BudgetGroup, projectId: string): AngularFirestoreCollection<Budget> {
return this.fireStore.collection<Budget>(`projects/${projectId}/budgets`, ref => ref
.where('budgetGroup.id', '==', budgetGroup.id)
);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.