Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-09-2022 06:36 AM
I would like a node to be unique based on two constraints:
1. A property set by me
2. The index as set by neo4j at the creation of the node
This is what I've tried so far:
CREATE CONSTRAINT transaction_constraint IF NOT EXISTS
FOR (tx: Transaction)
REQUIRE(tx.`Transaction Hash`, id(tx)) IS UNIQUE
but this is the error I get:
py2neo.errors.ClientError: [Statement.SyntaxError] Invalid input '(': expected "." (line 4, column 70 (offset: 221))
"REQUIRE(tx.`Transaction Hash`, id(tx)) IS UNIQUE"
^
I would like to avoid having an extra id that I manually increment to keep things neat if possible.
Solved! Go to Solution.
12-09-2022 08:30 AM
You can't index the internal node id. Anyways the id() of a node is always present and unique across nodes, so what you are trying to do will always be unique regardless of 'Transaction Hash'. You can use the id() as an identifier if you want. Keep in mind that the values are reused.
12-09-2022 08:30 AM
You can't index the internal node id. Anyways the id() of a node is always present and unique across nodes, so what you are trying to do will always be unique regardless of 'Transaction Hash'. You can use the id() as an identifier if you want. Keep in mind that the values are reused.
12-10-2022 07:35 AM
@glilienfield Thank you for the answer! I was trying to find a way to distinguish coinbase transactions as they all have the same hash. Ultimately, block hash along with transaction hash were used as constraints.
All the sessions of the conference are now available online