I have an employee document (name, designation, ...) and a sub-collection containing all the shifts (documents of the sub-collection) assigned to this employee.
When assigning a new shift, I want to retrieve only the employees that have a particular designation, meaning they are skilled to perform this shift.
Furthermore, I should search within the sub-collection and fetch only the employees that do not have a document for the same date of the shift to assign.
At the moment I only know how to retrieve the employees that have a particular designation.
What I am not able to implement is the part where I only get the skilled employees that are free on the day of the shift to assign.
@override
Stream<List<Employee>> availableEmployeesForGivenDesignation(String designation, DateTime statusDate) {
return _employeeCollection
.where('designation', isEqualTo: designation)
.snapshots()
.map((snapshot) {
//todo search in the sub-collection
...
});
}