php editor Xigua brings the latest java Q&A: How does Spring Data Neo4j return the count of affected nodes after an update operation? Spring Data Neo4j is a powerful graph database framework that provides rich functions and flexible API. When performing an update operation, sometimes it is necessary to obtain the number of affected nodes after the update for subsequent processing. This article will introduce how to use Spring Data Neo4j to implement this function and help developers make better use of the features of graph databases.
After performing an update operation using the spring data neo4j repository, is there any way to return the number of affected nodes?
For example
@Query("MATCH (n:Student) WHERE n.id IN $idList SET n.isRegistered = true") Integer updateRegisterInfo(@Param("idList") List idList);
But sdn can only return void/null values for such operations.
Thank you
If you want the number of nodes to whichsetis applied, return the number of rows:
match (n:student) where n.id in $idlist set n.isregistered = true return count(*) as numaffected
If you want a count of nodes withisregisteredvalues that have changed, use thewhereclause to delete nodes that already haveisregistered = true:
MATCH (n:Student) WHERE n.id IN $idList AND NOT coalesce(n.isRegistered, false) SET n.isRegistered = true RETURN count(*) AS numAffected
(I just formatted this as a standalone cypher to make it easier to read.)
The above is the detailed content of Spring Data Neo4j returns count of affected nodes after update operation. For more information, please follow other related articles on the PHP Chinese website!
Reasons why Windows printer does not print
What is an .Xauthority file?
How to open gff file
How to buy and sell Bitcoin on Ouyi platform
Reasons for session failure
What does the rm-rf command mean in linux?
How to open mdf file
The computer has Internet access but the browser cannot open the web page