Skip to content

Commit

Permalink
Clarify schema introspection update snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
simolus3 committed Feb 21, 2024
1 parent a26cc44 commit 27877a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
24 changes: 13 additions & 11 deletions docs/lib/snippets/modular/schema_inspection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@ extension FindById<Table extends HasResultSet, Row>
}
// #enddocregion findById

extension FindTodoEntryById on GeneratedDatabase {
Todos get todos => Todos(this);

// #docregion findTodoEntryById
Selectable<Todo> findTodoEntryById(int id) {
return select(todos)..where((row) => row.id.equals(id));
}
// #enddocregion findTodoEntryById

// #docregion updateTitle
// #docregion updateTitle
extension UpdateTitle on DatabaseConnectionUser {
Future<Row?> updateTitle<T extends TableInfo<Table, Row>, Row>(
T table, int id, String newTitle) async {
final columnsByName = table.columnsByName;
Expand All @@ -60,7 +52,17 @@ extension FindTodoEntryById on GeneratedDatabase {

return rows.singleOrNull;
}
// #enddocregion updateTitle
}
// #enddocregion updateTitle

extension FindTodoEntryById on GeneratedDatabase {
Todos get todos => Todos(this);

// #docregion findTodoEntryById
Selectable<Todo> findTodoEntryById(int id) {
return select(todos)..where((row) => row.id.equals(id));
}
// #enddocregion findTodoEntryById

// #docregion updateTodo
Future<Todo?> updateTodoTitle(int id, String newTitle) {
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/docs/Dart API/schema_inspection.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ of the `id` column:

{% include "blocks/snippet" snippets = snippets name = 'updateTitle' %}

This method can then be called like this:
In a database or database accessor class, the method can then be called like this:

{% include "blocks/snippet" snippets = snippets name = 'updateTodo' %}

Expand All @@ -75,4 +75,4 @@ If you have questions about this, or have a suggestion for more examples to incl
[ResultSetImplementation]: https://drift.simonbinder.eu/api/drift/resultsetimplementation-class
[TableInfo]: https://drift.simonbinder.eu/api/drift/tableinfo-mixin
[ViewInfo]: https://drift.simonbinder.eu/api/drift/viewinfo-class
[GeneratedColumn]: https://drift.simonbinder.eu/api/drift/generatedcolumn-class
[GeneratedColumn]: https://drift.simonbinder.eu/api/drift/generatedcolumn-class

0 comments on commit 27877a7

Please sign in to comment.