RethinkDB 中的更新和增量

Upsert & increment in RethinkDB

是否可以做一个 "upsert" 增量? 因此,如果查询是插入,则计数器将 initialize with 1 如果是更新,它将 increment 计数器 1

table.insert({id: 1, counter: 1}, {conflict: function(id, oldVal, newVal) {
  return newVal.merge({counter: oldVal('counter').add(1)})
}})

在 v2.3.0 IIUC 中引入: https://github.com/rethinkdb/rethinkdb/releases/tag/v2.3.0