Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Initial products
CREATE (dress1 { name: "Halter Dress", colour: "Blue"})-[:BRAND]-(frenchConnection { name: "French Connection" })
CREATE (dress2 { name: "Another Dress", colour: "Yellow"})-[:BRAND]-(frenchConnection)
CREATE (dress3 { name: "Different Dress", colour: "Blue"})-[:BRAND]-(frenchConnection)
RETURN dress1, dress2, dress3
// Query to find the blue French Connection products
START brand = node:node_auto_index(name="French Connection")
MATCH brand<-[:BRAND]-product
WHERE product.colour = "Blue"
RETURN brand, product
// Create a node for the colour 'Blue'
CREATE (blue { name: "Blue"})
// Make all the blue French Connection products point to the blue node
START brand = node:node_auto_index(name="French Connection"), blue = node:node_auto_index(name="Blue")
MATCH brand<-[:BRAND]-product
WHERE product.colour = "Blue"
CREATE UNIQUE product-[:COLOUR]->blue
RETURN brand, product
// Create a node for the colour 'Yellow'
CREATE (yellow { name: "Yellow"})
// Make all the yellow French Connection products point to the blue node
START brand = node:node_auto_index(name="French Connection") , yellow = node:node_auto_index(name="Yellow")
MATCH brand<-[:BRAND]-product
WHERE product.colour = "Yellow"
CREATE product-[:COLOUR]->yellow
RETURN brand, product
// Query for all the blue French Connection products
START brand = node:node_auto_index(name="French Connection"), blue = node:node_auto_index(name="Blue")
MATCH brand<-[:BRAND]-product-[:COLOUR]->blue
RETURN brand, product
// Add an on sale property to all French connection blue products
START brand = node:node_auto_index(name="French Connection"),
blue = node:node_auto_index(name="Blue")
MATCH brand<-[:BRAND]-product-[:COLOUR]->blue
SET product.state = "OnSale"
RETURN brand, product
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.