Reputation: 1096
I am new to Nosql world and meteor, I have two collections, taskCollectioin and workersCollection and my goal is to match each task to the available timeslot in workersCollection. my tasks collection has fields {client,task-name,time-flag,assigned=false} and my workers collection has field {name, timeslot:[slot, available]}. I have created also result collection called matchCollection result that need to insert a document resulting in matching of each task to available worker.
My question: Since we are dealing with querying from two different collection and comparing their field for matching, how would you implement a function in meteor that solves following psuedo code algorithm?
'FOR each task FROM TaskCollection
| IF (assigned == false)
| | get the task flag(for example: 10-12 pm)
| ENDIF
| FOR each worker From collection
| | **get worker slots
| | IF (worker timeslot is availible for a given task time-flag)
| | | 1-assign the task to the worker
| | | 2-set the task assigned to true
| | | 3-set the timeslot.available to false
| | | 4-create a document in MatchCollection
| | END IF
| ENDFOR
ENDFOR'
Upvotes: 1
Views: 33
Reputation: 9753
You will achieve this using aggregation... here You have to study this part.
Upvotes: 1