class levelorm.orm.BaseModel(*args, **kwargs)[source]

Bases: object

base model for DBBaseModel to inherit from. user models should inherit from a class created by levelorm.db_base_model()

db = None
prefix = None
save() → None[source]

writes this instance to the db. members are serialized in the order they are defined on the model and are 4-byte aligned

delete() → None[source]

deletes this instance from the db. no error is raised if the key was not found

classmethod get(key: Union[str, bytes]) → Optional[Model][source]

return an instance of the model by querying db and parsing the result

classmethod parse(key: Union[str, bytes], data: bytes) → Model[source]

used internally by get() and iter() to deserialize values

classmethod iter(**kwargs) → Iterator[Union[Model, str]][source]

proxies to plyvel.DB.iterator but yields (str, BaseModel) pairs instead of (bytes, bytes)