Add an option to exlcude basic models from mappings #13
-
Environment
I have several models, and they have common fields.
It throws the following error.
The error doesn't affect to other indices, but I think still need an option to ignore some models from mappings.
|
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
The ESBaseModel is exactly for this. |
Beta Was this translation helpful? Give feedback.
-
Oh, I misunderstood your question... import esorm
class BaseModel(esorm.ESBaseModel):
...
class Model(BaseModel, esorm.ESModel):
... I'm not sure if it works atm. but if not I will make it work this way. |
Beta Was this translation helpful? Give feedback.
-
Yes, we can use two base models.
|
Beta Was this translation helpful? Give feedback.
-
Ok, I've tested it, this works, and it is more pythonic way. You have one base model, but two parents: class BaseModelParent(esorm.ESBaseModel):
class ESConfig:
id_field = 'f_str'
f_str: str
f_int: int
class BaseModelParentModel(BaseModelParent, esorm.ESModel):
f_float: float
|
Beta Was this translation helpful? Give feedback.
-
@wallneradam
It throws the following error.
I'm just giving an example. ** Note ** |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@wallneradam https://github.com/wallneradam/esorm/blob/main/esorm/model.py#L237-L244 |
Beta Was this translation helpful? Give feedback.
Ok, I've tested it, this works, and it is more pythonic way. You have one base model, but two parents:
ESBaseModel
classes won't be incuded in mappings. So you can use them as a base structure for multiple models. AlsoESConfig
settings are inherited from the base model. I think this is what yout want.