There are two collections:
Trains = new Mongo.Collection('trains'); Passengers = new Mongo.Collection('passengers'); One contains data about trains, the other - data about passengers. In each document of the train there is a field numberOfPassengers . Each passenger has a train field. I need the numberOfPassengers each train to store the current number of passengers, with a specific train field. In other words:
Trains.find({name: 'redTrain'}).numberOfPassengers = Passengers.find({train: 'redTrain').count(); How is it possible to link these two collections in this way? So that the document of one collection can dynamically store the number of elements from another collection.