We have a bunch of files and we want only users belonging to a certain department to have access to a specific set of files. We want to create a system that would upon swiping the card allows access to files.
I don't want to have multiple relations from each user to each file, but I'd rather have it compartmentalized.
What would Cypher query for this look like?
With the following command, you can now check the access rights of a person or department with a graph database.
The MATCH clause tries to find a pattern where the Person node with the usernaname “jsmith” and the File node with the name “apendix.pdf” are connected within 2 hops with relationships of type BELONGS_TO or HAS_ACCESS_TO.
In summary, the query checks if Mark BELONGS_TO a certain team which HAS_ACCESS_TO a file or whether there is a direct relationship between Person and File with HAS_ACCESS_TO type.
MATCH path=(p:Person {usernamename:"jsmith"})-[:BELONGS_TO|:HAS_ACCESS_TO *..2
]->(f:File {name:"apendix.pdf"})
RETURN *;