I'm currently developing a web app with Angular 2 and facing an issue with retrieving data from Firebase based on specific conditions in the child node. Here's how my Firebase structure looks like: I need to extract the entry for the one with approverEmail set as [email protected] and status as 0 (both conditions must be met simultaneously).
{
"BugList" : {
"Company 1" : {
"-Kbne6WxelgI6Qv9T0eP" : {
"approverEmail" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a0c1d0d0d2cfd6c5d291e0cdc1c9cc8ec3cfcd">[email protected]</a>",
"firstName" : "Jack",
"lastName" : "Daniels",
"noteToApprover" : "Gooday mate",
"status" : 0,
},
"-Kbne6WxelgI6Qv9T0QP" : {
"approverEmail" : "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="04657474766b726176364469656d682a676b69">[email protected]</a>",
"firstName" : "Tom",
"lastName" : "Riddle",
"noteToApprover" : "Howdy",
"status" : 1,
}
}
},
}
My current approach involves using angularFire2, which lacks sufficient documentation on this particular issue. This is where I'm at right now and could use some guidance.
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()
}
This is the snippet of code from 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: {
}
});
}
}