forked from graphql-python/graphene-mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
38 lines (26 loc) · 825 Bytes
/
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
from datetime import datetime
from mongoengine import Document, EmbeddedDocument
from mongoengine.fields import (
DateTimeField,
EmbeddedDocumentField,
ListField,
ReferenceField,
StringField,
)
class Department(Document):
meta = {"collection": "department"}
name = StringField()
class Role(Document):
meta = {"collection": "role"}
name = StringField()
class Task(EmbeddedDocument):
name = StringField()
deadline = DateTimeField(default=datetime.now)
class Employee(Document):
meta = {"collection": "employee"}
name = StringField()
hired_on = DateTimeField(default=datetime.now)
department = ReferenceField(Department)
roles = ListField(ReferenceField(Role))
leader = ReferenceField("Employee")
tasks = ListField(EmbeddedDocumentField(Task))