RethinkDB更新和替换——不在一行中

RethinkDB update and replace-without in one line

有人能想出一种优雅的方式来在一行中完成 updatereplace 吗?

我想使用 r.row.without 删除字段并在同一个查询中更新。

类似于:

r.db('db').table('table').get('item_id')
          .update({ field_a:'value_a'})
          .replace(r.row.without(r.args(['field_b'])))`

简单的链接会很好,但是这行不通(更新returns一个改变结果)。

r.db('db').table('table').get('item_id')
    .replace(
        r.row.merge(
            function(doc){ 
                return {field_a: 'newval'}
            }
        ).without('field_b')
    )

应该可以做到这一点

您也可以写.update({field_a: 'value_a', field_b: r.literal()})来更改一个字段并同时删除另一个字段。