When working with Firebase, I have the need to extract data from tables/nodes.
Specifically, I am dealing with two tables - one called jobs and the other called organisations.
The outcome I am looking for: I want to retrieve all companies that do not have any jobs listed.
To illustrate, here is a simplified example of my jobs list node/table structure:
jobs: {
-k3resdfsfsdfsdf:{jobName: test1, companyId: 1h3hr4jrkfk5k5kff},
-k3resdfsfsdfsdf:{jobName: test2, companyId: 2h3hr4jrkfk5k5kff},
-k3resdfsfsdfsdf:{jobName: test3, companyId: 2h3hr4jrkfk5k5kff}
}
Here is a similar example of my organisations table structure:
organisations: {
fsdfsddfsfsdfsdf:{companyId: 1h3hr4jrkfk5k5kff, companyName: comp a, address: 12 road},
jhhjresdfsfsdfsf:{companyId: 2h3hr4jrkfk5k5kff, companyName: comp b, address: 11 road},
hsdfskhjfsdfsdf: {companyId: 3h3hr4jrkfk5k5kff, companyName: comp c, address: 10 road}
}
I am aiming to identify and retrieve all organisations that do not have any job listings in the jobs list. Essentially, I am seeking to cross-reference the data.
This is what I have attempted so far:
this.firebaseBaseUrl = "hiddenForStackOverflow";
this.refOrg = new Firebase(firebaseBaseUrl + "/organisations");
this.refJobs = new Firebase(firebaseBaseUrl + "/jobs");
this.refOrg .once('value', function(snapshot: any) {
snapshot.forEach(function(orgSnapshot: any) {
var listOfOrganisations= orgSnapshot.val();
// I am currently unsure how to achieve this without iterating through both lists, which might lead to performance issues.
});
});