use of com.couchbase.client.java.kv.UpsertOptions in project spring-data-couchbase by spring-projects.
the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method upsertByIdOther.
@Test
public void upsertByIdOther() {
// 10
UpsertOptions options = UpsertOptions.upsertOptions().timeout(Duration.ofSeconds(10));
GetOptions getOptions = GetOptions.getOptions().timeout(Duration.ofSeconds(10));
Airport saved = template.upsertById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(options).one(vie.withIcao("lowo")).block();
try {
Airport found = template.findById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(getOptions).one(saved.getId()).block();
assertEquals(saved, found);
} finally {
template.removeById().inScope(otherScope).inCollection(otherCollection).one(saved.getId()).block();
}
}
use of com.couchbase.client.java.kv.UpsertOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method upsertById.
@Test
public void upsertById() {
// 10
UpsertOptions options = UpsertOptions.upsertOptions().timeout(Duration.ofSeconds(10));
GetOptions getOptions = GetOptions.getOptions().timeout(Duration.ofSeconds(10));
Airport saved = couchbaseTemplate.upsertById(Airport.class).inScope(scopeName).inCollection(collectionName).withOptions(options).one(vie.withIcao("526"));
try {
Airport found = couchbaseTemplate.findById(Airport.class).inScope(scopeName).inCollection(collectionName).withOptions(getOptions).one(saved.getId());
assertEquals(saved, found);
} finally {
couchbaseTemplate.removeById().inScope(scopeName).inCollection(collectionName).one(saved.getId());
}
}
use of com.couchbase.client.java.kv.UpsertOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method upsertByIdOther.
@Test
public void upsertByIdOther() {
// 10
UpsertOptions options = UpsertOptions.upsertOptions().timeout(Duration.ofSeconds(10));
GetOptions getOptions = GetOptions.getOptions().timeout(Duration.ofSeconds(10));
Airport saved = couchbaseTemplate.upsertById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(options).one(vie.withIcao("679"));
try {
Airport found = couchbaseTemplate.findById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(getOptions).one(saved.getId());
assertEquals(saved, found);
} finally {
couchbaseTemplate.removeById().inScope(otherScope).inCollection(otherCollection).one(saved.getId());
}
}
use of com.couchbase.client.java.kv.UpsertOptions in project spring-data-couchbase by spring-projects.
the class DefaultCouchbaseCacheWriter method put.
@Override
public void put(final String collectionName, final String key, final Object value, final Duration expiry, final Transcoder transcoder) {
UpsertOptions options = upsertOptions();
if (expiry != null) {
options.expiry(expiry);
}
if (transcoder != null) {
options.transcoder(transcoder);
}
getCollection(collectionName).upsert(key, value, options);
}
Aggregations