Skip to content

Commit

Permalink
fix: Apply fixes in previous docs as well (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
hampuslavin authored Oct 7, 2024
1 parent ea118fb commit 9dba3cd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/06-concepts/06-database/07-relation-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var user = await Company.db.findById(
employeeId,
include: Company.include(
employees: Employee.includeList(
where: (t) => t.name.like('a%')
where: (t) => t.name.iLike('a%')
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

The Serverpod query framework supports filtering on, sorting on, and including relational data structures. In SQL this is often achieved using a join operation. The functionality is available if there exists any [one-to-one](relations/one-to-one) or [one-to-many](relations/one-to-many) object relations between two models.


## Include relational data

To include relational data in a query, use the `include` method. The `include` method has a typed interface and contains all the declared relations in your yaml file.
Expand All @@ -16,10 +15,12 @@ var employee = await Employee.db.findById(
),
);
```

The example above return a employee including the related address object.

### Nested includes
It is also possible to include deeply nested objects.

It is also possible to include deeply nested objects.

```dart
var employee = await Employee.db.findById(
Expand All @@ -32,9 +33,10 @@ var employee = await Employee.db.findById(
),
);
```

The example above returns an employee including the related company object that has the related address object included.

Any relational object can be included or not when making a query but only the includes that are explicitly defined will be included in the result.
Any relational object can be included or not when making a query but only the includes that are explicitly defined will be included in the result.

```dart
var user = await Employee.db.findById(
Expand All @@ -48,6 +50,7 @@ var user = await Employee.db.findById(
),
);
```

The example above includes several different objects configured by specifying the named parameters.

## Include relational lists
Expand Down Expand Up @@ -113,15 +116,16 @@ For each call to includeList (nested or not) the Serverpod Framework will perfor
When working with large datasets, it's often necessary to [filter](filter) and [sort](sort) the records to retrieve the most relevant data. Serverpod offers methods to refine the included list of related objects:

#### Filter
Use the `where` clause to filter the results based on certain conditions.

Use the `where` clause to filter the results based on certain conditions.

```dart
var user = await Company.db.findById(
session,
employeeId,
include: Company.include(
employees: Employee.includeList(
where: (t) => t.name.ilike('a%')
where: (t) => t.name.iLike('a%')
),
),
);`
Expand All @@ -130,6 +134,7 @@ var user = await Company.db.findById(
The example above retrieves only employees whose names start with the letter 'a':

#### Sort

The orderBy clause lets you sort the results based on a specific field.

```dart
Expand All @@ -143,25 +148,27 @@ var user = await Company.db.findById(
),
);
```

The example above sorts the employees by their names in ascending order.

### Pagination

[Paginate](pagination) results by specifying a limit on the number of records and an offset.
[Paginate](pagination) results by specifying a limit on the number of records and an offset.

```dart
var user = await Company.db.findById(
session,
employeeId,
include: Company.include(
employees: Employee.includeList(
limit: 100,
limit: 10,
offset: 10,
),
),
);
```
The example above retrieves the next 100 employees starting from the 11th record:

The example above retrieves the next 10 employees starting from the 11th record:

Using these methods in conjunction provides a powerful way to query, filter, and sort relational data efficiently.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var user = await Company.db.findById(
employeeId,
include: Company.include(
employees: Employee.includeList(
where: (t) => t.name.ilike('a%')
where: (t) => t.name.iLike('a%')
),
),
);`
Expand Down Expand Up @@ -161,14 +161,14 @@ var user = await Company.db.findById(
employeeId,
include: Company.include(
employees: Employee.includeList(
limit: 100,
limit: 10,
offset: 10,
),
),
);
```

The example above retrieves the next 100 employees starting from the 11th record:
The example above retrieves the next 10 employees starting from the 11th record:

Using these methods in conjunction provides a powerful way to query, filter, and sort relational data efficiently.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var user = await Company.db.findById(
employeeId,
include: Company.include(
employees: Employee.includeList(
where: (t) => t.name.ilike('a%')
where: (t) => t.name.iLike('a%')
),
),
);`
Expand Down Expand Up @@ -161,14 +161,14 @@ var user = await Company.db.findById(
employeeId,
include: Company.include(
employees: Employee.includeList(
limit: 100,
limit: 10,
offset: 10,
),
),
);
```

The example above retrieves the next 100 employees starting from the 11th record:
The example above retrieves the next 10 employees starting from the 11th record:

Using these methods in conjunction provides a powerful way to query, filter, and sort relational data efficiently.

Expand Down
4 changes: 2 additions & 2 deletions versioned_docs/version-2.1.0/06-concepts/07-configuration.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Configurations

Serverpod can be configured in a few different ways. The minimum required settings to provide is the configuration for the API server. If no settings are provided at all the default settings for the API server are used.
Serverpod can be configured in a few different ways. The minimum required settings to provide is the configuration for the API server. If no settings are provided at all, the default settings for the API server are used.

## Configuration options

There are three different ways to configure Serverpod, with environment variables, via yaml config files or by supplying the dart configuration object to the Serverpod constructor. The environment variables take precedence over the yaml configurations but both can be used simultaneously. The dart configuration object will override any environment variable or config file. The tables show all available configuration options provided in the Serverpod core library.
There are three different ways to configure Serverpod: with environment variables, via yaml config files or by supplying the dart configuration object to the Serverpod constructor. The environment variables take precedence over the yaml configurations but both can be used simultaneously. The dart configuration object will override any environment variable or config file. The tables show all available configuration options provided in the Serverpod core library.

| Environment variable | Config file | Default | Description |
|----------------------------------------------|--------------------------------------|-----------|--------------------------------------------------|
Expand Down

0 comments on commit 9dba3cd

Please sign in to comment.