diff --git a/src/main/java/org/springframework/data/couchbase/core/CouchbaseOperations.java b/src/main/java/org/springframework/data/couchbase/core/CouchbaseOperations.java index b85b05e89..6fbb66d37 100644 --- a/src/main/java/org/springframework/data/couchbase/core/CouchbaseOperations.java +++ b/src/main/java/org/springframework/data/couchbase/core/CouchbaseOperations.java @@ -54,8 +54,28 @@ public interface CouchbaseOperations extends FluentCouchbaseOperations { */ QueryScanConsistency getConsistency(); + /** + * Save the entity to couchbase.
+ * If there is no version property on the entity class, and this is in a transaction, use insert.
+ * If there is no version property on the entity class, and this is not in a transaction, use upsert.
+ * If there is a version property on the entity class, and it is non-zero, then this is an existing document, use + * replace.
+ * Otherwise, there is a version property for the entity, but it is zero or null, use insert.
+ * + * @param entity the entity to save in couchbase + * @param scopeAndCollection for use by repositories only. these are varargs for the scope and collection. + * @param the entity class + * @return + */ T save(T entity, String... scopeAndCollection); + /** + * Returns the count of documents found by the query. + * @param query + * @param domainType + * @param + * @return + */ Long count(Query query, Class domainType); } diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseOperations.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseOperations.java index 2b2973a08..723626bf0 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseOperations.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseOperations.java @@ -52,9 +52,29 @@ public interface ReactiveCouchbaseOperations extends ReactiveFluentCouchbaseOper */ CouchbaseClientFactory getCouchbaseClientFactory(); + /** + * Save the entity to couchbase.
+ * If there is no version property on the entity class, and this is in a transaction, use insert.
+ * If there is no version property on the entity class, and this is not in a transaction, use upsert.
+ * If there is a version property on the entity class, and it is non-zero, then this is an existing document, use + * replace.
+ * Otherwise, there is a version property for the entity, but it is zero or null, use insert.
+ * + * @param entity the entity to save in couchbase + * @param scopeAndCollection for use by repositories only. these are varargs for the scope and collection. + * @param the entity class + * @return + */ Mono save(T entity, String... scopeAndCollection); - Mono count(Query query, Class personClass); + /** + * Returns the count of documents found by the query. + * @param query + * @param domainType + * @param + * @return + */ + Mono count(Query query, Class domainType); /** * @return the default consistency to use for queries diff --git a/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplate.java b/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplate.java index c86e154e4..18d2951e5 100644 --- a/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplate.java +++ b/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplate.java @@ -72,10 +72,7 @@ public ReactiveCouchbaseTemplate(final CouchbaseClientFactory clientFactory, fin this.scanConsistency = scanConsistency; } - public Mono save(T entity) { - return save(entity, null, null); - } - + @Override public Mono save(T entity, String... scopeAndCollection) { Assert.notNull(entity, "Entity must not be null!"); String scope = scopeAndCollection.length > 0 ? scopeAndCollection[0] : null;