-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
56 lines (35 loc) · 1.31 KB
/
models.py
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
51
52
53
54
55
56
from arango_orm.fields import String, Integer, Boolean, DateTime
from arango_orm import Collection, Relation, Graph, GraphConnection
class Student(Collection):
__collection__ = 'students'
_key = String(required=True) # registration number
name = String(required=True, allow_none=False)
age = Integer()
class Teacher(Collection):
__collection__ = 'teachers'
_key = String(required=True) # employee id
name = String(required=True)
class Subject(Collection):
__collection__ = 'subjects'
_key = String(required=True) # subject code
name = String(required=True)
class Area(Collection):
__collection__ = 'areas'
_key = String(required=True) # area name
class Log(Collection):
__collection__ = 'logs'
_key = String(required=True)
timestamp = DateTime()
message = String()
class UniversityGraph(Graph):
__graph__ = 'university_graph'
graph_connections = [
# Using general Relation class for relationship
GraphConnection(Student, Relation("studies"), Subject),
GraphConnection(Teacher, Relation("teaches"), Subject),
# Using specific classes for vertex and edges
GraphConnection([Teacher, Student], Relation("resides_in"), Area)
]
all_db_objects = [
Student, Teacher, Subject, Area, UniversityGraph, Log
]