I am using Angular 2 to build a web app. I am trying to retrieve data from firebase when one or more of the condition(s) are met in the child node. For example, below is how my firebase are structured. I want to pick out the entry for the one with approverEmail being approver1@mail.com as well as status being 0 (Both have to be met at the same time).
{
"BugList" : {
"Company 1" : {
"-Kbne6WxelgI6Qv9T0eP" : {
"approverEmail" : "approver1@mail.com",
"firstName" : "Jack",
"lastName" : "Daniels",
"noteToApprover" : "Gooday mate",
"status" : 0,
},
"-Kbne6WxelgI6Qv9T0QP" : {
"approverEmail" : "approver2@mail.com",
"firstName" : "Tom",
"lastName" : "Riddle",
"noteToApprover" : "Howdy",
"status" : 1,
}
}
},
}
Currently, I am using angularFire2 which has limited amount of information on this topic. This is what I have at the moment and I am stuck
forms.service.ts
getPendingApproval() {
var currentUser: User = this.userService.getCurrentUser();
const queryList = this.af.database.list('/BugList/' + currentUser.company, {
query: {
// email field match currentUser.email && status == 0
}
});
}
and in my app.component.ts
getList() {
this.list = this.formsService.getPendingApproval()
}
Code for my forms.service.ts
@Injectable()
export class FormsService {
constructor(private af: AngularFire, private userService: UserService) { }
saveToFirebase(bug: Bug) {
const bugRef = this.af.database.list('/BugsList/' + bug.companyName);
return bugRef.push(timesheet)
}
getPendingApproval() {
var currentUser: User = this.userService.getCurrentUser();
const queryList = this.af.database.list('/BugsList/' + currentUser.company, {
query: {
}
});
}
}