SpringData how to get resultCount of a delete/update query

is there a why to get ‘resultCount’ of an update/delete query?
I’m looking for some hint like #{#n1ql.returning} but for resultCount

Hi OranB -

There isn’t a mechanism for returning the number of mutations from the response metadata, but you can have your upsert/delete return something for each upsert/delete, and then count them.

@Query(“update #{#n1ql.bucket} set name=$newName where name = $oldName returning 1”)
List<Integer> myUpsert(String oldName, String newName);|

int l = airportRepository.myUpsert("oldName", "newName").size(); <-- take .size()

Instead of “returning 1”, you could also use #{#n1ql.returning}, which will return the whole entity

@Query(“update #{#n1ql.bucket} set name=$newName where name = $oldName #{#n1ql.returning}” )
List<Airport> myUpsert(String oldName, String newName);|

ps. I did try: “SELECT COUNT(*) from (UPDATE ... returning 1) s” but the subquery can only be a SELECT.

@mreiche is mutationCount is not option?

"metrics": {
        "elapsedTime": "5.648016559s",
        "executionTime": "5.647957729s",
        "resultCount": 0,
        "resultSize": 0,
        "serviceLoad": 2,
        "mutationCount": 15994


UPDATE … returning RAW 1;
do length of result slice

spring data couchbase doesn’t expose the result metadata.

RAW won’t work as spring data couchbase expects json.