Skip to content

Add javadoc for save operations. #1508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ public ReactiveCouchbaseTemplate(final CouchbaseClientFactory clientFactory, fin
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;
Expand Down