Created
May 3, 2018 15:55
-
-
Save atomicsamurai/a37c0430a428703e6daf1c5160cb0782 to your computer and use it in GitHub Desktop.
Cypher for querying driver's access to trunk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MATCH (driver:User {name: 'Cathy'}) | |
| WITH driver | |
| // find the trunk from the drive and the package | |
| // the package and the location are the key to open the trunk | |
| OPTIONAL MATCH driver_item_path=(driver)-[:DRIVES|INCLUDES*]-(item:Item {name: 'Item'})-[:DELIVER_TO]->(trunk:Door) | |
| WITH driver_item_path,trunk | |
| OPTIONAL MATCH item_work_path=(trunk)<-[:INCLUDES*..5]-(intermediate:Collection)-[:INCLUDES*..5]->(:Location {name: 'Work'}) | |
| USING JOIN ON intermediate | |
| RETURN CASE | |
| WHEN driver_item_path IS NULL THEN { result: false, advice: "Driver not authorized on package."} | |
| WHEN item_work_path IS NOT NULL THEN { result: true, advice: "Driver authorized on package at current location."} | |
| WHEN item_work_path IS NULL THEN { result: false, advice: "Driver not authorized on package at current location."} | |
| ELSE false | |
| END AS result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment