Hi,
I’m in-progress of converting SDK 2 code into SDK 3.
How to convert MutationResult into Optional<Map<String,Object>> ?
Cannot resolve method ‘content’ in ‘MutationResult’
@Override
public Map<String, Object> upsertDocument(final String identifier, final int expiry, Map<String, Object> data) {
return Optional.ofNullable(upsertCouchbaseDocument(identifier, expiry, data))
.map(d -> gson.fromJson(d.content(),Map.class))
.orElse(Collections.EMPTY_MAP);
}
private MutationResult upsertCouchbaseDocument(final String identifier, final int expiry, final Map<String, Object> data) {
try{
return couchbaseConfiguration.getBucket().defaultCollection().upsert(identifier,data,UpsertOptions.upsertOptions().expiry(Duration.ofSeconds(expiry)));
} catch (RuntimeException rte) {
throw new DataAccessException(rte.getMessage(), rte.getCause());
}
Thanks.