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

fix: Apply fixes to 1.2 docs version. #61

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ Make sure that the documentation is all up-to-date then run:
npm run docusaurus docs:version X.X.X
```

### Amend the latest version

If you need to make changes to the latest version, you can do so by removing the latest version from `versions.json` and adding it again running the create version command with the same version number.

```
npm run docusaurus docs:version X.X.X
```

### Build and deploy

To do this you need access to the Serverpod Github `serverpod.github.io` repository. Clone it next to the `serverpod_web` repo.
Expand Down
18 changes: 9 additions & 9 deletions versioned_docs/version-1.2.0/05-concepts/06-database/08-sort.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Sort

It is often desirable to order the results of a database query. The 'find' method has an `orderBy` parameter where you can specify a column for sorting. In your model, the static `t` field provides a reference to a representation of the database table associated with the model, and this representation includes a field corresponding to each column.
It is often desirable to order the results of a database query. The 'find' method has an `orderBy` parameter where you can specify a column for sorting. The parameter takes a callback as an argument that passes a model-specific table descriptor, also accessible through the `t` field on the model. The table descriptor represents the database table associated with the model and includes fields for each corresponding column. The callback is then used to specify the column to sort by.

```dart
var companies = await Company.db.find(
session,
orderBy: Company.t.name,
orderBy: (t) => t.name,
);
```

Expand All @@ -16,7 +16,7 @@ By default the order is set to ascending, this can be changed to descending by s
```dart
var companies = await Company.db.find(
session,
orderBy: Company.t.name,
orderBy: (t) => t.name,
orderDescending: true,
);
```
Expand All @@ -28,9 +28,9 @@ To order by several different columns use `orderByList`, note that this cannot b
```dart
var companies = await Company.db.find(
session,
orderByList: [
Order(column: Company.t.name, orderDescending: true),
Order(column: Company.t.id),
orderByList: (t) => [
Order(column: t.name, orderDescending: true),
Order(column: t.id),
],
);
```
Expand All @@ -44,7 +44,7 @@ To sort based on a field from a related model, use the chained field reference.
```dart
var companies = await Company.db.find(
session,
orderBy: Company.t.ceo.name,
orderBy: (t) => t.ceo.name,
);
```

Expand All @@ -55,7 +55,7 @@ You can order results based on the count of a list relation (1:n).
```dart
var companies = await Company.db.find(
session,
orderBy: Company.t.employees.count(),
orderBy: (t) => t.employees.count(),
);
```

Expand All @@ -66,7 +66,7 @@ The count used for sorting can also be filtered using a sub-filter.
```dart
var companies = await Company.db.find(
session,
orderBy: Company.t.employees.count(
orderBy: (t) => t.employees.count(
(employee) => employee.role.equals('developer'),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Since each repair migration is created for a specific live database schema, Serv
By default, the repair migration system connects to your `development` database using the information specified in your Serverpod config. To use a different database source, the `--mode` option is used.

```bash
$ serverpod create-migration --mode production
$ serverpod create-repair-migration --mode production
```

The command connects and pulls the live database schema from a running server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,22 @@ $ serverpod create-migration

3. Create a repair migration.

The repair migration system will create a repair migration that makes your live database schema match the newly created migration. Navigate to your project's `server` package directory and run the `create-repair-migration` command.
The repair migration system will create a repair migration that makes your live database schema match the newly created migration. To enable the command to fetch your live database schema it requires a running server. Navigate to your project's `server` package directory and start the server, then run the `create-repair-migration` command.

```bash
$ dart run bin/main.dart
$ serverpod create-repair-migration
```

:::info
When starting the server, warnings will be displayed about the database schema not matching the target database schema. These warnings are expected and can safely be ignored when creating the repair migration.
:::

Use the `--mode` option to specify the database source to use. By default, the repair migration system connects to your `development` database using the information specified in your Serverpod config.

4. Apply the repair migration to your database.

Apply the repair migration to your database using the `--apply-repair-migration` flag when starting the server.
To apply the repair migration to your database, restart the server using the `--apply-repair-migration` flag.

```bash
$ dart run bin/main.dart --apply-repair-migration
Expand Down