In order to handle the insertion functionality in Couchbase SDK 3, I believe can be handled as mentioned below.
public void insert(String id, String jsonString, Collection collection) {
MutationResult upsertResult =null;
JsonObject content = JsonObject.fromJson(jsonString);
try{
//Insert Document
upsertResult = collection.upsert(id, content);
}Catch (CasMismatchException e){
//To Do: the caller is expected to re-do the whole "fetch-modify-update" cycle again
}
//Retrieve the documentGetResult getResult = collection.get(id).contentAsObject();
}
But how can I return a document format similar to JsonDocument or an alternative format in CB SDK 3? The current project which was developed using CB SDK 2 uses the JsonDocument format extensively. How to handle this change without breaking the current code after the migration to Couchbase SDK 3?
DoesJsonTranscoder
offer an alternative to the above scenario. If so could you please indicate how it could be used in the above simple scenario?