[Persistence] Add support for pinned messages

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-02-22 17:39:23 +05:30
parent 953a82c7bc
commit cf6ae8761e
17 changed files with 1759 additions and 9 deletions
@@ -1,5 +1,6 @@
export 'channels.dart';
export 'messages.dart';
export 'pinned_messages.dart';
export 'reactions.dart';
export 'users.dart';
export 'members.dart';
@@ -64,6 +64,18 @@ class Messages extends Table {
/// Id of the User who sent the message
TextColumn get userId => text().nullable()();
/// Whether the message is pinned or not
BoolColumn get pinned => boolean().withDefault(const Constant(false))();
/// The DateTime at which the message was pinned
DateTimeColumn get pinnedAt => dateTime().nullable()();
/// The DateTime on which the message pin expires
DateTimeColumn get pinExpires => dateTime().nullable()();
/// Id of the User who pinned the message
TextColumn get pinnedByUserId => text().nullable()();
/// The channel cid of which this message is part of
TextColumn get channelCid => text().nullable().customConstraint(
'NULLABLE REFERENCES channels(cid) ON DELETE CASCADE')();
@@ -0,0 +1,7 @@
import 'package:moor/moor.dart';
import 'messages.dart';
/// Represents a [PinnedMessages] table in [MoorChatDatabase].
@DataClassName('PinnedMessageEntity')
class PinnedMessages extends Messages {}