Search in sources :

Example 6 with UpsertOptions

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();
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) GetOptions(com.couchbase.client.java.kv.GetOptions) UpsertOptions(com.couchbase.client.java.kv.UpsertOptions) Test(org.junit.jupiter.api.Test)

Example 7 with UpsertOptions

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());
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) GetOptions(com.couchbase.client.java.kv.GetOptions) UpsertOptions(com.couchbase.client.java.kv.UpsertOptions) Test(org.junit.jupiter.api.Test)

Example 8 with UpsertOptions

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());
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) GetOptions(com.couchbase.client.java.kv.GetOptions) UpsertOptions(com.couchbase.client.java.kv.UpsertOptions) Test(org.junit.jupiter.api.Test)

Example 9 with UpsertOptions

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);
}
Also used : UpsertOptions(com.couchbase.client.java.kv.UpsertOptions)

Aggregations

UpsertOptions (com.couchbase.client.java.kv.UpsertOptions)9 Test (org.junit.jupiter.api.Test)6 Airport (org.springframework.data.couchbase.domain.Airport)5 GetOptions (com.couchbase.client.java.kv.GetOptions)4 UpsertRequest (com.couchbase.client.core.msg.kv.UpsertRequest)1