I'm trying to make a select query with 2 inner joins over 3 tables to be able to show all tasks for the whole company.
Meaning I have three tables and I would like to obtain the tasks of all the Employees within the company.
Table 1: Companies
===================
ID CompanyName
===================
1 Company1
2 Company2
Table 2: Employes
=============================
ID Name CompanyID
=============================
1 Employee1 1
2 Employee2 1
3 Employee3 2
Table 3: Tasks
==============================
ID TaskTitle EmployeeID
==============================
1 Feature1 1
2 Feature2 2
3 Feature3 3
4 Feature4 1
So result for companyID === 1 should be tasks 1, 2 and 4.
I know you can populate data using mongoose but only if there is a relationship in the table where you are trying to populate those data. Which is not in this approach of relationships using only parent ids.
Is there a way to do this in mongo using mongoose (keystoneJS)?
Any help is much appreciated! Many thanks...