title: How can I upsert using Mongoose based on _id?
body: <p>When I do this:</p>
  
  <pre><code>client_id = req.param("client_id") ? null
  client =
    name: req.param "clientName"
    status: 'active'
  
  Client.update {_id: client_id}, client, {upsert: true}, (err, updRes) -&gt;
    if err
      res.json
        error: "Couldn't create client"
    else
      res.json client
  </code></pre>
  
  <p>It will create a new client record, except with a <code>null</code> <code>_id</code> field. I assume that's because the insert part of the upsert looks to the <code>query</code> to create the document. How can I do it so that if no doc is found, then insert a new <code>ObjectId</code>?</p>