Skip to content

Instantly share code, notes, and snippets.

@laurieboyes
Created September 28, 2017 08:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save laurieboyes/7df68f0cf600411acdbfe2c9840b0a5f to your computer and use it in GitHub Desktop.
Save laurieboyes/7df68f0cf600411acdbfe2c9840b0a5f to your computer and use it in GitHub Desktop.
MATCH (root:TimeTreeRoot)-[:CHILD]->(year:Year)
WITH collect(year) AS years UNWIND years AS y
SET y.uuid = toString(y.value)
WITH y
MATCH (y)-[:CHILD]->(month:Month)
WITH y, collect(month) AS months UNWIND months AS m
SET m.uuid = m.value + '/' + y.value
WITH y, m
MATCH (m)-[:CHILD]->(day:Day)
WITH y, m, collect(day) AS days UNWIND days AS d
SET d.uuid = d.value + '/' + m.value + '/' + y.value
;
@MilesAheadAlso
Copy link

Many thanks for this code. I modified is as below, but I am not sure whether the indexing is more efficient on an integer or on a string. I assumed on an integer.

MATCH (root:TimeTreeRoot)-[:CHILD]->(year:Year)
WITH collect(year) AS years UNWIND years AS y
	SET y.uuid = toInt(y.value)
	WITH y
	MATCH (y)-[:CHILD]->(month:Month)
	WITH y, collect(month) AS months UNWIND months AS m
		SET m.uuid = toInt(y.value*100 + m.value)
		WITH y, m
		MATCH (m)-[:CHILD]->(day:Day)
		WITH y, m, collect(day) AS days UNWIND days AS d
			SET d.uuid = toInt(y.value*10000 + m.value*100 +  d.value)
;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment