title: Update a field in an array of subdocuments for ALL records
body: <p>When I first created my site I didn't know MongoDB did case sensitive searching, among many other things, and I'm trying to fix the problems.</p>
  
  <p>I've already updated the code to alter the user input before it's saved so it is lowercase AND trimmed of extra spaces.</p>
  
  <p>I can easily update a collection of users from the mongo shell, and then I'm good to go there, but I have another collection that needs updating and it looks like this:</p>
  
  <p>Registration Data Object:</p>
  
  <pre><code>{
  event: string,
  field: string,
  users: [string],
  players: [
    first: string,
    last: string,
    email: string
  ]
  }
  </code></pre>
  
  <p>If it's possible to update the players.email field for ALL registrations by trimming it and making it lowercase from the mongo shell, I'd love to do that.  But I don't think it is, and I've had trouble doing it from mongoose (using Node.js backend, AngularJS frontend).</p>
  
  <p>I was thinking something like this, but I get Type error: Registration.save is not a function:</p>
  
  <pre><code>module.exports.regUpdateAll = function(req, res) {
    console.log('UPDATE ALL REGISTRATIONS');
      Registration.find().exec((err, reg) =&gt; {
        reg.forEach((reg) =&gt; {
          for(var i = 0; i &lt; reg.players.length; i++) { 
            reg.players[i].email = reg.players[i].email.toLowerCase().trim(); 
          }
        });
        console.log(reg);
        Registration.save(reg).then((err, response) =&gt; {
          if(!err) {
            res.status(200).send(response);
          } else {
            console.log(err);
            res.status(500).send(err);
          }
        });
      });     
  };
  </code></pre>
  
  <p>How can I fix this to work?</p>