Создание коллекций

This commit is contained in:
2025-03-25 20:53:53 +03:00
parent cb6ce05059
commit e6517402d3
375 changed files with 1775 additions and 1519 deletions

View File

@@ -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),
),
);
}
}

View File

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