Domain and Model
Model¶
In Epure, Model class represents table and your decorated by @epure() class from db perspective.
Model of a class can be accessed through the .md
field
Accessing .dom
, .md
fields and .get_model()
method
.dom
, .md
fields and .get_model()
method can be only accessed in method of "epurized" class, decorated by @escript function. Read more about @escript here
You can get ColumnProxy objects by accessing fields of Model
Through ColumnProxy object you then can create all kinds of queries. Read more about examples and methods of ColumnProxy that are used with @escript
decorator here
Getting ColumnProxy field from Model
.get_model()
method¶
.get_model()
is a simple and easy way to get the Model object of class using instance of this class e.g.:
Getting Model object with .get_model()
method
The more convinient way if you have instance of Class
Domain¶
Domain comes from the idea of "DDD" or Domain Driven Design, in Epure, Domain represents object of DataBase and can be accessed through the .dom
field
Accessing .dom
, .md
fields and .get_model()
method
.dom
, .md
fields and .get_model()
method can be only accessed in method of "epurized" class, decorated by @escript function. Read more about @escript here
You can dynamically interact with Domain object by getting Models from it.
Getting Model object from Domain
The more convinient way if you have instance of Class
from epure import escript, epure
@epure
class MyEpureCls:
...
...
@escript
def method_to_get_model(self):
my_epure_cls_model = self.get_model(MyEpureCls) # This will return Model object
...
Or if you know the table name of Model which you want to get