[英]Query inner object id in a collection using Firestore/ Angularfire2 or Firestore SDK
Could you tell me how to query id
of budgetGroup
object in budgets
collection? 您能告诉我如何在
budgets
集合中查询budgetGroup
对象的id
吗?
I can do a basic query like below. 我可以进行如下基本查询。 But how can I query an inner object as mentioned above?
但是,如何如上所述查询内部对象?
provider.ts provider.ts
getSpecificBudget(id:string;budgetGroup: BudgetGroup, projectId: string): AngularFirestoreCollection<Budget> {
return this.fireStore.collection<Budget>(`projects/${projectId}/budgets`, ref => ref
.where('id', '==', id)
);
}
model.ts 模型
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;
}
firestore: 消防站:
This is the solution.We can simply do as shown below. 这是解决方案。我们可以简单地如下所示。 ie
.where('budgetGroup.id', '==', budgetGroup.id)
即
.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.