title: Conditional Delete in RethinkDB
body: <p>I would like to delete an object in RethinkDB but only if a condition is met.</p>
  
  <p>I came up with the following function that utilizes replace and null (RethinkDB deletes objects when null is passed in to <code>replace()</code>). However, I cannot get this to work as RethinkDB keeps returning <code>Cannot perform bracket on a non-object non-sequence</code>null<code>.</code> I am only trying to replace one object. What is wrong?</p>
  
  <pre><code>r.db('test')
    .table('test')
    .get('123')
    .replace(function(thing) {
      return r.branch(thing('color').ne('green'),
        r.error('Object color must be green to be deleted'),
        null)
    }, { returnChanges: true })
  </code></pre>