MCPcopy
hub / github.com/ormar-orm/ormar / remove

Method remove

ormar/relations/relation.py:183–199  ·  view source on GitHub ↗

Removes child Model from relation, either sets None as related model or removes it from the list in RelationProxy depending on relation type. :param child: model to remove from relation :type child: Model

(self, child: Union["NewBaseModel", type["NewBaseModel"]])

Source from the content-addressed store, hash-verified

181 self._owner.__dict__[relation_name] = proxy
182
183 def remove(self, child: Union["NewBaseModel", type["NewBaseModel"]]) -> None:
184 """
185 Removes child Model from relation, either sets None as related model or removes
186 it from the list in RelationProxy depending on relation type.
187
188 :param child: model to remove from relation
189 :type child: Model
190 """
191 relation_name = self.field_name
192 if self._type == RelationType.PRIMARY:
193 if self.related_models == child:
194 self.related_models = None
195 del self._owner.__dict__[relation_name]
196 else:
197 position = self._find_existing(child)
198 if position is not None:
199 self.related_models.pop(position) # type: ignore
200
201 def get(self) -> Optional[Union[list["Model"], "Model"]]:
202 """

Calls 2

_find_existingMethod · 0.95
popMethod · 0.80