Couchbase Java SDK 3.0 Counter

Hi Team,

I have worked on counter during update like shown below.

import static com.couchbase.client.java.kv.MutateInSpec.increment;

 public static void main(String[] args) {
 	List<MutateInSpec> updateSpecs = new ArrayList<>();
	updateSpecs.add(increment("processCnt", 1));
	updateSpecs.add(MutateInSpec.upsert("processCntUpdTm", System.currentTimeMillis()));
	sdkupdate();//code
 }

Above code seem to work fine.

But how to do increment during document creation.

I am using Java -couchbase SDK 3.0 .

Whenever I search for counters , couchbase sdk points to below link Core Operations | Couchbase Docs.

The method bucket.counter() does not exist.

What is the equivalent version of this ?

Thanks in advance

Hi Manzoor,

In SDK 3 the atomic counter methods live in the BinaryCollection class, accessed by calling collection.binary().

Thanks,
David