javascript - insert a new document from querying combined collection -


i new nosql world , meteor, have 2 collections, taskcollectioin , workerscollection , goal match each task available timeslot in workerscollection. tasks collection has fields {client,task-name,time-flag,assigned=false} , workers collection has field {name, timeslot:[slot, available]}. have created result collection called matchcollection result need insert document resulting in matching of each task available worker.

my question: since dealing querying 2 different collection , comparing field matching, how implement function in meteor solves following psuedo code algorithm?

'for each task taskcollection    | if (assigned == false)    |  |  task flag(for example: 10-12 pm)         | endif       |  each worker collection    |  |  **get worker slots    |  |    if (worker timeslot availible given task time-flag)    |  |    |   1-assign task worker    |  |    |   2-set task assigned true    |  |    |   3-set timeslot.available false    |  |    |   4-create document in matchcollection    |  |    end if     |  endfor         endfor' 

you achieve using aggregation... here have study part.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -