From fb7abe42fde9673e79e6ece465ef1b9be7143ee9 Mon Sep 17 00:00:00 2001 From: Crispen Gari Date: Wed, 31 Jan 2024 14:44:39 +0200 Subject: [PATCH] docs --- README.md | 12 ++++++++++++ todo.txt | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 15c15c8..59bbf33 100644 --- a/README.md +++ b/README.md @@ -348,6 +348,18 @@ With the `delete_by_pk` method you can delete a record in a database based on th affected_rows = db.delete_by_pk(User, userId) ``` +You cal also use `filters` to delete a record in a database. The `delete_one` function allows you to delete a single record in a database that matches a filter. + +```py +affected_rows = db.delete_one(User, {"name": "Crispen"}) +``` + +You can also the `delete_bulk` which delete a lot of records that matches a filter: + +```py +affected_rows = db.delete_bulk(User, {"name": "Crispen"}) +``` + ### Associations With `dataloom` you can define models that have relationships. Let's say we have a model called `Post` and every post should belong to a single `User`. Here is how you can define model mappings between a `Post` and a `User` using the `ForeignKeyColumn()` diff --git a/todo.txt b/todo.txt index 6b24843..118950c 100644 --- a/todo.txt +++ b/todo.txt @@ -2,7 +2,7 @@ 2. inserting data ✅ 3. created at and updated at field ✅ 4. foreign key and primary key ✅ -5. Foreign key Column -6. Delete table +5. Foreign key Column ✅ +6. Delete table data ✅