plynx.db.db_object

The class defines DBObject. This is an abstraction of all of the objects in database.

Module Contents

plynx.db.db_object.DBObjectType[source]
plynx.db.db_object._registry[source]
plynx.db.db_object.register_class(target_class)[source]

Register inherited from DB Object class

plynx.db.db_object.get_class(name: str) → DBObjectType[source]

Get DB Object inherited class object by its name from the registry

exception plynx.db.db_object.DBObjectNotFound[source]

Bases: Exception

Internal Exception.

exception plynx.db.db_object.ClassNotSavable[source]

Bases: Exception

Internal Exception.

class plynx.db.db_object._DBObject[source]

DB Object. Abstraction of an object in the DB.

DB_COLLECTION =[source]
classmethod load(cls: Type[DBObjectType], _id: ObjectId, collection: Optional[str] = None)[source]

Load object from db.

Args:
_id (ObjectId): ID of the object in DB
save(self, force: bool = False, collection: Optional[str] = None)[source]

Save Object in the database

copy(self: DBObjectType)[source]

Make a copy

Return:
A copy of the Object
classmethod from_dict(cls: Type[DBObjectType], dict_obj: Dict[str, Any])[source]

Create a class based on dict_obj

to_dict(self: DBObjectType)[source]

Create serialized object

__str__(self)[source]
__repr__(self)[source]
class plynx.db.db_object.Meta[source]

Bases: type

Class Registry handle

classmethod __new__(meta, name, bases, class_dict)[source]
class plynx.db.db_object.DBObject[source]

Bases: plynx.db.db_object._DBObject

DB Object. Abstraction of an object in the DB.

Args:
obj_dict (dict, None): Representation of the object. If None, an object with default fields will be created.
__post_init__(self)[source]