diff --git a/README.md b/README.md index 14141ba..b09e4c4 100644 --- a/README.md +++ b/README.md @@ -125,8 +125,8 @@ for user in results: print(f"User: {user.name}, Age: {user.age}") # Update a record -user.age = 31 -db.update(User,user) +new_user.age = 31 +db.update(new_user) # Delete a record db.delete(User, new_user.pk) diff --git a/docs/guide/data-ops.md b/docs/guide/data-ops.md index a739f72..f513447 100644 --- a/docs/guide/data-ops.md +++ b/docs/guide/data-ops.md @@ -56,12 +56,12 @@ See [Filtering Results](filtering.md) for more advanced filtering options. ## Updating Records You can update records in the database by modifying the fields of the model -instance and then calling the `update()` method. You need to pass the model -class and the instance to the method: +instance and then calling the `update()` method. You just pass the model +instance to the method: ```python user.age = 26 -db.update(User, user) +db.update(user) ``` ## Deleting Records diff --git a/docs/guide/guide.md b/docs/guide/guide.md index 1a69ac7..be1dde5 100644 --- a/docs/guide/guide.md +++ b/docs/guide/guide.md @@ -113,12 +113,11 @@ returned. ## Updating Records Records can be updated seamlessly. Simply modify the fields of the model -instance and call the `update()` method, passing the model class and the updated -instance: +instance and pass that to the `update()` method: ```python user.age = 31 -db.update(User, user) +db.update(user) ``` ## Deleting Records diff --git a/docs/quickstart.md b/docs/quickstart.md index 79b66e4..21f63b9 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -26,7 +26,7 @@ db.create_table(User) # Insert a record user = User(name="John Doe", age=30) -new_record = db.insert(user) +new_user = db.insert(user) # Query records results = db.select(User).filter(name="John Doe").fetch_all() @@ -34,15 +34,15 @@ for user in results: print(f"User: {user.name}, Age: {user.age}, Admin: {user.admin}") # Update a record -user.age = 31 -db.update(User, user) +new_user.age = 31 +db.update(new_user) results = db.select(User).filter(name="John Doe").fetch_one() print("Updated age:", results.age) # Delete a record -db.delete(User, new_record.pk) +db.delete(User, new_user.pk) ``` See the [Guide](guide/guide.md) for more detailed information on how to use `SQLiter`.