allow remove with both string id and object.
This commit is contained in:
@@ -127,6 +127,9 @@ public interface CouchbaseOperations {
|
||||
/**
|
||||
* Remove the given object from the bucket by id.
|
||||
*
|
||||
* If the object is a String, it will be treated as the document key
|
||||
* directly.
|
||||
*
|
||||
* @param object the Object to remove.
|
||||
*/
|
||||
void remove(Object object);
|
||||
|
||||
@@ -163,6 +163,16 @@ public class CouchbaseTemplate implements CouchbaseOperations {
|
||||
public void remove(final Object objectToRemove) {
|
||||
ensureNotIterable(objectToRemove);
|
||||
|
||||
if (objectToRemove instanceof String) {
|
||||
execute(new BucketCallback<OperationFuture<Boolean>>() {
|
||||
@Override
|
||||
public OperationFuture<Boolean> doInBucket() {
|
||||
return client.delete((String) objectToRemove);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
final ConvertedCouchbaseDocument converted = new ConvertedCouchbaseDocument();
|
||||
couchbaseConverter.write(objectToRemove, converted);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user