cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to count actual affected nodes for updating operations?

lingvisa
Graph Fellow
MATCH (m:Product)
REMOVE m.price
RETURN count(m) as count

Even if my Product nodes don't have the property 'price', it still returns the total number of product nodes. How can I return the count of nodes that have been affected by the REMOVE command? For example, if Product nodes don't have any 'price' property', it should return 0; if 100 product nodes have 'price' property while other product nodes don't have this property, it should return 350.

How to modify this query?

1 ACCEPTED SOLUTION

accounts
Node Clone

How about adding a where clause? something like

MATCH (m:Product)
WHERE EXISTS(m.price)
REMOVE m.price
....

however if you're using one of the drivers you can look at the query statistics to see counters.propertiesSet ( in the browser you can find it if you click the Code tab in the results pane )

View solution in original post

1 REPLY 1

accounts
Node Clone

How about adding a where clause? something like

MATCH (m:Product)
WHERE EXISTS(m.price)
REMOVE m.price
....

however if you're using one of the drivers you can look at the query statistics to see counters.propertiesSet ( in the browser you can find it if you click the Code tab in the results pane )

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online