title: Relationship between collections in mongodb
body: <p><strong>How can we do relational update queries in mongodb.</strong></p>
  <p>We have the following scenario:</p>
  <blockquote>
  <p>In a bank the deposits of the clients are managed, once a certain
  period of time is fulfilled the bank returns the deposit to the
  clients plus the accrued interest, a client can have several deposits.
  we create the client's collection, with his name, and what he has
  available to withdraw, we create the deposit collection, with the
  amount, the interest rate, and we join it to the client's model by the
  client's id from a clientId field. Every 24 hours the bank updates all
  user accounts, if the deposit creation date is less than two years,
  the user's interest is updated, if the date is equal to 2 years a new
  field is added to the deposit (expired: true), and to the client's
  collection in the available field is added, what was already
  accumulated, the interest, plus the amount of the deposit. To give a
  solution I have tried to obtain all the deposits, I save them in an
  object and I go through it with the map property. Inside the map I try
  to update the clients that have expired deposits, however, only the
  last element that runs through the map is being updated.</p>
  </blockquote>
  <p>What would be the best solution to this problem. I clarify that I am using mongoose and nodejs.</p>