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: Use new order by syntax for documentation. #59

Merged
merged 1 commit into from
Jan 19, 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
6 changes: 3 additions & 3 deletions docs/03-tutorials/01-first-app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ Future<List<Note>> getAllNotes(Session session) async {
// and not in the order they were updated.
return await Note.db.find(
session,
orderBy: Note.t.id,
orderBy: (t) => t.id,
);
}
```

In the code above, we use the `Note.db.find` method to retrieve all the notes from the database. By specifying `orderBy: Note.t.id`, we ensure that the notes are always returned in the same order based on the id column.
In the code above, we use the `Note.db.find` method to retrieve all the notes from the database. By specifying `orderBy: (t) => t.id`, we ensure that the notes are always returned in the same order based on the id column.

Putting it all together you end up with a `notes_endpoint.dart` file that looks like this:

Expand All @@ -216,7 +216,7 @@ class NotesEndpoint extends Endpoint {
// and not in the order they were updated.
return await Note.db.find(
session,
orderBy: Note.t.id,
orderBy: (t) => t.id,
);
}

Expand Down
2 changes: 1 addition & 1 deletion docs/05-concepts/06-database/07-relation-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ var user = await Company.db.findById(
employeeId,
include: Company.include(
employees: Employee.includeList(
orderBy: Employee.t.name,
orderBy: (t) => t.name,
),
),
);
Expand Down
6 changes: 3 additions & 3 deletions docs/05-concepts/06-database/09-pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int companiesPerPage = 10;

var companies = await Company.db.find(
session,
orderBy: Company.t.id,
orderBy: (t) => t.id,
limit: companiesPerPage,
offset: (page - 1) * companiesPerPage,
);
Expand Down Expand Up @@ -73,7 +73,7 @@ int recordsPerPage = 10;

var companies = await Company.db.find(
session,
orderBy: Company.t.id,
orderBy: (t) => t.id,
limit: recordsPerPage,
);
```
Expand All @@ -87,7 +87,7 @@ int cursor = lastCompanyIdFromPreviousPage; // This is typically sent by the cli
var companies = await Company.db.find(
session,
where: Company.t.id > cursor,
orderBy: Company.t.id,
orderBy: (t) => t.id,
limit: recordsPerPage,
);
```
Expand Down