how to ensure atomicity in neo4j cypher writes:

I have never used the transaction lock features in neo4j cypher before so I not sure how to do this. I have a series of writes that I need all to complete or none complete:

CREATE (e:Elections) SET e +=$electionObj,

                            WITH e, $nominate_authorizers AS na
                            UNWIND na AS n_auth 
                            MATCH (nm:Member {member_id: n_auth.member_id})
                            CREATE (nm)-[nr:NOMINATE_AUTHORIZER]->(e)

                            WITH e, nm, $certify_authorizers AS ca
                            UNWIND ca AS c_auth 
                            MATCH (cm:Member {member_id: c_auth.member_id})
                            CREATE (cm)-[cr:CERTIFY_AUTHORIZER]->(e)

                            WITH e, nm,cm, $tally_authorizers AS ta
                            UNWIND ta AS t_auth 
                            MATCH (tm:Member {member_id: t_auth.member_id})
                            CREATE (tm)-[tr:TALLY_AUTHORIZER]->(e)

                            WITH e, nm,cm, tm, $audit_authorizers AS aa
                            UNWIND aa AS a_auth 
                            MATCH (am:Member {member_id: a_auth.member_id})
                            CREATE (am)-[ar:AUDIT_AUTHORIZER]->(e)

                            WITH e, nm,cm, tm, am, $races AS races
                            UNWIND races AS race 
                            CREATE (r:Race) 
                            SET race, 
                            CREATE (r)-[rr:OF_ELECTION]->(e) 
                            RETURN {election: e}

The problem is ...if there's an error that causes one of these MATCH's to return 0 row the query moves right along and creates the nodes it found. What is the most efficient of achieving atomicity here. I have looked at the apoc library but not sure about it....any suggestion would be appreciated.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum