title: Insert/Update record using mongoose
body: <p>I am trying to insert a record into mongodb, using mongoose, but the record does not update when record is already in the database. Is there something I am doing wrong? The documentation for mongoose is not the easiest to follow for me.</p>
  
  <pre><code>models.fg_records.update({email:clean_email}, inactive_user, {update: true}, function (err) {
      if(err){
          throw err;
          console.log(err);
      } else {
  
          // send mail with defined transport object
          transport.sendMail(message, function(err, response) {
              if(err) {
                  console.log(err);
                  view('&lt;ul&gt;&lt;li&gt;There was a problem sending an email to this user. Make sure you types it correctly.&lt;/li&gt;&lt;/ul&gt;');
              } else {
                  res.redirect('/records');
              }
          });
  
      }
  });
  </code></pre>