statikk 0.1.25__py3-none-any.whl → 0.1.26__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 +15 -1
- statikk/models.py +3 -0
- {statikk-0.1.25.dist-info → statikk-0.1.26.dist-info}/METADATA +1 -1
- {statikk-0.1.25.dist-info → statikk-0.1.26.dist-info}/RECORD +7 -7
- {statikk-0.1.25.dist-info → statikk-0.1.26.dist-info}/WHEEL +0 -0
- {statikk-0.1.25.dist-info → statikk-0.1.26.dist-info}/licenses/LICENSE.txt +0 -0
- {statikk-0.1.25.dist-info → statikk-0.1.26.dist-info}/top_level.txt +0 -0
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.
|
@@ -519,6 +532,7 @@ class Table:
|
|
519
532
|
continue
|
520
533
|
if value is not None:
|
521
534
|
setattr(item, key, value)
|
535
|
+
item.model_rebuild(force=True)
|
522
536
|
return item
|
523
537
|
|
524
538
|
def _serialize_item(self, item: DatabaseModel):
|
@@ -629,7 +643,7 @@ class Table:
|
|
629
643
|
def _perform_batch_write(
|
630
644
|
self, put_items: List[DatabaseModel], delete_items: List[DatabaseModel], delete_keys: list[dict[str, Any]]
|
631
645
|
):
|
632
|
-
if len(put_items) == 0 and len(delete_items) == 0:
|
646
|
+
if len(put_items) == 0 and len(delete_items) == 0 and (len(delete_keys) == 0):
|
633
647
|
return
|
634
648
|
|
635
649
|
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,12 +1,12 @@
|
|
1
1
|
statikk/__init__.py,sha256=pH5i4Fj1tbXLqLtTVIdoojiplZssQn0nnud8-HXodRE,577
|
2
2
|
statikk/conditions.py,sha256=63FYMR-UUaE-ZJEb_8CU721CQTwhajq39-BbokmKeMA,2166
|
3
|
-
statikk/engine.py,sha256=
|
3
|
+
statikk/engine.py,sha256=ZV-Eh-Q2K4H6yFnfFkg7_JEoOrTJ--wIIAZICgX9fpQ,32820
|
4
4
|
statikk/expressions.py,sha256=boAeGxZj2cDsXxoiX3IIEzfX9voSMQngi4-rE_jYeuE,12233
|
5
5
|
statikk/fields.py,sha256=uLGD3xEnz2nqQY6EwG8Dd7pnRMMVP4PU2Z2I-uGNaTA,150
|
6
|
-
statikk/models.py,sha256=
|
6
|
+
statikk/models.py,sha256=0sJYkQt2cFJvyFUheMrFESh4NLojylgtdrUOtsIYhvQ,17732
|
7
7
|
statikk/typing.py,sha256=laOlOpWOm9_sOj4hhdZnGTUZRiq8760_B9I9B3wBhz8,750
|
8
|
-
statikk-0.1.
|
9
|
-
statikk-0.1.
|
10
|
-
statikk-0.1.
|
11
|
-
statikk-0.1.
|
12
|
-
statikk-0.1.
|
8
|
+
statikk-0.1.26.dist-info/licenses/LICENSE.txt,sha256=uSH_2Hpb2Bigy5_HhBliN2fZbBU64G3ERM5zzhKPUEE,1078
|
9
|
+
statikk-0.1.26.dist-info/METADATA,sha256=FYhQwcUSkN3o5mDleEvKJaHkXu5zRiFktyTgQtkV8N4,3183
|
10
|
+
statikk-0.1.26.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
|
11
|
+
statikk-0.1.26.dist-info/top_level.txt,sha256=etKmBbjzIlLpSefXoiOfhWGEgvqUEALaFwCjFDBD9YI,8
|
12
|
+
statikk-0.1.26.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|