mirror of https://github.com/AMT-Cheif/drift.git
Generate modular manager code
This commit is contained in:
parent
24af4873e7
commit
6558e46da0
|
@ -206,6 +206,8 @@ class GeopolyTestCompanion extends UpdateCompanion<GeopolyTestData> {
|
|||
|
||||
abstract class _$_GeopolyTestDatabase extends GeneratedDatabase {
|
||||
_$_GeopolyTestDatabase(QueryExecutor e) : super(e);
|
||||
_$_GeopolyTestDatabaseManager get managers =>
|
||||
_$_GeopolyTestDatabaseManager(this);
|
||||
late final GeopolyTest geopolyTest = GeopolyTest(this);
|
||||
Selectable<double?> area(int var1) {
|
||||
return customSelect(
|
||||
|
@ -224,3 +226,86 @@ abstract class _$_GeopolyTestDatabase extends GeneratedDatabase {
|
|||
@override
|
||||
List<DatabaseSchemaEntity> get allSchemaEntities => [geopolyTest];
|
||||
}
|
||||
|
||||
class $GeopolyTestFilterComposer
|
||||
extends FilterComposer<_$_GeopolyTestDatabase, GeopolyTest> {
|
||||
$GeopolyTestFilterComposer(super.db, super.table);
|
||||
ColumnFilters<GeopolyPolygon> get shape => ColumnFilters($table.shape);
|
||||
ColumnFilters<DriftAny> get a => ColumnFilters($table.a);
|
||||
}
|
||||
|
||||
class $GeopolyTestOrderingComposer
|
||||
extends OrderingComposer<_$_GeopolyTestDatabase, GeopolyTest> {
|
||||
$GeopolyTestOrderingComposer(super.db, super.table);
|
||||
ColumnOrderings<GeopolyPolygon> get shape => ColumnOrderings($table.shape);
|
||||
ColumnOrderings<DriftAny> get a => ColumnOrderings($table.a);
|
||||
}
|
||||
|
||||
class $GeopolyTestProcessedTableManager extends ProcessedTableManager<
|
||||
_$_GeopolyTestDatabase,
|
||||
GeopolyTest,
|
||||
GeopolyTestData,
|
||||
$GeopolyTestFilterComposer,
|
||||
$GeopolyTestOrderingComposer,
|
||||
$GeopolyTestProcessedTableManager,
|
||||
$GeopolyTestInsertCompanionBuilder,
|
||||
$GeopolyTestUpdateCompanionBuilder> {
|
||||
const $GeopolyTestProcessedTableManager(super.$state);
|
||||
}
|
||||
|
||||
typedef $GeopolyTestInsertCompanionBuilder = GeopolyTestCompanion Function({
|
||||
Value<GeopolyPolygon?> shape,
|
||||
Value<DriftAny?> a,
|
||||
Value<int> rowid,
|
||||
});
|
||||
typedef $GeopolyTestUpdateCompanionBuilder = GeopolyTestCompanion Function({
|
||||
Value<GeopolyPolygon?> shape,
|
||||
Value<DriftAny?> a,
|
||||
Value<int> rowid,
|
||||
});
|
||||
|
||||
class $GeopolyTestTableManager extends RootTableManager<
|
||||
_$_GeopolyTestDatabase,
|
||||
GeopolyTest,
|
||||
GeopolyTestData,
|
||||
$GeopolyTestFilterComposer,
|
||||
$GeopolyTestOrderingComposer,
|
||||
$GeopolyTestProcessedTableManager,
|
||||
$GeopolyTestInsertCompanionBuilder,
|
||||
$GeopolyTestUpdateCompanionBuilder> {
|
||||
$GeopolyTestTableManager(_$_GeopolyTestDatabase db, GeopolyTest table)
|
||||
: super(TableManagerState(
|
||||
db: db,
|
||||
table: table,
|
||||
filteringComposer: $GeopolyTestFilterComposer(db, table),
|
||||
orderingComposer: $GeopolyTestOrderingComposer(db, table),
|
||||
getChildManagerBuilder: (p0) =>
|
||||
$GeopolyTestProcessedTableManager(p0),
|
||||
getUpdateCompanionBuilder: ({
|
||||
Value<GeopolyPolygon?> shape = const Value.absent(),
|
||||
Value<DriftAny?> a = const Value.absent(),
|
||||
Value<int> rowid = const Value.absent(),
|
||||
}) =>
|
||||
GeopolyTestCompanion(
|
||||
shape: shape,
|
||||
a: a,
|
||||
rowid: rowid,
|
||||
),
|
||||
getInsertCompanionBuilder: ({
|
||||
Value<GeopolyPolygon?> shape = const Value.absent(),
|
||||
Value<DriftAny?> a = const Value.absent(),
|
||||
Value<int> rowid = const Value.absent(),
|
||||
}) =>
|
||||
GeopolyTestCompanion.insert(
|
||||
shape: shape,
|
||||
a: a,
|
||||
rowid: rowid,
|
||||
)));
|
||||
}
|
||||
|
||||
class _$_GeopolyTestDatabaseManager {
|
||||
final _$_GeopolyTestDatabase _db;
|
||||
_$_GeopolyTestDatabaseManager(this._db);
|
||||
$GeopolyTestTableManager get geopolyTest =>
|
||||
$GeopolyTestTableManager(_db, _db.geopolyTest);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import '../../writer/database_writer.dart';
|
|||
import '../../writer/drift_accessor_writer.dart';
|
||||
import '../../writer/function_stubs_writer.dart';
|
||||
import '../../writer/import_manager.dart';
|
||||
import '../../writer/manager_writer.dart';
|
||||
import '../../writer/modules.dart';
|
||||
import '../../writer/tables/table_writer.dart';
|
||||
import '../../writer/tables/view_writer.dart';
|
||||
|
@ -294,6 +295,10 @@ class _DriftBuildRun {
|
|||
|
||||
if (result is DriftTable) {
|
||||
TableWriter(result, writer.child()).writeInto();
|
||||
|
||||
final scope = writer.child();
|
||||
final manager = ManagerWriter(scope, scope, '')..addTable(result);
|
||||
manager.writeTableManagers();
|
||||
} else if (result is DriftView) {
|
||||
ViewWriter(result, writer.child(), null).write();
|
||||
} else if (result is DriftTrigger) {
|
||||
|
|
|
@ -148,14 +148,20 @@ class DatabaseWriter {
|
|||
}
|
||||
}
|
||||
|
||||
// Write the main database manager & all the managers for tables
|
||||
// Write the main database manager and, if we're doing a monolithic build,
|
||||
// the manager classes for involved tables.
|
||||
if (scope.options.generateManager) {
|
||||
final managerWriter = ManagerWriter(scope.child(), dbScope, dbClassName);
|
||||
for (var table in elements.whereType<DriftTable>()) {
|
||||
managerWriter.addTable(table);
|
||||
}
|
||||
managerWriter.write();
|
||||
// Add getter for the manager to the database class
|
||||
if (!scope.generationOptions.isModular) {
|
||||
managerWriter.writeTableManagers();
|
||||
}
|
||||
|
||||
// Write main class for managers and reference it in a getter from the
|
||||
// database class.
|
||||
managerWriter.writeMainClass();
|
||||
firstLeaf.writeln(managerWriter.managerGetter);
|
||||
}
|
||||
|
||||
|
|
|
@ -230,12 +230,14 @@ class _TableManagerWriter {
|
|||
/// The name of the filter composer class
|
||||
///
|
||||
/// E.G `UserFilterComposer`
|
||||
String get filterComposer => '\$${table.entityInfoName}FilterComposer';
|
||||
AnnotatedDartCode get filterComposer =>
|
||||
scope.generatedElement(table, '\$${table.entityInfoName}FilterComposer');
|
||||
|
||||
/// The name of the filter composer class
|
||||
/// The name of the ordering composer class
|
||||
///
|
||||
/// E.G `UserOrderingComposer`
|
||||
String get orderingComposer => '\$${table.entityInfoName}OrderingComposer';
|
||||
AnnotatedDartCode get orderingComposer => scope.generatedElement(
|
||||
table, '\$${table.entityInfoName}OrderingComposer');
|
||||
|
||||
/// The name of the processed table manager class
|
||||
///
|
||||
|
@ -246,7 +248,7 @@ class _TableManagerWriter {
|
|||
/// The name of the root table manager class
|
||||
///
|
||||
/// E.G `UserTableManager`
|
||||
String get rootTableManager => '\$${table.entityInfoName}TableManager';
|
||||
String get rootTableManager => ManagerWriter._rootManagerName(table);
|
||||
|
||||
/// Name of the typedef for the insertCompanionBuilder
|
||||
///
|
||||
|
@ -440,8 +442,7 @@ class _TableManagerWriter {
|
|||
.firstOrNull
|
||||
?.otherColumn;
|
||||
if (referencedCol != null && referencedCol.owner is DriftTable) {
|
||||
final referencedTable = tables.firstWhere(
|
||||
(t) => t.entityInfoName == referencedCol.owner.entityInfoName);
|
||||
final referencedTable = referencedCol.owner as DriftTable;
|
||||
return (referencedTable, referencedCol);
|
||||
}
|
||||
return null;
|
||||
|
@ -507,12 +508,14 @@ class _TableManagerWriter {
|
|||
c.filters.add(_ReferencedFilterWriter(c.fieldGetter,
|
||||
fieldGetter: c.fieldGetter,
|
||||
referencedColumnGetter: referencedColumnNames.fieldGetter,
|
||||
referencedFilterComposer: referencedTableNames.filterComposer,
|
||||
referencedFilterComposer:
|
||||
scope.dartCode(referencedTableNames.filterComposer),
|
||||
referencedTableField: referencedTableField));
|
||||
c.orderings.add(_ReferencedOrderingWriter(c.fieldGetter,
|
||||
fieldGetter: c.fieldGetter,
|
||||
referencedColumnGetter: referencedColumnNames.fieldGetter,
|
||||
referencedOrderingComposer: referencedTableNames.orderingComposer,
|
||||
referencedOrderingComposer:
|
||||
scope.dartCode(referencedTableNames.orderingComposer),
|
||||
referencedTableField: referencedTableField));
|
||||
}
|
||||
columns.add(c);
|
||||
|
@ -536,7 +539,8 @@ class _TableManagerWriter {
|
|||
backRefFilters.add(_ReferencedFilterWriter(filterName,
|
||||
fieldGetter: reference.$2.nameInDart,
|
||||
referencedColumnGetter: referencedColumnNames.fieldGetter,
|
||||
referencedFilterComposer: referencedTableNames.filterComposer,
|
||||
referencedFilterComposer:
|
||||
scope.dartCode(referencedTableNames.filterComposer),
|
||||
referencedTableField: referencedTableField));
|
||||
}
|
||||
}
|
||||
|
@ -604,8 +608,15 @@ class ManagerWriter {
|
|||
return '$databaseManagerName get managers => $databaseManagerName(this);';
|
||||
}
|
||||
|
||||
/// Write the manager to a provider [TextEmitter]
|
||||
void write() {
|
||||
static String _rootManagerName(DriftTable table) {
|
||||
return '\$${table.entityInfoName}TableManager';
|
||||
}
|
||||
|
||||
AnnotatedDartCode _referenceRootManager(DriftTable table) {
|
||||
return _scope.generatedElement(table, _rootManagerName(table));
|
||||
}
|
||||
|
||||
void writeTableManagers() {
|
||||
final leaf = _scope.leaf();
|
||||
|
||||
// create the manager class for each table
|
||||
|
@ -620,19 +631,29 @@ class ManagerWriter {
|
|||
tableWriters.removeWhere((t) => t.hasCustomRowClass);
|
||||
|
||||
// Write each tables manager to the leaf and append the getter to the main manager
|
||||
final tableManagerGetters = StringBuffer();
|
||||
for (var table in tableWriters) {
|
||||
table.writeManager(leaf);
|
||||
tableManagerGetters.writeln(
|
||||
"${table.rootTableManager} get ${table.table.dbGetterName} => ${table.rootTableManager}(_db, _db.${table.table.dbGetterName});");
|
||||
}
|
||||
}
|
||||
|
||||
// Write the main manager class
|
||||
/// Writes the main manager class referencing the generated classes for each
|
||||
/// table using a getter.
|
||||
void writeMainClass() {
|
||||
final leaf = _scope.leaf();
|
||||
leaf
|
||||
..writeln('class $databaseManagerName{')
|
||||
..writeln('final $_dbClassName _db;')
|
||||
..writeln('$databaseManagerName(this._db);')
|
||||
..writeln(tableManagerGetters)
|
||||
..writeln('}');
|
||||
..writeln('$databaseManagerName(this._db);');
|
||||
|
||||
for (final table in _addedTables) {
|
||||
if (!table.hasExistingRowClass) {
|
||||
final type = leaf.dartCode(_referenceRootManager(table));
|
||||
|
||||
leaf.writeln(
|
||||
'$type get ${table.dbGetterName} => $type(_db, _db.${table.dbGetterName});');
|
||||
}
|
||||
}
|
||||
|
||||
leaf.writeln('}');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import 'package:drift/internal/modular.dart' as i7;
|
|||
|
||||
abstract class $Database extends i0.GeneratedDatabase {
|
||||
$Database(i0.QueryExecutor e) : super(e);
|
||||
$DatabaseManager get managers => $DatabaseManager(this);
|
||||
late final i1.Users users = i1.Users(this);
|
||||
late final i2.Posts posts = i2.Posts(this);
|
||||
late final i3.SearchInPosts searchInPosts = i3.SearchInPosts(this);
|
||||
|
@ -69,3 +70,15 @@ abstract class $Database extends i0.GeneratedDatabase {
|
|||
i0.DriftDatabaseOptions get options =>
|
||||
const i0.DriftDatabaseOptions(storeDateTimeAsText: true);
|
||||
}
|
||||
|
||||
class $DatabaseManager {
|
||||
final $Database _db;
|
||||
$DatabaseManager(this._db);
|
||||
i1.$UsersTableManager get users => i1.$UsersTableManager(_db, _db.users);
|
||||
i2.$PostsTableManager get posts => i2.$PostsTableManager(_db, _db.posts);
|
||||
i3.$SearchInPostsTableManager get searchInPosts =>
|
||||
i3.$SearchInPostsTableManager(_db, _db.searchInPosts);
|
||||
i2.$LikesTableManager get likes => i2.$LikesTableManager(_db, _db.likes);
|
||||
i1.$FollowsTableManager get follows =>
|
||||
i1.$FollowsTableManager(_db, _db.follows);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// ignore_for_file: type=lint
|
||||
import 'package:drift/drift.dart' as i0;
|
||||
import 'package:modular/src/posts.drift.dart' as i1;
|
||||
import 'package:drift/internal/modular.dart' as i2;
|
||||
import 'package:modular/src/users.drift.dart' as i3;
|
||||
|
||||
class Posts extends i0.Table with i0.TableInfo<Posts, i1.Post> {
|
||||
@override
|
||||
|
@ -215,6 +217,111 @@ class PostsCompanion extends i0.UpdateCompanion<i1.Post> {
|
|||
}
|
||||
}
|
||||
|
||||
class $PostsFilterComposer
|
||||
extends i0.FilterComposer<i0.GeneratedDatabase, i1.Posts> {
|
||||
$PostsFilterComposer(super.db, super.table);
|
||||
i0.ColumnFilters<int> get id => i0.ColumnFilters($table.id);
|
||||
i0.ColumnFilters<int> get authorId => i0.ColumnFilters($table.author);
|
||||
i0.ComposableFilter author(
|
||||
i0.ComposableFilter Function(i3.$UsersFilterComposer f) f) {
|
||||
return $composeWithJoins(
|
||||
$db: $db,
|
||||
$table: $table,
|
||||
referencedTable:
|
||||
i2.ReadDatabaseContainer($db).resultSet<i3.Users>('users'),
|
||||
getCurrentColumn: (f) => f.author,
|
||||
getReferencedColumn: (f) => f.id,
|
||||
getReferencedComposer: (db, table) =>
|
||||
i3.$UsersFilterComposer(db, table),
|
||||
builder: f);
|
||||
}
|
||||
|
||||
i0.ColumnFilters<String> get content => i0.ColumnFilters($table.content);
|
||||
}
|
||||
|
||||
class $PostsOrderingComposer
|
||||
extends i0.OrderingComposer<i0.GeneratedDatabase, i1.Posts> {
|
||||
$PostsOrderingComposer(super.db, super.table);
|
||||
i0.ColumnOrderings<int> get id => i0.ColumnOrderings($table.id);
|
||||
i0.ColumnOrderings<int> get authorId => i0.ColumnOrderings($table.author);
|
||||
i0.ComposableOrdering author(
|
||||
i0.ComposableOrdering Function(i3.$UsersOrderingComposer o) o) {
|
||||
return $composeWithJoins(
|
||||
$db: $db,
|
||||
$table: $table,
|
||||
referencedTable:
|
||||
i2.ReadDatabaseContainer($db).resultSet<i3.Users>('users'),
|
||||
getCurrentColumn: (f) => f.author,
|
||||
getReferencedColumn: (f) => f.id,
|
||||
getReferencedComposer: (db, table) =>
|
||||
i3.$UsersOrderingComposer(db, table),
|
||||
builder: o);
|
||||
}
|
||||
|
||||
i0.ColumnOrderings<String> get content => i0.ColumnOrderings($table.content);
|
||||
}
|
||||
|
||||
class $PostsProcessedTableManager extends i0.ProcessedTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.Posts,
|
||||
i1.Post,
|
||||
$PostsFilterComposer,
|
||||
$PostsOrderingComposer,
|
||||
$PostsProcessedTableManager,
|
||||
$PostsInsertCompanionBuilder,
|
||||
$PostsUpdateCompanionBuilder> {
|
||||
const $PostsProcessedTableManager(super.$state);
|
||||
}
|
||||
|
||||
typedef $PostsInsertCompanionBuilder = i1.PostsCompanion Function({
|
||||
i0.Value<int> id,
|
||||
required int author,
|
||||
i0.Value<String?> content,
|
||||
});
|
||||
typedef $PostsUpdateCompanionBuilder = i1.PostsCompanion Function({
|
||||
i0.Value<int> id,
|
||||
i0.Value<int> author,
|
||||
i0.Value<String?> content,
|
||||
});
|
||||
|
||||
class $PostsTableManager extends i0.RootTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.Posts,
|
||||
i1.Post,
|
||||
$PostsFilterComposer,
|
||||
$PostsOrderingComposer,
|
||||
$PostsProcessedTableManager,
|
||||
$PostsInsertCompanionBuilder,
|
||||
$PostsUpdateCompanionBuilder> {
|
||||
$PostsTableManager(i0.GeneratedDatabase db, i1.Posts table)
|
||||
: super(i0.TableManagerState(
|
||||
db: db,
|
||||
table: table,
|
||||
filteringComposer: $PostsFilterComposer(db, table),
|
||||
orderingComposer: $PostsOrderingComposer(db, table),
|
||||
getChildManagerBuilder: (p0) => $PostsProcessedTableManager(p0),
|
||||
getUpdateCompanionBuilder: ({
|
||||
i0.Value<int> id = const i0.Value.absent(),
|
||||
i0.Value<int> author = const i0.Value.absent(),
|
||||
i0.Value<String?> content = const i0.Value.absent(),
|
||||
}) =>
|
||||
i1.PostsCompanion(
|
||||
id: id,
|
||||
author: author,
|
||||
content: content,
|
||||
),
|
||||
getInsertCompanionBuilder: ({
|
||||
i0.Value<int> id = const i0.Value.absent(),
|
||||
required int author,
|
||||
i0.Value<String?> content = const i0.Value.absent(),
|
||||
}) =>
|
||||
i1.PostsCompanion.insert(
|
||||
id: id,
|
||||
author: author,
|
||||
content: content,
|
||||
)));
|
||||
}
|
||||
|
||||
class Likes extends i0.Table with i0.TableInfo<Likes, i1.Like> {
|
||||
@override
|
||||
final i0.GeneratedDatabase attachedDatabase;
|
||||
|
@ -403,3 +510,132 @@ class LikesCompanion extends i0.UpdateCompanion<i1.Like> {
|
|||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class $LikesFilterComposer
|
||||
extends i0.FilterComposer<i0.GeneratedDatabase, i1.Likes> {
|
||||
$LikesFilterComposer(super.db, super.table);
|
||||
i0.ColumnFilters<int> get postId => i0.ColumnFilters($table.post);
|
||||
i0.ComposableFilter post(
|
||||
i0.ComposableFilter Function(i1.$PostsFilterComposer f) f) {
|
||||
return $composeWithJoins(
|
||||
$db: $db,
|
||||
$table: $table,
|
||||
referencedTable:
|
||||
i2.ReadDatabaseContainer($db).resultSet<i1.Posts>('posts'),
|
||||
getCurrentColumn: (f) => f.post,
|
||||
getReferencedColumn: (f) => f.id,
|
||||
getReferencedComposer: (db, table) =>
|
||||
i1.$PostsFilterComposer(db, table),
|
||||
builder: f);
|
||||
}
|
||||
|
||||
i0.ColumnFilters<int> get likedById => i0.ColumnFilters($table.likedBy);
|
||||
i0.ComposableFilter likedBy(
|
||||
i0.ComposableFilter Function(i3.$UsersFilterComposer f) f) {
|
||||
return $composeWithJoins(
|
||||
$db: $db,
|
||||
$table: $table,
|
||||
referencedTable:
|
||||
i2.ReadDatabaseContainer($db).resultSet<i3.Users>('users'),
|
||||
getCurrentColumn: (f) => f.likedBy,
|
||||
getReferencedColumn: (f) => f.id,
|
||||
getReferencedComposer: (db, table) =>
|
||||
i3.$UsersFilterComposer(db, table),
|
||||
builder: f);
|
||||
}
|
||||
}
|
||||
|
||||
class $LikesOrderingComposer
|
||||
extends i0.OrderingComposer<i0.GeneratedDatabase, i1.Likes> {
|
||||
$LikesOrderingComposer(super.db, super.table);
|
||||
i0.ColumnOrderings<int> get postId => i0.ColumnOrderings($table.post);
|
||||
i0.ComposableOrdering post(
|
||||
i0.ComposableOrdering Function(i1.$PostsOrderingComposer o) o) {
|
||||
return $composeWithJoins(
|
||||
$db: $db,
|
||||
$table: $table,
|
||||
referencedTable:
|
||||
i2.ReadDatabaseContainer($db).resultSet<i1.Posts>('posts'),
|
||||
getCurrentColumn: (f) => f.post,
|
||||
getReferencedColumn: (f) => f.id,
|
||||
getReferencedComposer: (db, table) =>
|
||||
i1.$PostsOrderingComposer(db, table),
|
||||
builder: o);
|
||||
}
|
||||
|
||||
i0.ColumnOrderings<int> get likedById => i0.ColumnOrderings($table.likedBy);
|
||||
i0.ComposableOrdering likedBy(
|
||||
i0.ComposableOrdering Function(i3.$UsersOrderingComposer o) o) {
|
||||
return $composeWithJoins(
|
||||
$db: $db,
|
||||
$table: $table,
|
||||
referencedTable:
|
||||
i2.ReadDatabaseContainer($db).resultSet<i3.Users>('users'),
|
||||
getCurrentColumn: (f) => f.likedBy,
|
||||
getReferencedColumn: (f) => f.id,
|
||||
getReferencedComposer: (db, table) =>
|
||||
i3.$UsersOrderingComposer(db, table),
|
||||
builder: o);
|
||||
}
|
||||
}
|
||||
|
||||
class $LikesProcessedTableManager extends i0.ProcessedTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.Likes,
|
||||
i1.Like,
|
||||
$LikesFilterComposer,
|
||||
$LikesOrderingComposer,
|
||||
$LikesProcessedTableManager,
|
||||
$LikesInsertCompanionBuilder,
|
||||
$LikesUpdateCompanionBuilder> {
|
||||
const $LikesProcessedTableManager(super.$state);
|
||||
}
|
||||
|
||||
typedef $LikesInsertCompanionBuilder = i1.LikesCompanion Function({
|
||||
required int post,
|
||||
required int likedBy,
|
||||
i0.Value<int> rowid,
|
||||
});
|
||||
typedef $LikesUpdateCompanionBuilder = i1.LikesCompanion Function({
|
||||
i0.Value<int> post,
|
||||
i0.Value<int> likedBy,
|
||||
i0.Value<int> rowid,
|
||||
});
|
||||
|
||||
class $LikesTableManager extends i0.RootTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.Likes,
|
||||
i1.Like,
|
||||
$LikesFilterComposer,
|
||||
$LikesOrderingComposer,
|
||||
$LikesProcessedTableManager,
|
||||
$LikesInsertCompanionBuilder,
|
||||
$LikesUpdateCompanionBuilder> {
|
||||
$LikesTableManager(i0.GeneratedDatabase db, i1.Likes table)
|
||||
: super(i0.TableManagerState(
|
||||
db: db,
|
||||
table: table,
|
||||
filteringComposer: $LikesFilterComposer(db, table),
|
||||
orderingComposer: $LikesOrderingComposer(db, table),
|
||||
getChildManagerBuilder: (p0) => $LikesProcessedTableManager(p0),
|
||||
getUpdateCompanionBuilder: ({
|
||||
i0.Value<int> post = const i0.Value.absent(),
|
||||
i0.Value<int> likedBy = const i0.Value.absent(),
|
||||
i0.Value<int> rowid = const i0.Value.absent(),
|
||||
}) =>
|
||||
i1.LikesCompanion(
|
||||
post: post,
|
||||
likedBy: likedBy,
|
||||
rowid: rowid,
|
||||
),
|
||||
getInsertCompanionBuilder: ({
|
||||
required int post,
|
||||
required int likedBy,
|
||||
i0.Value<int> rowid = const i0.Value.absent(),
|
||||
}) =>
|
||||
i1.LikesCompanion.insert(
|
||||
post: post,
|
||||
likedBy: likedBy,
|
||||
rowid: rowid,
|
||||
)));
|
||||
}
|
||||
|
|
|
@ -204,6 +204,84 @@ class SearchInPostsCompanion extends i0.UpdateCompanion<i1.SearchInPost> {
|
|||
}
|
||||
}
|
||||
|
||||
class $SearchInPostsFilterComposer
|
||||
extends i0.FilterComposer<i0.GeneratedDatabase, i1.SearchInPosts> {
|
||||
$SearchInPostsFilterComposer(super.db, super.table);
|
||||
i0.ColumnFilters<String> get author => i0.ColumnFilters($table.author);
|
||||
i0.ColumnFilters<String> get content => i0.ColumnFilters($table.content);
|
||||
}
|
||||
|
||||
class $SearchInPostsOrderingComposer
|
||||
extends i0.OrderingComposer<i0.GeneratedDatabase, i1.SearchInPosts> {
|
||||
$SearchInPostsOrderingComposer(super.db, super.table);
|
||||
i0.ColumnOrderings<String> get author => i0.ColumnOrderings($table.author);
|
||||
i0.ColumnOrderings<String> get content => i0.ColumnOrderings($table.content);
|
||||
}
|
||||
|
||||
class $SearchInPostsProcessedTableManager extends i0.ProcessedTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.SearchInPosts,
|
||||
i1.SearchInPost,
|
||||
$SearchInPostsFilterComposer,
|
||||
$SearchInPostsOrderingComposer,
|
||||
$SearchInPostsProcessedTableManager,
|
||||
$SearchInPostsInsertCompanionBuilder,
|
||||
$SearchInPostsUpdateCompanionBuilder> {
|
||||
const $SearchInPostsProcessedTableManager(super.$state);
|
||||
}
|
||||
|
||||
typedef $SearchInPostsInsertCompanionBuilder = i1.SearchInPostsCompanion
|
||||
Function({
|
||||
required String author,
|
||||
required String content,
|
||||
i0.Value<int> rowid,
|
||||
});
|
||||
typedef $SearchInPostsUpdateCompanionBuilder = i1.SearchInPostsCompanion
|
||||
Function({
|
||||
i0.Value<String> author,
|
||||
i0.Value<String> content,
|
||||
i0.Value<int> rowid,
|
||||
});
|
||||
|
||||
class $SearchInPostsTableManager extends i0.RootTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.SearchInPosts,
|
||||
i1.SearchInPost,
|
||||
$SearchInPostsFilterComposer,
|
||||
$SearchInPostsOrderingComposer,
|
||||
$SearchInPostsProcessedTableManager,
|
||||
$SearchInPostsInsertCompanionBuilder,
|
||||
$SearchInPostsUpdateCompanionBuilder> {
|
||||
$SearchInPostsTableManager(i0.GeneratedDatabase db, i1.SearchInPosts table)
|
||||
: super(i0.TableManagerState(
|
||||
db: db,
|
||||
table: table,
|
||||
filteringComposer: $SearchInPostsFilterComposer(db, table),
|
||||
orderingComposer: $SearchInPostsOrderingComposer(db, table),
|
||||
getChildManagerBuilder: (p0) =>
|
||||
$SearchInPostsProcessedTableManager(p0),
|
||||
getUpdateCompanionBuilder: ({
|
||||
i0.Value<String> author = const i0.Value.absent(),
|
||||
i0.Value<String> content = const i0.Value.absent(),
|
||||
i0.Value<int> rowid = const i0.Value.absent(),
|
||||
}) =>
|
||||
i1.SearchInPostsCompanion(
|
||||
author: author,
|
||||
content: content,
|
||||
rowid: rowid,
|
||||
),
|
||||
getInsertCompanionBuilder: ({
|
||||
required String author,
|
||||
required String content,
|
||||
i0.Value<int> rowid = const i0.Value.absent(),
|
||||
}) =>
|
||||
i1.SearchInPostsCompanion.insert(
|
||||
author: author,
|
||||
content: content,
|
||||
rowid: rowid,
|
||||
)));
|
||||
}
|
||||
|
||||
i0.Trigger get postsInsert => i0.Trigger(
|
||||
'CREATE TRIGGER posts_insert AFTER INSERT ON posts BEGIN INSERT INTO search_in_posts ("rowid", author, content) VALUES (new.id, new.author, new.content);END',
|
||||
'posts_insert');
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:drift/drift.dart' as i0;
|
|||
import 'package:modular/src/users.drift.dart' as i1;
|
||||
import 'package:modular/src/preferences.dart' as i2;
|
||||
import 'dart:typed_data' as i3;
|
||||
import 'package:drift/internal/modular.dart' as i4;
|
||||
|
||||
class Users extends i0.Table with i0.TableInfo<Users, i1.User> {
|
||||
@override
|
||||
|
@ -313,6 +314,106 @@ class UsersCompanion extends i0.UpdateCompanion<i1.User> {
|
|||
}
|
||||
}
|
||||
|
||||
class $UsersFilterComposer
|
||||
extends i0.FilterComposer<i0.GeneratedDatabase, i1.Users> {
|
||||
$UsersFilterComposer(super.db, super.table);
|
||||
i0.ColumnFilters<int> get id => i0.ColumnFilters($table.id);
|
||||
i0.ColumnFilters<String> get name => i0.ColumnFilters($table.name);
|
||||
i0.ColumnFilters<String> get biography => i0.ColumnFilters($table.biography);
|
||||
i0.ColumnFilters<String> get preferencesValue =>
|
||||
i0.ColumnFilters($table.preferences);
|
||||
i0.ColumnWithTypeConverterFilters<i2.Preferences?, i2.Preferences, String>
|
||||
get preferences => i0.ColumnWithTypeConverterFilters($table.preferences);
|
||||
i0.ColumnFilters<i3.Uint8List> get profilePicture =>
|
||||
i0.ColumnFilters($table.profilePicture);
|
||||
}
|
||||
|
||||
class $UsersOrderingComposer
|
||||
extends i0.OrderingComposer<i0.GeneratedDatabase, i1.Users> {
|
||||
$UsersOrderingComposer(super.db, super.table);
|
||||
i0.ColumnOrderings<int> get id => i0.ColumnOrderings($table.id);
|
||||
i0.ColumnOrderings<String> get name => i0.ColumnOrderings($table.name);
|
||||
i0.ColumnOrderings<String> get biography =>
|
||||
i0.ColumnOrderings($table.biography);
|
||||
i0.ColumnOrderings<String> get preferences =>
|
||||
i0.ColumnOrderings($table.preferences);
|
||||
i0.ColumnOrderings<i3.Uint8List> get profilePicture =>
|
||||
i0.ColumnOrderings($table.profilePicture);
|
||||
}
|
||||
|
||||
class $UsersProcessedTableManager extends i0.ProcessedTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.Users,
|
||||
i1.User,
|
||||
$UsersFilterComposer,
|
||||
$UsersOrderingComposer,
|
||||
$UsersProcessedTableManager,
|
||||
$UsersInsertCompanionBuilder,
|
||||
$UsersUpdateCompanionBuilder> {
|
||||
const $UsersProcessedTableManager(super.$state);
|
||||
}
|
||||
|
||||
typedef $UsersInsertCompanionBuilder = i1.UsersCompanion Function({
|
||||
i0.Value<int> id,
|
||||
required String name,
|
||||
i0.Value<String?> biography,
|
||||
i0.Value<i2.Preferences?> preferences,
|
||||
i0.Value<i3.Uint8List?> profilePicture,
|
||||
});
|
||||
typedef $UsersUpdateCompanionBuilder = i1.UsersCompanion Function({
|
||||
i0.Value<int> id,
|
||||
i0.Value<String> name,
|
||||
i0.Value<String?> biography,
|
||||
i0.Value<i2.Preferences?> preferences,
|
||||
i0.Value<i3.Uint8List?> profilePicture,
|
||||
});
|
||||
|
||||
class $UsersTableManager extends i0.RootTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.Users,
|
||||
i1.User,
|
||||
$UsersFilterComposer,
|
||||
$UsersOrderingComposer,
|
||||
$UsersProcessedTableManager,
|
||||
$UsersInsertCompanionBuilder,
|
||||
$UsersUpdateCompanionBuilder> {
|
||||
$UsersTableManager(i0.GeneratedDatabase db, i1.Users table)
|
||||
: super(i0.TableManagerState(
|
||||
db: db,
|
||||
table: table,
|
||||
filteringComposer: $UsersFilterComposer(db, table),
|
||||
orderingComposer: $UsersOrderingComposer(db, table),
|
||||
getChildManagerBuilder: (p0) => $UsersProcessedTableManager(p0),
|
||||
getUpdateCompanionBuilder: ({
|
||||
i0.Value<int> id = const i0.Value.absent(),
|
||||
i0.Value<String> name = const i0.Value.absent(),
|
||||
i0.Value<String?> biography = const i0.Value.absent(),
|
||||
i0.Value<i2.Preferences?> preferences = const i0.Value.absent(),
|
||||
i0.Value<i3.Uint8List?> profilePicture = const i0.Value.absent(),
|
||||
}) =>
|
||||
i1.UsersCompanion(
|
||||
id: id,
|
||||
name: name,
|
||||
biography: biography,
|
||||
preferences: preferences,
|
||||
profilePicture: profilePicture,
|
||||
),
|
||||
getInsertCompanionBuilder: ({
|
||||
i0.Value<int> id = const i0.Value.absent(),
|
||||
required String name,
|
||||
i0.Value<String?> biography = const i0.Value.absent(),
|
||||
i0.Value<i2.Preferences?> preferences = const i0.Value.absent(),
|
||||
i0.Value<i3.Uint8List?> profilePicture = const i0.Value.absent(),
|
||||
}) =>
|
||||
i1.UsersCompanion.insert(
|
||||
id: id,
|
||||
name: name,
|
||||
biography: biography,
|
||||
preferences: preferences,
|
||||
profilePicture: profilePicture,
|
||||
)));
|
||||
}
|
||||
|
||||
i0.Index get usersName =>
|
||||
i0.Index('users_name', 'CREATE INDEX users_name ON users (name)');
|
||||
|
||||
|
@ -510,6 +611,135 @@ class FollowsCompanion extends i0.UpdateCompanion<i1.Follow> {
|
|||
}
|
||||
}
|
||||
|
||||
class $FollowsFilterComposer
|
||||
extends i0.FilterComposer<i0.GeneratedDatabase, i1.Follows> {
|
||||
$FollowsFilterComposer(super.db, super.table);
|
||||
i0.ColumnFilters<int> get followedId => i0.ColumnFilters($table.followed);
|
||||
i0.ComposableFilter followed(
|
||||
i0.ComposableFilter Function(i1.$UsersFilterComposer f) f) {
|
||||
return $composeWithJoins(
|
||||
$db: $db,
|
||||
$table: $table,
|
||||
referencedTable:
|
||||
i4.ReadDatabaseContainer($db).resultSet<i1.Users>('users'),
|
||||
getCurrentColumn: (f) => f.followed,
|
||||
getReferencedColumn: (f) => f.id,
|
||||
getReferencedComposer: (db, table) =>
|
||||
i1.$UsersFilterComposer(db, table),
|
||||
builder: f);
|
||||
}
|
||||
|
||||
i0.ColumnFilters<int> get followerId => i0.ColumnFilters($table.follower);
|
||||
i0.ComposableFilter follower(
|
||||
i0.ComposableFilter Function(i1.$UsersFilterComposer f) f) {
|
||||
return $composeWithJoins(
|
||||
$db: $db,
|
||||
$table: $table,
|
||||
referencedTable:
|
||||
i4.ReadDatabaseContainer($db).resultSet<i1.Users>('users'),
|
||||
getCurrentColumn: (f) => f.follower,
|
||||
getReferencedColumn: (f) => f.id,
|
||||
getReferencedComposer: (db, table) =>
|
||||
i1.$UsersFilterComposer(db, table),
|
||||
builder: f);
|
||||
}
|
||||
}
|
||||
|
||||
class $FollowsOrderingComposer
|
||||
extends i0.OrderingComposer<i0.GeneratedDatabase, i1.Follows> {
|
||||
$FollowsOrderingComposer(super.db, super.table);
|
||||
i0.ColumnOrderings<int> get followedId => i0.ColumnOrderings($table.followed);
|
||||
i0.ComposableOrdering followed(
|
||||
i0.ComposableOrdering Function(i1.$UsersOrderingComposer o) o) {
|
||||
return $composeWithJoins(
|
||||
$db: $db,
|
||||
$table: $table,
|
||||
referencedTable:
|
||||
i4.ReadDatabaseContainer($db).resultSet<i1.Users>('users'),
|
||||
getCurrentColumn: (f) => f.followed,
|
||||
getReferencedColumn: (f) => f.id,
|
||||
getReferencedComposer: (db, table) =>
|
||||
i1.$UsersOrderingComposer(db, table),
|
||||
builder: o);
|
||||
}
|
||||
|
||||
i0.ColumnOrderings<int> get followerId => i0.ColumnOrderings($table.follower);
|
||||
i0.ComposableOrdering follower(
|
||||
i0.ComposableOrdering Function(i1.$UsersOrderingComposer o) o) {
|
||||
return $composeWithJoins(
|
||||
$db: $db,
|
||||
$table: $table,
|
||||
referencedTable:
|
||||
i4.ReadDatabaseContainer($db).resultSet<i1.Users>('users'),
|
||||
getCurrentColumn: (f) => f.follower,
|
||||
getReferencedColumn: (f) => f.id,
|
||||
getReferencedComposer: (db, table) =>
|
||||
i1.$UsersOrderingComposer(db, table),
|
||||
builder: o);
|
||||
}
|
||||
}
|
||||
|
||||
class $FollowsProcessedTableManager extends i0.ProcessedTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.Follows,
|
||||
i1.Follow,
|
||||
$FollowsFilterComposer,
|
||||
$FollowsOrderingComposer,
|
||||
$FollowsProcessedTableManager,
|
||||
$FollowsInsertCompanionBuilder,
|
||||
$FollowsUpdateCompanionBuilder> {
|
||||
const $FollowsProcessedTableManager(super.$state);
|
||||
}
|
||||
|
||||
typedef $FollowsInsertCompanionBuilder = i1.FollowsCompanion Function({
|
||||
required int followed,
|
||||
required int follower,
|
||||
i0.Value<int> rowid,
|
||||
});
|
||||
typedef $FollowsUpdateCompanionBuilder = i1.FollowsCompanion Function({
|
||||
i0.Value<int> followed,
|
||||
i0.Value<int> follower,
|
||||
i0.Value<int> rowid,
|
||||
});
|
||||
|
||||
class $FollowsTableManager extends i0.RootTableManager<
|
||||
i0.GeneratedDatabase,
|
||||
i1.Follows,
|
||||
i1.Follow,
|
||||
$FollowsFilterComposer,
|
||||
$FollowsOrderingComposer,
|
||||
$FollowsProcessedTableManager,
|
||||
$FollowsInsertCompanionBuilder,
|
||||
$FollowsUpdateCompanionBuilder> {
|
||||
$FollowsTableManager(i0.GeneratedDatabase db, i1.Follows table)
|
||||
: super(i0.TableManagerState(
|
||||
db: db,
|
||||
table: table,
|
||||
filteringComposer: $FollowsFilterComposer(db, table),
|
||||
orderingComposer: $FollowsOrderingComposer(db, table),
|
||||
getChildManagerBuilder: (p0) => $FollowsProcessedTableManager(p0),
|
||||
getUpdateCompanionBuilder: ({
|
||||
i0.Value<int> followed = const i0.Value.absent(),
|
||||
i0.Value<int> follower = const i0.Value.absent(),
|
||||
i0.Value<int> rowid = const i0.Value.absent(),
|
||||
}) =>
|
||||
i1.FollowsCompanion(
|
||||
followed: followed,
|
||||
follower: follower,
|
||||
rowid: rowid,
|
||||
),
|
||||
getInsertCompanionBuilder: ({
|
||||
required int followed,
|
||||
required int follower,
|
||||
i0.Value<int> rowid = const i0.Value.absent(),
|
||||
}) =>
|
||||
i1.FollowsCompanion.insert(
|
||||
followed: followed,
|
||||
follower: follower,
|
||||
rowid: rowid,
|
||||
)));
|
||||
}
|
||||
|
||||
class PopularUser extends i0.DataClass {
|
||||
final int id;
|
||||
final String name;
|
||||
|
|
Loading…
Reference in New Issue