Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Do you think something like the following should work with RethinkDB?

  r.table('foo')
   .get(5)
   .update({
     '_rev': r.branch(r['_rev'] == 5,
       r('_rev').add(1),
       r.error("invalid revision")
     ),
     'name': "awesome name"
   })
the basic idea is that `name` should be update to "awesome name" and `_rev` should be incremented by 1, but only if `_rev` is 5, otherwise an "invalid revision" error should be thrown.


That would work. I didn't realize you can raise error on the row. Good work!


Yes, this will work.


awesome, thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: