Add javadoc for save operations.

Closes #1495.
This commit is contained in:
Michael Reiche
2022-07-13 18:13:42 -07:00
parent fab3f55436
commit 4974e0075f
3 changed files with 42 additions and 5 deletions

View File

@@ -54,8 +54,28 @@ public interface CouchbaseOperations extends FluentCouchbaseOperations {
*/
QueryScanConsistency getConsistency();
/**
* Save the entity to couchbase.<br>
* If there is no version property on the entity class, and this is in a transaction, use insert. <br>
* If there is no version property on the entity class, and this is not in a transaction, use upsert. <br>
* If there is a version property on the entity class, and it is non-zero, then this is an existing document, use
* replace.<br>
* Otherwise, there is a version property for the entity, but it is zero or null, use insert. <br>
*
* @param entity the entity to save in couchbase
* @param scopeAndCollection for use by repositories only. these are varargs for the scope and collection.
* @param <T> the entity class
* @return
*/
<T> T save(T entity, String... scopeAndCollection);
/**
* Returns the count of documents found by the query.
* @param query
* @param domainType
* @param <T>
* @return
*/
<T> Long count(Query query, Class<T> domainType);
}

View File

@@ -52,9 +52,29 @@ public interface ReactiveCouchbaseOperations extends ReactiveFluentCouchbaseOper
*/
CouchbaseClientFactory getCouchbaseClientFactory();
/**
* Save the entity to couchbase.<br>
* If there is no version property on the entity class, and this is in a transaction, use insert. <br>
* If there is no version property on the entity class, and this is not in a transaction, use upsert. <br>
* If there is a version property on the entity class, and it is non-zero, then this is an existing document, use
* replace.<br>
* Otherwise, there is a version property for the entity, but it is zero or null, use insert. <br>
*
* @param entity the entity to save in couchbase
* @param scopeAndCollection for use by repositories only. these are varargs for the scope and collection.
* @param <T> the entity class
* @return
*/
<T> Mono<T> save(T entity, String... scopeAndCollection);
<T> Mono<Long> count(Query query, Class<T> personClass);
/**
* Returns the count of documents found by the query.
* @param query
* @param domainType
* @param <T>
* @return
*/
<T> Mono<Long> count(Query query, Class<T> domainType);
/**
* @return the default consistency to use for queries

View File

@@ -72,10 +72,7 @@ public class ReactiveCouchbaseTemplate implements ReactiveCouchbaseOperations, A
this.scanConsistency = scanConsistency;
}
public <T> Mono<T> save(T entity) {
return save(entity, null, null);
}
@Override
public <T> Mono<T> save(T entity, String... scopeAndCollection) {
Assert.notNull(entity, "Entity must not be null!");
String scope = scopeAndCollection.length > 0 ? scopeAndCollection[0] : null;