-
Notifications
You must be signed in to change notification settings - Fork 0
/
cypher_queries.txt
50 lines (40 loc) · 2.42 KB
/
cypher_queries.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# CONSTRAINTS ################################################################################################################
CREATE CONSTRAINT FOR(a:Applicant) REQUIRE a.uuid IS UNIQUE
CREATE CONSTRAINT FOR(j:Job) REQUIRE j.uuid IS UNIQUE
CREATE CONSTRAINT FOR(e:Employer) REQUIRE e.uuid IS UNIQUE
CREATE CONSTRAINT FOR(u:User) REQUIRE u.userName IS UNIQUE
# DATA #######################################################################################################################
CREATE (full_stack_software_developer:Job { uuid: '7df53d53-7c25-4b37-a004-6d9e30d44abe', name: 'Full Stack Software Developer', status: 'OPEN' }),
(john_doe:Applicant { uuid: '6b3e2869-0166-44a6-9371-eab5c09a8ff7', name: 'John Doe'}),
(john_doe)-[:HAS_APPLIED_TO {rejected: false}]->(full_stack_software_developer),
(john_doe)-[:IS_INTERVIEWING_FOR { interviewDate: '2023-04-09T05:53:12.5468730Z' }]->(full_stack_software_developer)
MATCH (full_stack_software_developer:Job { uuid: '7df53d53-7c25-4b37-a004-6d9e30d44abe' })
CREATE (lee_cardholder: Applicant { uuid: 'e2a17b6b-0e40-4eea-94a8-c07d7fe3bb5d', name: 'Lee Cardholder' }),
(lee_cardholder)-[:HAS_APPLIED_TO {rejected: true}]->(full_stack_software_developer)
# password is 123
CREATE (u:User { userName: 'alexis', password: '$2a$11$cD.oCT/QzAgQvza7pDWhI.mjUwpNoNuVMulxyUgXHXZbOJTdji0f6', role: 'applicant' }),
(a:Applicant { uuid: '41cdfb73-0a28-4ccf-85d5-d0c424f6fa08', name: 'Alexis Powers'}),
(u)-[:IS_USER_FOR]->(a)
MATCH (e:Employer {uuid: '0b043999-d2c2-4645-a56d-ddaeb72ee577' }),
(a:Applicant {uuid: '6b3e2869-0166-44a6-9371-eab5c09a8ff7' })
CREATE (e)-[r:INTERVIEWING_WITH]->(a);
MATCH (e:Employer {uuid: '0b043999-d2c2-4645-a56d-ddaeb72ee577' }),
(a:Applicant {uuid: '6b3e2869-0166-44a6-9371-eab5c09a8ff7' })
CREATE (a)-[r:INTERVIEWING_WITH]->(e)
MATCH (a:Applicant)-[:INTERVIEWING_WITH]-(e:Employer)
RETURN a,e
MATCH ()-[r]-() WHERE id(r)=49 DELETE r
# FULL JOB DETAILS BY UUID QUERY #############################################################################################
WITH '7df53d53-7c25-4b37-a004-6d9e30d44abe' AS uuid
MATCH (j:Job)
WHERE j.uuid = uuid
WITH j, COLLECT {
MATCH (a:Applicant)-[r:HAS_APPLIED_TO]->(j:Job)
RETURN a{.*, rejected: r.rejected}
} AS a,
COLLECT {
MATCH (c:Applicant)-[r:HAS_APPLIED_TO]->(j:Job), (c2:Applicant)-[rr:IS_INTERVIEWING_FOR]->(j:Job)
WHERE r.rejected = false
RETURN c{.*, interviewDate: rr.interviewDate}
} AS c
RETURN j{.*, applicants: a, candidates: c}