-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow.py
49 lines (31 loc) · 1.14 KB
/
show.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
from mongo_secret import URI
from yuno.client import YunoClient
from yuno.objects import YunoDict
from yuno.database import YunoDatabase
from yuno.collection import YunoCollection
class CustomObject(YunoDict):
hello: str = "world"
do_not_exist: str = "this does not exist" # its default value if not found in db
class CustomDocument(YunoDict):
__lazy__ = ["hello"] # lazy loaded attribute
hello: str
world: str = "heyhey"
a: CustomObject # nested object ^^
class SpecialDocument(YunoDict):
__lazy__ = ["specialAttributes"]
specialAttributes: list[str]
version: str
class CustomCollection(YunoCollection):
__type__ = CustomDocument # the default type of document in the collection
special: SpecialDocument # a special document type
class CustomDatabase(YunoDatabase):
__yuno_test__: CustomCollection
class CustomClient(YunoClient):
test_database: CustomDatabase
test_document = CustomClient(URI).test_database.__yuno_test__.a
print(test_document)
print(test_document.hello)
print(test_document.world)
print(test_document.a)
print(test_document.a.hello)
print(test_document.a.do_not_exist)