Skip to content

Commit

Permalink
docs(reference:orm): add withScopes method
Browse files Browse the repository at this point in the history
Closes adonisjs#2
  • Loading branch information
RomainLanz committed May 21, 2021
1 parent 5149182 commit 08aa8cd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions content/reference/orm/query-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ The `sideloaded` value is passed down to the preloaded relationships as well.

---

### apply
The apply method allows you to leverage the query scopes defined on the model.
### withScopes
The `withScopes` method allows you to leverage the query scopes defined on the model.

Begin by defining a query scope.

Expand All @@ -205,6 +205,18 @@ The `forUser` property is a query scope that accepts the `user` object to fetch

Now you can use the query scope as follows

```ts
Team
.query()
.withScopes((scopes) => scopes.forUser(auth.user))
```

---

### apply

Alias for the [`withScopes`](./query-builder.md#withscopes) method.

```ts
Team
.query()
Expand Down

0 comments on commit 08aa8cd

Please sign in to comment.