Skip to content

Commit 521d7b1

Browse files
committed
doc: Update summary of functions and properties in all API references
1 parent e3fe8f6 commit 521d7b1

File tree

6 files changed

+102
-119
lines changed

6 files changed

+102
-119
lines changed

docs/api/active-record-mixin.md

Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ Most of class properties are inherited from
393393
def query() -> Select[tuple[Self]]
394394
```
395395

396-
> Returns a new `sqlalchemy.sql.Select` instance for the model.
396+
> Return a new `sqlalchemy.sql.Select` for the model.
397397

398398
> This is a shortcut for `select(cls)`.
399399

@@ -419,7 +419,10 @@ def query() -> Select[tuple[Self]]
419419
def fill(**kwargs) -> Self
420420
```
421421

422-
> Fills the object with values from `kwargs` without saving to the database.
422+
> Fill the object with passed values.
423+
424+
> Update the object's attributes with the provided values
425+
> without saving to the database.
423426

424427
> **Parameters**
425428

@@ -453,7 +456,7 @@ def fill(**kwargs) -> Self
453456
async def save() -> Self
454457
```
455458

456-
> Saves the current row.
459+
> Save the current row.
457460

458461
> ???+ note
459462
>
@@ -480,7 +483,7 @@ async def save() -> Self
480483
async def update(**kwargs) -> Self
481484
```
482485

483-
> Updates the current row with the provided values.
486+
> Update the current row with the provided values.
484487

485488
> This is the same as calling `self.fill(**kwargs).save()`.
486489

@@ -509,7 +512,7 @@ async def update(**kwargs) -> Self
509512
async def delete() -> None
510513
```
511514

512-
> Deletes the current row.
515+
> Delete the current row.
513516

514517
> ???+ danger
515518
>
@@ -551,7 +554,7 @@ async def remove() -> None
551554
async def insert(**kwargs) -> Self
552555
```
553556

554-
> Inserts a new row and returns the saved instance.
557+
> Insert a new row and return the saved instance.
555558

556559
> **Parameters**
557560

@@ -585,7 +588,7 @@ async def create(**kwargs) -> Self
585588
async def save_all(rows: Sequence[Self], refresh: bool = False) -> None
586589
```
587590

588-
> Saves multiple rows in a single transaction.
591+
> Save multiple rows in a single transaction.
589592

590593
> When using this method to update existing rows, instances are not
591594
> refreshed after commit by default. Accessing the attributes of the
@@ -662,7 +665,7 @@ async def save_all(rows: Sequence[Self], refresh: bool = False) -> None
662665
async def insert_all(rows: Sequence[Self], refresh: bool = False) -> None
663666
```
664667

665-
> Inserts multiple rows in a single transaction.
668+
> Insert multiple rows in a single transaction.
666669

667670
> This is mostly a shortcut for [`save_all()`](#save_all)
668671
> when inserting new rows.
@@ -682,7 +685,7 @@ async def insert_all(rows: Sequence[Self], refresh: bool = False) -> None
682685
async def update_all(rows: Sequence[Self], refresh: bool = False) -> None
683686
```
684687

685-
> Updates multiple rows in a single transaction.
688+
> Update multiple rows in a single transaction.
686689

687690
> This is mostly a shortcut for [`save_all()`](#save_all)
688691
> when updating existing rows.
@@ -706,7 +709,7 @@ async def update_all(rows: Sequence[Self], refresh: bool = False) -> None
706709
async def delete_all(rows: Sequence[Self]) -> None
707710
```
708711

709-
> Deletes multiple rows in a single transaction.
712+
> Delete multiple rows in a single transaction.
710713

711714
> ???+ danger
712715
>
@@ -742,7 +745,7 @@ async def delete_all(rows: Sequence[Self]) -> None
742745
async def destroy(*ids: object) -> None
743746
```
744747

745-
> Deletes multiple rows by their primary key.
748+
> Delete multiple rows by their primary key.
746749

747750
> This method can only be used if the model has a single primary key.
748751
> Otherwise, it will raise a `CompositePrimaryKeyError` exception.
@@ -787,7 +790,7 @@ async def get(
787790
) -> Self | None
788791
```
789792

790-
> Fetches a row by primary key or `None` if no result is found.
793+
> Fetch a row by primary key or return `None` if no result is found.
791794

792795
> If multiple results are found, it will raise a
793796
> `sqlalchemy.exc.MultipleResultsFound` exception.
@@ -837,8 +840,10 @@ async def get_or_fail(
837840
) -> Self
838841
```
839842

840-
> Fetches a row by primary key or raises a `sqlalchemy.exc.NoResultFound`
841-
> exception if no result is found.
843+
> Fetch a row by primary key.
844+
845+
> If no result is found, it will raise a `sqlalchemy.exc.NoResultFound`
846+
> exception.
842847

843848
> If multiple results are found, it will raise a
844849
> `sqlalchemy.exc.MultipleResultsFound` exception.
@@ -884,7 +889,7 @@ async def get_or_fail(
884889
async def scalars() -> ScalarResult[Self]
885890
```
886891

887-
> Returns a `sqlalchemy.engine.ScalarResult` instance containing all rows.
892+
> Fetch all rows as scalars.
888893

889894
> **Returns**
890895

@@ -913,7 +918,7 @@ async def scalars() -> ScalarResult[Self]
913918
async def first(scalar: bool = True) -> Self | Row[tuple[Any, ...]] | None
914919
```
915920

916-
> Fetches the first row or `None` if no results are found.
921+
> Fetch the first row or return `None` if no results are found.
917922

918923
> If `scalar` is `True`, returns a scalar value (default).
919924

@@ -957,8 +962,10 @@ async def first(scalar: bool = True) -> Self | Row[tuple[Any, ...]] | None
957962
async def one(scalar: bool = True) -> Self | Row[tuple[Any, ...]]
958963
```
959964

960-
> Fetches one row or raises a `sqlalchemy.exc.NoResultFound` exception
961-
> if no results are found.
965+
> Fetch one row.
966+
967+
> If no result is found, it will raise a `sqlalchemy.exc.NoResultFound`
968+
> exception.
962969

963970
> If multiple results are found, it will raise a
964971
> `sqlalchemy.exc.MultipleResultsFound` exception.
@@ -1021,7 +1028,7 @@ async def one(scalar: bool = True) -> Self | Row[tuple[Any, ...]]
10211028
async def one_or_none(scalar: bool = True) -> Self | Row[tuple[Any, ...]] | None
10221029
```
10231030

1024-
> Fetches one row or `None` if no results are found.
1031+
> Fetch one row or return `None` if no results are found.
10251032

10261033
> If multiple results are found, it will raise a
10271034
> `sqlalchemy.exc.MultipleResultsFound` exception.
@@ -1083,7 +1090,7 @@ async def one_or_none(scalar: bool = True) -> Self | Row[tuple[Any, ...]] | None
10831090
async def all(scalars: bool = True) -> Sequence[Self] | Sequence[Row[tuple[Any, ...]]]
10841091
```
10851092

1086-
> Fetches all rows.
1093+
> Fetch all rows.
10871094

10881095
> If `scalars` is `True`, returns scalar values (default).
10891096

@@ -1126,7 +1133,7 @@ async def all(scalars: bool = True) -> Sequence[Self] | Sequence[Row[tuple[Any,
11261133
async def count() -> int
11271134
```
11281135

1129-
> Fetches the number of rows.
1136+
> Fetch the number of rows.
11301137

11311138
> **Returns**
11321139

@@ -1147,8 +1154,7 @@ async def count() -> int
11471154
async def unique(scalars: bool = True) -> ScalarResult[Self] | Result[tuple[Any, ...]]
11481155
```
11491156

1150-
> Similar to [`scalars()`](#scalars) but applies unique filtering to
1151-
> the objects returned in the result instance.
1157+
> Return rows with unique filtering applied.
11521158

11531159
> If `scalars` is `False`, returns a `sqlalchemy.engine.Result` instance
11541160
> instead of a `sqlalchemy.engine.ScalarResult` instance.
@@ -1191,9 +1197,7 @@ async def unique(scalars: bool = True) -> ScalarResult[Self] | Result[tuple[Any,
11911197
async def unique_first(scalar: bool = True) -> Self | Row[tuple[Any, ...]] | None
11921198
```
11931199

1194-
> Similar to [`first()`](#first) but applies unique filtering to
1195-
> the objects returned by either `sqlalchemy.engine.ScalarResult`
1196-
> or `sqlalchemy.engine.Result` depending on the value of `scalar`.
1200+
> Similar to `first()` with unique filtering applied.
11971201

11981202
> ???+ note
11991203
>
@@ -1211,9 +1215,7 @@ async def unique_first(scalar: bool = True) -> Self | Row[tuple[Any, ...]] | Non
12111215
async def unique_one(scalar: bool = True) -> Self | Row[tuple[Any, ...]]
12121216
```
12131217

1214-
> Similar to [`one()`](#one) but applies unique filtering to
1215-
> the objects returned by either `sqlalchemy.engine.ScalarResult`
1216-
> or `sqlalchemy.engine.Result` depending on the value of `scalar`.
1218+
> Similar to `one()` with unique filtering applied.
12171219

12181220
> ???+ note
12191221
>
@@ -1231,9 +1233,7 @@ async def unique_one(scalar: bool = True) -> Self | Row[tuple[Any, ...]]
12311233
async def unique_one_or_none(scalar: bool = True) -> Self | Row[tuple[Any, ...]] | None
12321234
```
12331235

1234-
> Similar to [`one_or_none()`](#one_or_none) but applies unique filtering to
1235-
> the objects returned by either `sqlalchemy.engine.ScalarResult`
1236-
> or `sqlalchemy.engine.Result` depending on the value of `scalar`.
1236+
> Similar to `one_or_none()` with unique filtering applied.
12371237

12381238
> ???+ note
12391239
>
@@ -1252,9 +1252,7 @@ async def unique_one_or_none(scalar: bool = True) -> Self | Row[tuple[Any, ...]]
12521252
async def unique_all(scalars: bool = True) -> Sequence[Self] | Sequence[Row[tuple[Any, ...]]]
12531253
```
12541254

1255-
> Similar to [`all()`](#all) but applies unique filtering to
1256-
> the objects returned by either `sqlalchemy.engine.ScalarResult`
1257-
> or `sqlalchemy.engine.Result` depending on the value of `scalars`.
1255+
> Similar to `all()` with unique filtering applied.
12581256

12591257
> ???+ note
12601258
>
@@ -1272,8 +1270,7 @@ async def unique_all(scalars: bool = True) -> Sequence[Self] | Sequence[Row[tupl
12721270
async def unique_count() -> int
12731271
```
12741272

1275-
> Similar to [`count()`](#count) but applies unique filtering to
1276-
> the objects returned by `sqlalchemy.engine.ScalarResult`.
1273+
> Similar to `count()` with unique filtering applied.
12771274

12781275
> ???+ note
12791276
>
@@ -1291,7 +1288,7 @@ async def unique_count() -> int
12911288
def select(*entities: _ColumnsClauseArgument[Any]) -> AsyncQuery[Self]
12921289
```
12931290

1294-
> Replaces the columns clause with the given entities.
1291+
> Replace the columns clause with the given entities.
12951292

12961293
> The existing set of FROMs are maintained, including those implied by
12971294
> the current columns clause.
@@ -1322,7 +1319,7 @@ def select(*entities: _ColumnsClauseArgument[Any]) -> AsyncQuery[Self]
13221319
def distinct() -> AsyncQuery[Self]
13231320
```
13241321

1325-
> Applies DISTINCT to the SELECT statement overall.
1322+
> Apply DISTINCT to the SELECT statement overall.
13261323

13271324
> **Returns**
13281325

@@ -1344,7 +1341,7 @@ def distinct() -> AsyncQuery[Self]
13441341
def options(*args: ExecutableOption) -> AsyncQuery[Self]
13451342
```
13461343

1347-
> Applies the given list of mapper options.
1344+
> Apply the given list of mapper options.
13481345

13491346
> ???+ warning
13501347
>
@@ -1419,7 +1416,7 @@ def options(*args: ExecutableOption) -> AsyncQuery[Self]
14191416
def where(*criteria: ColumnElement[bool], **filters: Any) -> AsyncQuery[Self]
14201417
```
14211418

1422-
> Applies one or more WHERE criteria to the query.
1419+
> Apply one or more WHERE criteria to the query.
14231420

14241421
> It supports both Django-like syntax and SQLAlchemy syntax.
14251422

@@ -1489,7 +1486,7 @@ def search(
14891486
) -> AsyncQuery[Self]
14901487
```
14911488

1492-
> Applies a search filter to the query.
1489+
> Apply a search filter to the query.
14931490

14941491
> Searches for `search_term` in the
14951492
> [searchable columns](inspection-mixin.md#searchable_attributes) of the model.
@@ -1544,7 +1541,7 @@ def search(
15441541
def order_by(*columns: ColumnExpressionOrStrLabelArgument[Any]) -> AsyncQuery[Self]
15451542
```
15461543

1547-
> Applies one or more ORDER BY criteria to the query.
1544+
> Apply one or more ORDER BY criteria to the query.
15481545

15491546
> It supports both Django-like syntax and SQLAlchemy syntax.
15501547

@@ -1601,7 +1598,7 @@ def group_by(
16011598
) -> AsyncQuery[Self]
16021599
```
16031600

1604-
> Applies one or more GROUP BY criteria to the query.
1601+
> Apply one or more GROUP BY criteria to the query.
16051602

16061603
> It supports both Django-like syntax and SQLAlchemy syntax.
16071604

@@ -1651,7 +1648,7 @@ def group_by(
16511648
def offset(offset: int) -> AsyncQuery[Self]
16521649
```
16531650

1654-
> Applies an OFFSET clause to the query.
1651+
> Apply one OFFSET criteria to the query.
16551652

16561653
> **Parameters**
16571654

@@ -1697,7 +1694,7 @@ def skip(skip: int) -> AsyncQuery[Self]
16971694
def limit(limit: int) -> AsyncQuery[Self]
16981695
```
16991696

1700-
> Applies a LIMIT clause to the query.
1697+
> Apply one LIMIT criteria to the query.
17011698

17021699
> **Parameters**
17031700

@@ -1751,7 +1748,7 @@ def top(top: int) -> AsyncQuery[Self]
17511748
def join(*paths: EagerLoadPath) -> AsyncQuery[Self]
17521749
```
17531750

1754-
> Joined eager loading using LEFT OUTER JOIN.
1751+
> Apply joined eager loading using LEFT OUTER JOIN.
17551752

17561753
> When a tuple is passed, the second element must be boolean, and
17571754
> if `True`, the join is `INNER JOIN`, otherwise `LEFT OUTER JOIN`.
@@ -1906,7 +1903,7 @@ def with_subquery(*paths: EagerLoadPath) -> AsyncQuery[Self]
19061903
def with_schema(schema: EagerSchema) -> AsyncQuery[Self]
19071904
```
19081905

1909-
> Joined, subqueryload and selectinload eager loading.
1906+
> Apply joined, subqueryload and selectinload eager loading.
19101907

19111908
> Useful for complex cases where you need to load nested relationships in
19121909
> separate queries.
@@ -1983,9 +1980,9 @@ def smart_query(
19831980
) -> AsyncQuery[Self]
19841981
```
19851982

1986-
> Creates a query combining filtering, sorting, grouping and eager loading.
1987-
> Then, wraps the query into an [`AsyncQuery`](async-query.md) instance and
1988-
> returns it.
1983+
> Create an async smart query.
1984+
1985+
> Smart queries combine filtering, sorting, grouping and eager loading.
19891986

19901987
> See [`smart_query() from SmartQueryMixin`](smart-query-mixin.md#smart_query)
19911988
> for details.
@@ -1997,8 +1994,7 @@ def smart_query(
19971994
def get_async_query(query: Query | None = None) -> AsyncQuery[Self]
19981995
```
19991996

2000-
> Returns an `AsyncQuery` instance with the provided
2001-
> `sqlalchemy.sql.Select` instance.
1997+
> Create an `AsyncQuery` instance.
20021998

20031999
> If no `sqlalchemy.sql.Select` instance is provided,
20042000
> it uses the `query` property of the model.
@@ -2034,7 +2030,7 @@ def get_primary_key_name() -> str
20342030
This function is deprecated since version 0.2 and will be removed in future versions.
20352031
Use [`primary_key_name`](inspection-mixin.md#primary_key_name) property instead.
20362032

2037-
> Gets the primary key name of the model.
2033+
> Get the primary key name of the model.
20382034

20392035
> ???+ warning
20402036
>

0 commit comments

Comments
 (0)