statikk 0.1.25__py3-none-any.whl → 0.1.27__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
statikk/engine.py CHANGED
@@ -209,6 +209,19 @@ class Table:
209
209
  data[key] = self._deserialize_value(value, model_class.model_fields[key])
210
210
  return model_class(**data)
211
211
 
212
+ def delete_hierarchy(self, model: DatabaseModel):
213
+ """
214
+ Deletes an item and all its children from the database by id, using the partition key of the table.
215
+ :param id: The id of the item to delete.
216
+ """
217
+ with self.batch_write() as batch:
218
+ for key in model._db_snapshot_keys | self._create_snapshot_representation(model):
219
+ hash_key, sort_key = key.split("#", 1)
220
+ delete_params = {self.key_schema.hash_key: hash_key}
221
+ if sort_key:
222
+ delete_params[self.key_schema.sort_key] = sort_key
223
+ batch.delete_by_key(delete_params)
224
+
212
225
  def delete_item(self, model: DatabaseModel):
213
226
  """
214
227
  Deletes an item from the database by id, using the partition key of the table.
@@ -629,7 +642,7 @@ class Table:
629
642
  def _perform_batch_write(
630
643
  self, put_items: List[DatabaseModel], delete_items: List[DatabaseModel], delete_keys: list[dict[str, Any]]
631
644
  ):
632
- if len(put_items) == 0 and len(delete_items) == 0:
645
+ if len(put_items) == 0 and len(delete_items) == 0 and (len(delete_keys) == 0):
633
646
  return
634
647
 
635
648
  dynamodb_table = self._get_dynamodb_table()
statikk/models.py CHANGED
@@ -256,6 +256,9 @@ class DatabaseModel(BaseModel, TrackingMixin):
256
256
  def delete(self):
257
257
  return self._table.delete_item(self)
258
258
 
259
+ def delete_hierarchy(self):
260
+ return self._table.delete_hierarchy(self)
261
+
259
262
  def update(self, sort_key: Optional[str] = None) -> DatabaseModelUpdateExpressionBuilder:
260
263
  return DatabaseModelUpdateExpressionBuilder(self, sort_key)
261
264
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: statikk
3
- Version: 0.1.25
3
+ Version: 0.1.27
4
4
  Summary: statikk is a single table application (STA) library for DynamoDb.
5
5
  Home-page: https://github.com/terinia/statikk
6
6
  Author: Balint Biro
@@ -0,0 +1,12 @@
1
+ statikk/__init__.py,sha256=pH5i4Fj1tbXLqLtTVIdoojiplZssQn0nnud8-HXodRE,577
2
+ statikk/conditions.py,sha256=63FYMR-UUaE-ZJEb_8CU721CQTwhajq39-BbokmKeMA,2166
3
+ statikk/engine.py,sha256=LBESyF2emdlDjcEnhPQeK-MJoO2si8TXacrJWuiKfYw,32781
4
+ statikk/expressions.py,sha256=boAeGxZj2cDsXxoiX3IIEzfX9voSMQngi4-rE_jYeuE,12233
5
+ statikk/fields.py,sha256=uLGD3xEnz2nqQY6EwG8Dd7pnRMMVP4PU2Z2I-uGNaTA,150
6
+ statikk/models.py,sha256=0sJYkQt2cFJvyFUheMrFESh4NLojylgtdrUOtsIYhvQ,17732
7
+ statikk/typing.py,sha256=laOlOpWOm9_sOj4hhdZnGTUZRiq8760_B9I9B3wBhz8,750
8
+ statikk-0.1.27.dist-info/licenses/LICENSE.txt,sha256=uSH_2Hpb2Bigy5_HhBliN2fZbBU64G3ERM5zzhKPUEE,1078
9
+ statikk-0.1.27.dist-info/METADATA,sha256=hZGMcXG4kE4_EL6mpgmbs5ZenceV_emW6qNLltAH7ag,3183
10
+ statikk-0.1.27.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
11
+ statikk-0.1.27.dist-info/top_level.txt,sha256=etKmBbjzIlLpSefXoiOfhWGEgvqUEALaFwCjFDBD9YI,8
12
+ statikk-0.1.27.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.0.2)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,12 +0,0 @@
1
- statikk/__init__.py,sha256=pH5i4Fj1tbXLqLtTVIdoojiplZssQn0nnud8-HXodRE,577
2
- statikk/conditions.py,sha256=63FYMR-UUaE-ZJEb_8CU721CQTwhajq39-BbokmKeMA,2166
3
- statikk/engine.py,sha256=zcoSR_exARya7_taiKd94lc0H8rQbNpdcOrKQmCrMKs,32106
4
- statikk/expressions.py,sha256=boAeGxZj2cDsXxoiX3IIEzfX9voSMQngi4-rE_jYeuE,12233
5
- statikk/fields.py,sha256=uLGD3xEnz2nqQY6EwG8Dd7pnRMMVP4PU2Z2I-uGNaTA,150
6
- statikk/models.py,sha256=zZgvv-z-G-XKl23028Lx403jAUaEq8AtyYb3oQc6blc,17649
7
- statikk/typing.py,sha256=laOlOpWOm9_sOj4hhdZnGTUZRiq8760_B9I9B3wBhz8,750
8
- statikk-0.1.25.dist-info/licenses/LICENSE.txt,sha256=uSH_2Hpb2Bigy5_HhBliN2fZbBU64G3ERM5zzhKPUEE,1078
9
- statikk-0.1.25.dist-info/METADATA,sha256=xndOSnhTTgn1na2xvANN0Ckpi9pRx0bszNgyiZMbZzU,3183
10
- statikk-0.1.25.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
11
- statikk-0.1.25.dist-info/top_level.txt,sha256=etKmBbjzIlLpSefXoiOfhWGEgvqUEALaFwCjFDBD9YI,8
12
- statikk-0.1.25.dist-info/RECORD,,