Создание коллекций
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:remever/database/database.dart';
|
||||
import 'package:remever/database/tables.dart';
|
||||
import 'package:remever/models/collection_dto.dart';
|
||||
|
||||
part 'collections_dao.g.dart';
|
||||
|
||||
@@ -13,10 +14,20 @@ class CollectionsDao extends DatabaseAccessor<AppDatabase>
|
||||
///
|
||||
CollectionsDao(super.attachedDatabase);
|
||||
|
||||
///
|
||||
/// Получение коллекций из базы данных
|
||||
///
|
||||
Stream<List<Collection>> getCollections() {
|
||||
return db.managers.collections.watch();
|
||||
}
|
||||
|
||||
/// Создание коллекции
|
||||
Future<void> createCollection(CollectionDto dto) async {
|
||||
await db.managers.collections.create(
|
||||
(o) => o(
|
||||
title: dto.title,
|
||||
desc: dto.desc,
|
||||
isPublic: Value<bool>(dto.isPublic),
|
||||
image: Value<String?>(dto.avatar),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,13 +63,9 @@ mixin _Deletable on Table {
|
||||
@DataClassName('Collection')
|
||||
class Collections extends Table with _UuidPrimaryKey, _Timestampable {
|
||||
TextColumn get title => text()();
|
||||
|
||||
TextColumn get desc => text()();
|
||||
|
||||
TextColumn get image => text().nullable()();
|
||||
|
||||
TextColumn get payload => text().nullable()();
|
||||
|
||||
IntColumn get likesCount => integer().withDefault(Constant(0))();
|
||||
BoolColumn get isLiked => boolean().withDefault(Constant(false))();
|
||||
BoolColumn get isPublic => boolean().withDefault(Constant(false))();
|
||||
|
||||
Reference in New Issue
Block a user