Increment a field inside a document


#1

Hi.
Is there a way to send an increment command to a field inside a document without fetching the document previously?
I saw the increment command which only refer to the key and the increment.
I wish for a similar method that accepts key, field name, and increment.

Example:
bucket sales
{
key : 1,
“salesman_name” : “George”,
“team”:1
"sales":2
},
{
key : 2,
“salesman_name” : “John”,
“team”:6
"sales":10
}

Command:
increment(key=2,field=sales,increment=1)


#2

@gluz

Hi, no the increment command cannot be used on JSON at all. If you use incr/decr or the newer “counter” variants, the document solely consists of the number in it, no JSON allowed.
If you want to do that, you need to use get & cas operations to properly make that happen concurrently.


#3

Thanks @daschl.
Hope you guys will change that in the future.


#4

Yes, we are investigating many ways how we can make that happen, of course they all have tradeoffs.