mdocument.model.relations.RelationManyToMany¶
-
class
mdocument.model.relations.RelationManyToMany(parent_field: mdocument.model.field.Field, child_field: mdocument.model.field.Field)¶ Bases:
mdocument.model.relations.RelationMultiple parents multiple children.
Updates list when parent/child updates. Deletes all children when its all parents deleted.
-
__init__(parent_field: mdocument.model.field.Field, child_field: mdocument.model.field.Field)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(parent_field, child_field)Initialize self.
Creates index for relation.
delete(client, document[, session])Deletes children with only one parent.
get_collections(client)Gets parent and child connection.
register(parent_field, child_field)Saves relation to Model relations map.
update(client, document)Updates all childes fields from parent.
Attributes
child_document_clschild_modelparent_document_clsparent_model-
abstract async
create_index()¶ Creates index for relation.
-
async
delete(client: AsyncIOMotorClient, document: MDocument, session=None)¶ Deletes children with only one parent. And removes parent from children.
-
get_collections(client) → Tuple[AsyncIOMotorCollection, AsyncIOMotorCollection]¶ Gets parent and child connection.
-
classmethod
register(parent_field: Union[mdocument.model.field.Field, Type[mdocument.document.MDocument], Type[mdocument.model.model.Model]], child_field: mdocument.model.field.Field)¶ Saves relation to Model relations map.
-
async
update(client, document)¶ Updates all childes fields from parent.
-