How to append to array only if it doesn't contain value with rethinkDB
<p>I'd like to append a value to an array in a record that looks similar to the following: </p>

<pre><code>{
  _id: 'foo',
  cols: [
    'abc123',
    '123abc'
  ]
}
</code></pre>

<p>It's possible that this field doesn't exist and will need to be created prior to appending. I also don't want to append to the array if the value already exists in the array. So far I have the following which satisfies all but the last requirement of not adding duplicate entries. </p>

<pre><code>r.table('users')
 .get(userId)
 .update({
   cols: r.row('cols').default([]).append(uuid)
 }) 
</code></pre>

<p>Any help appreciated, thanks!</p>