Details
-
Improvement
-
Resolution: Fixed
-
Minor
-
None
-
None
Description
Use case is to effectively set a counter to a given value, even though it already exists. It seems the canonical, modern way to do this is as follows:
bucket.remove("countme"); |
bucket.counter("countme", 1, 0); // init at 0, incr by 1 if exists |
System.out.println(bucket.counter("countme", 1).content()); // prints 1 |
JsonLongDocument overrider = JsonLongDocument.create("countme", new Long(99)); |
bucket.upsert(overrider);
|
System.out.println("after increment: " + bucket.counter("countme", 1).content()); // prints 100 |
But the API reference discussion of counters doesn't currently make that clear.
Attachments
Issue Links
- relates to
-
DOC-3068 need a discussion on how counters are represented
-
- Resolved
-