Clarify schema introspection update snippet

This commit is contained in:
Simon Binder 2024-02-21 10:49:36 +01:00
parent a26cc44aaf
commit 27877a72e9
2 changed files with 15 additions and 13 deletions

View File

@ -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;
@ -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) {

View File

@ -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' %}
@ -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