modify entities according to NNBD models
Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -24,16 +24,16 @@ class Channels extends Table {
|
||||
DateTimeColumn get lastMessageAt => dateTime().nullable()();
|
||||
|
||||
/// The date of channel creation
|
||||
DateTimeColumn get createdAt => dateTime().nullable()();
|
||||
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
||||
|
||||
/// The date of the last channel update
|
||||
DateTimeColumn get updatedAt => dateTime().nullable()();
|
||||
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
|
||||
|
||||
/// The date of channel deletion
|
||||
DateTimeColumn get deletedAt => dateTime().nullable()();
|
||||
|
||||
/// The count of this channel members
|
||||
IntColumn get memberCount => integer().nullable()();
|
||||
IntColumn get memberCount => integer().withDefault(const Constant(0))();
|
||||
|
||||
/// The id of the user that created this channel
|
||||
TextColumn get createdById => text().nullable()();
|
||||
|
||||
@@ -21,22 +21,22 @@ class Members extends Table {
|
||||
DateTimeColumn get inviteRejectedAt => dateTime().nullable()();
|
||||
|
||||
/// True if the user has been invited to the channel
|
||||
BoolColumn get invited => boolean().nullable()();
|
||||
BoolColumn get invited => boolean().withDefault(const Constant(false))();
|
||||
|
||||
/// True if the member is banned from the channel
|
||||
BoolColumn get banned => boolean().nullable()();
|
||||
BoolColumn get banned => boolean().withDefault(const Constant(false))();
|
||||
|
||||
/// True if the member is shadow banned from the channel
|
||||
BoolColumn get shadowBanned => boolean().nullable()();
|
||||
BoolColumn get shadowBanned => boolean().withDefault(const Constant(false))();
|
||||
|
||||
/// True if the user is a moderator of the channel
|
||||
BoolColumn get isModerator => boolean().nullable()();
|
||||
BoolColumn get isModerator => boolean().withDefault(const Constant(false))();
|
||||
|
||||
/// The date of creation
|
||||
DateTimeColumn get createdAt => dateTime()();
|
||||
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
||||
|
||||
/// The last date of update
|
||||
DateTimeColumn get updatedAt => dateTime().nullable()();
|
||||
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
|
||||
|
||||
@override
|
||||
Set<Column> get primaryKey => {
|
||||
|
||||
@@ -15,19 +15,18 @@ class Messages extends Table {
|
||||
|
||||
/// The list of attachments, either provided by the user
|
||||
/// or generated from a command or as a result of URL scraping.
|
||||
TextColumn get attachments =>
|
||||
text().nullable().map(ListConverter<String>())();
|
||||
TextColumn get attachments => text().map(ListConverter<String>())();
|
||||
|
||||
/// The status of a sending message
|
||||
IntColumn get status =>
|
||||
integer().nullable().map(MessageSendingStatusConverter())();
|
||||
IntColumn get status => integer()
|
||||
.withDefault(const Constant(1))
|
||||
.map(MessageSendingStatusConverter())();
|
||||
|
||||
/// The message type
|
||||
TextColumn get type => text().nullable()();
|
||||
TextColumn get type => text().withDefault(const Constant('regular'))();
|
||||
|
||||
/// The list of user mentioned in the message
|
||||
TextColumn get mentionedUsers =>
|
||||
text().nullable().map(ListConverter<String>())();
|
||||
TextColumn get mentionedUsers => text().map(ListConverter<String>())();
|
||||
|
||||
/// A map describing the count of number of every reaction
|
||||
TextColumn get reactionCounts => text().nullable().map(MapConverter<int>())();
|
||||
@@ -48,16 +47,16 @@ class Messages extends Table {
|
||||
BoolColumn get showInChannel => boolean().nullable()();
|
||||
|
||||
/// If true the message is shadowed
|
||||
BoolColumn get shadowed => boolean().nullable()();
|
||||
BoolColumn get shadowed => boolean().withDefault(const Constant(false))();
|
||||
|
||||
/// A used command name.
|
||||
TextColumn get command => text().nullable()();
|
||||
|
||||
/// The DateTime when the message was created.
|
||||
DateTimeColumn get createdAt => dateTime()();
|
||||
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
||||
|
||||
/// The DateTime when the message was updated last time.
|
||||
DateTimeColumn get updatedAt => dateTime().nullable()();
|
||||
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
|
||||
|
||||
/// The DateTime when the message was deleted.
|
||||
DateTimeColumn get deletedAt => dateTime().nullable()();
|
||||
|
||||
@@ -16,10 +16,10 @@ class Reactions extends Table {
|
||||
TextColumn get type => text()();
|
||||
|
||||
/// The DateTime on which the reaction is created
|
||||
DateTimeColumn get createdAt => dateTime()();
|
||||
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
||||
|
||||
/// The score of the reaction (ie. number of reactions sent)
|
||||
IntColumn get score => integer().nullable()();
|
||||
IntColumn get score => integer().withDefault(const Constant(0))();
|
||||
|
||||
/// Reaction custom extraData
|
||||
TextColumn get extraData => text().nullable().map(MapConverter<Object>())();
|
||||
|
||||
@@ -15,7 +15,7 @@ class Reads extends Table {
|
||||
text().customConstraint('REFERENCES channels(cid) ON DELETE CASCADE')();
|
||||
|
||||
/// Number of unread messages
|
||||
IntColumn get unreadMessages => integer().nullable()();
|
||||
IntColumn get unreadMessages => integer().withDefault(const Constant(0))();
|
||||
|
||||
@override
|
||||
Set<Column> get primaryKey => {
|
||||
|
||||
@@ -12,19 +12,19 @@ class Users extends Table {
|
||||
TextColumn get role => text().nullable()();
|
||||
|
||||
/// Date of user creation
|
||||
DateTimeColumn get createdAt => dateTime().nullable()();
|
||||
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
||||
|
||||
/// Date of last user update
|
||||
DateTimeColumn get updatedAt => dateTime().nullable()();
|
||||
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
|
||||
|
||||
/// Date of last user connection
|
||||
DateTimeColumn get lastActive => dateTime().nullable()();
|
||||
|
||||
/// True if user is online
|
||||
BoolColumn get online => boolean().nullable()();
|
||||
BoolColumn get online => boolean().withDefault(const Constant(false))();
|
||||
|
||||
/// True if user is banned from the chat
|
||||
BoolColumn get banned => boolean().nullable()();
|
||||
BoolColumn get banned => boolean().withDefault(const Constant(false))();
|
||||
|
||||
/// Map of custom user extraData
|
||||
TextColumn get extraData => text().nullable().map(MapConverter<Object>())();
|
||||
|
||||
@@ -30,17 +30,15 @@ class StreamChatPersistenceClient extends ChatPersistenceClient {
|
||||
/// Connection mode on which the client will work
|
||||
ConnectionMode connectionMode = ConnectionMode.regular,
|
||||
Level logLevel = Level.WARNING,
|
||||
LogHandlerFunction logHandlerFunction,
|
||||
}) : assert(connectionMode != null, 'ConnectionMode cannot be null'),
|
||||
assert(logLevel != null, 'LogLevel cannot be null'),
|
||||
_connectionMode = connectionMode,
|
||||
LogHandlerFunction? logHandlerFunction,
|
||||
}) : _connectionMode = connectionMode,
|
||||
_logger = Logger.detached('💽')..level = logLevel {
|
||||
_logger.onRecord.listen(logHandlerFunction ?? _defaultLogHandler);
|
||||
}
|
||||
|
||||
/// [MoorChatDatabase] instance used by this client.
|
||||
@visibleForTesting
|
||||
MoorChatDatabase db;
|
||||
MoorChatDatabase? db;
|
||||
|
||||
final Logger _logger;
|
||||
final ConnectionMode _connectionMode;
|
||||
@@ -75,7 +73,7 @@ class StreamChatPersistenceClient extends ChatPersistenceClient {
|
||||
@override
|
||||
Future<void> connect(
|
||||
String userId, {
|
||||
DatabaseProvider databaseProvider, // Used only for testing
|
||||
DatabaseProvider? databaseProvider, // Used only for testing
|
||||
}) async {
|
||||
if (db != null) {
|
||||
throw Exception(
|
||||
@@ -330,13 +328,13 @@ class StreamChatPersistenceClient extends ChatPersistenceClient {
|
||||
_logger.info('Disconnecting');
|
||||
if (flush) {
|
||||
_logger.info('Flushing');
|
||||
await db.batch((batch) {
|
||||
db.allTables.forEach((table) {
|
||||
db.delete(table).go();
|
||||
await db!.batch((batch) {
|
||||
db!.allTables.forEach((table) {
|
||||
db!.delete(table).go();
|
||||
});
|
||||
});
|
||||
}
|
||||
await db.disconnect();
|
||||
await db!.disconnect();
|
||||
db = null;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user