Skip to content

Commit

Permalink
fix docs re update() method
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Ramsay <seapagan@gmail.com>
  • Loading branch information
seapagan committed Sep 30, 2024
1 parent b5f1262 commit e904bfc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/data-ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions docs/guide/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ 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()
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`.

0 comments on commit e904bfc

Please sign in to comment.