Is it possible to do an "upsert" with an increment? So if the query is an insert the counter will initialize with 1 and if it an update it will increment the counter by 1
table.insert({id: 1, counter: 1}, {conflict: function(id, oldVal, newVal) {
return newVal.merge({counter: oldVal('counter').add(1)})
}})
Introduced in v2.3.0 IIUC: https://github.com/rethinkdb/rethinkdb/releases/tag/v2.3.0