title: Update Mongoose document fails TypeError: Cannot read property 'coordinates' of undefined
body: <p>Not sure if I'm at all doing this the write way, it's the first attempt at writing a document update REST api call.</p>
  
  <p>I want the api call to supply just the fields of the document they want to update, so I was going to check if each field had data and then add it, or ignore if not to avoid fields being nulled.</p>
  
  <p>As you can see I've tried both to check if the field was not undefined, or the field exists, they both lead to the same server error.</p>
  
  <pre><code>app.put('/api/objects/update/:_id', function(req, res)
  {
      var id = req.params._id
      var object;
  
      if (typeof req.body.geometry.coordinates !== undefined) { object.geometry.coordinates = req.body.geometry.coordinates; }
      if (req.body.properties.name) { object.properties.name = req.body.properties.name; }
  
  
      Object.updateObject(id, object, {}, function(err, object)
      {
          if (err)
          {
              res.json(err);
              console.log("Object Not Found: " + id);
          }
  
          res.json(object);
          console.log("Updated Object: " + id);
      });
  });
  </code></pre>
  
  <p>This is the contents of the req.body that's being submitted:</p>
  
  <pre><code>{
    "properties":
    {
      "name": "Ted"
    }
  }
  </code></pre>
  
  <p>Server Error calls out the first if statement and fails.</p>
  
  <pre><code>TypeError: Cannot read property 'coordinates' of undefined
      at /opt/bitnami/apps/API/app.js:221:31
  </code></pre>
  
  <p>First question is can I check for an undefined property to skip it?
  Should I be doing it this way at all? If anyone has examples of a better way, I'm all ears.</p>