Could you tell me how to query id
of budgetGroup
object in budgets
collection?
I can do a basic query like below. But how can I query an inner object as mentioned above?
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)
getSpecificBudgetGroupBudget(budgetGroup: BudgetGroup, projectId: string): AngularFirestoreCollection<Budget> {
return this.fireStore.collection<Budget>(`projects/${projectId}/budgets`, ref => ref
.where('budgetGroup.id', '==', budgetGroup.id)
);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.