refactor(persistence): Align message entity with StreamChat.

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2023-06-17 06:18:23 +05:30
committed by xsahil03x
parent 3509945021
commit 517154cc8f
9 changed files with 580 additions and 257 deletions
@@ -53,14 +53,52 @@ class Messages extends Table {
/// A used command name.
TextColumn get command => text().nullable()();
/// The DateTime when the message was created.
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
/// The DateTime on which the message was created.
///
/// Returns the latest between [localCreatedAt] and [remoteCreatedAt].
/// If both are null, returns [currentDateAndTime].
Expression<DateTime> get createdAt {
return coalesce<DateTime>(
[localCreatedAt, remoteCreatedAt, currentDateAndTime],
);
}
/// The DateTime when the message was updated last time.
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
/// The DateTime on which the message was created on the client.
DateTimeColumn get localCreatedAt => dateTime().nullable()();
/// The DateTime when the message was deleted.
DateTimeColumn get deletedAt => dateTime().nullable()();
/// The DateTime on which the message was created on the server.
DateTimeColumn get remoteCreatedAt => dateTime().nullable()();
/// The DateTime on which the message was updated last time.
///
/// Returns the latest between [localUpdatedAt] and [remoteUpdatedAt].
/// If both are null, returns [createdAt].
Expression<DateTime> get updatedAt {
return coalesce<DateTime>(
[localUpdatedAt, remoteUpdatedAt, createdAt],
);
}
/// The DateTime on which the message was updated on the client.
DateTimeColumn get localUpdatedAt => dateTime().nullable()();
/// The DateTime on which the message was updated on the server.
DateTimeColumn get remoteUpdatedAt => dateTime().nullable()();
/// The DateTime on which the message was deleted.
///
/// Returns the latest between [localDeletedAt] and [remoteDeletedAt].
Expression<DateTime> get deletedAt {
return coalesce<DateTime>(
[localDeletedAt, remoteDeletedAt],
);
}
/// The DateTime on which the message was deleted on the client.
DateTimeColumn get localDeletedAt => dateTime().nullable()();
/// The DateTime on which the message was deleted on the server.
DateTimeColumn get remoteDeletedAt => dateTime().nullable()();
/// Id of the User who sent the message
TextColumn get userId => text().nullable()();