Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for bulk_update #148

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix lint issues
  • Loading branch information
Micheal Gendy committed Jan 11, 2022
commit cea75153f344d8b8e67965f400ddceb8ccd6c0fd
28 changes: 14 additions & 14 deletions docs/making_queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ notes = await Note.objects.filter(completed=True).all()

There are some special operators defined automatically on every column:

- `in` - SQL `IN` operator.
- `exact` - filter instances matching exact value.
- `iexact` - same as `exact` but case-insensitive.
- `contains` - filter instances containing value.
- `icontains` - same as `contains` but case-insensitive.
- `lt` - filter instances having value `Less Than`.
- `lte` - filter instances having value `Less Than Equal`.
- `gt` - filter instances having value `Greater Than`.
- `gte` - filter instances having value `Greater Than Equal`.
* `in` - SQL `IN` operator.
* `exact` - filter instances matching exact value.
* `iexact` - same as `exact` but case-insensitive.
* `contains` - filter instances containing value.
* `icontains` - same as `contains` but case-insensitive.
* `lt` - filter instances having value `Less Than`.
* `lte` - filter instances having value `Less Than Equal`.
* `gt` - filter instances having value `Greater Than`.
* `gte` - filter instances having value `Greater Than Equal`.

Example usage:

Expand All @@ -84,7 +84,7 @@ notes = await Note.objects.filter(Note.columns.id.in_([1, 2, 3])).all()
Here `Note.columns` refers to the columns of the underlying SQLAlchemy table.

!!! note
Note that `Note.columns` returns SQLAlchemy table columns, whereas `Note.fields` returns `orm` fields.
Note that `Note.columns` returns SQLAlchemy table columns, whereas `Note.fields` returns `orm` fields.

### .limit()

Expand Down Expand Up @@ -119,7 +119,7 @@ notes = await Note.objects.order_by("text", "-id").all()
```

!!! note
This will sort by ascending `text` and descending `id`.
This will sort by ascending `text` and descending `id`.

## Returning results

Expand Down Expand Up @@ -209,7 +209,7 @@ note = await Note.objects.get(id=1)
```

!!! note
`.get()` expects to find only one instance. This can raise `NoMatch` or `MultipleMatches`.
`.get()` expects to find only one instance. This can raise `NoMatch` or `MultipleMatches`.

### .update()

Expand Down Expand Up @@ -262,7 +262,7 @@ This will query a `Note` with `text` as `"Going to car wash"`,
if it doesn't exist, it will use `defaults` argument to create the new instance.

!!! note
Since `get_or_create()` is doing a [get()](#get), it can raise `MultipleMatches` exception.
Since `get_or_create()` is doing a [get()](#get), it can raise `MultipleMatches` exception.

### .update_or_create()

Expand All @@ -280,4 +280,4 @@ if an instance is found, it will use the `defaults` argument to update the insta
If it matches no records, it will use the comibnation of arguments to create the new instance.

!!! note
Since `update_or_create()` is doing a [get()](#get), it can raise `MultipleMatches` exception.
Since `update_or_create()` is doing a [get()](#get), it can raise `MultipleMatches` exception.