[LLC, Persistence] Add doc comments

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-01-28 19:48:54 +05:30
parent 6e5894eebe
commit 86a122aa23
30 changed files with 154 additions and 68 deletions
@@ -7,11 +7,11 @@ import '../mapper/mapper.dart';
part 'channel_dao.g.dart';
///
/// The Data Access Object for operations in [Channels] table.
@UseDao(tables: [Channels, Users])
class ChannelDao extends DatabaseAccessor<MoorChatDatabase>
with _$ChannelDaoMixin {
///
/// Creates a new channel dao instance
ChannelDao(MoorChatDatabase db) : super(db);
/// Get channel by cid
@@ -44,7 +44,7 @@ class ChannelDao extends DatabaseAccessor<MoorChatDatabase>
.get();
}
///
/// Updates all the channels using the new [channelList] data
Future<void> updateChannels(List<ChannelModel> channelList) {
return batch(
(it) => it.insertAll(
@@ -10,11 +10,11 @@ import '../mapper/mapper.dart';
part 'channel_query_dao.g.dart';
///
/// The Data Access Object for operations in [ChannelQueries] table.
@UseDao(tables: [ChannelQueries, Channels, Users])
class ChannelQueryDao extends DatabaseAccessor<MoorChatDatabase>
with _$ChannelQueryDaoMixin {
///
/// Creates a new channel query dao instance
ChannelQueryDao(this._db) : super(_db);
final MoorChatDatabase _db;
@@ -7,11 +7,11 @@ import '../mapper/mapper.dart';
part 'connection_event_dao.g.dart';
///
/// The Data Access Object for operations in [ConnectionEvents] table.
@UseDao(tables: [ConnectionEvents, Users])
class ConnectionEventDao extends DatabaseAccessor<MoorChatDatabase>
with _$ConnectionEventDaoMixin {
///
/// Creates a new connection event dao instance
ConnectionEventDao(MoorChatDatabase db) : super(db);
/// Get the latest stored connection event
@@ -9,11 +9,11 @@ import '../mapper/mapper.dart';
part 'member_dao.g.dart';
///
/// The Data Access Object for operations in [Members] table.
@UseDao(tables: [Members, Users])
class MemberDao extends DatabaseAccessor<MoorChatDatabase>
with _$MemberDaoMixin {
///
/// Creates a new member dao instance
MemberDao(MoorChatDatabase db) : super(db);
/// Get all members where [members.channelCid] matches [cid]
@@ -30,7 +30,7 @@ class MemberDao extends DatabaseAccessor<MoorChatDatabase>
}).get();
}
///
/// Updates all the members using the new [memberList] data
Future<void> updateMembers(String cid, List<Member> memberList) async {
return batch(
(it) => it.insertAll(
@@ -7,11 +7,11 @@ import '../mapper/mapper.dart';
part 'message_dao.g.dart';
///
/// The Data Access Object for operations in [Messages] table.
@UseDao(tables: [Messages, Users])
class MessageDao extends DatabaseAccessor<MoorChatDatabase>
with _$MessageDaoMixin {
///
/// Creates a new message dao instance
MessageDao(this._db) : super(_db);
final MoorChatDatabase _db;
@@ -52,7 +52,7 @@ class MessageDao extends DatabaseAccessor<MoorChatDatabase>
);
}
///
/// Returns a single message by matching the [messages.id] with [id]
Future<Message> getMessageById(String id) async {
return await (select(messages).join([
leftOuterJoin(users, messages.userId.equalsExp(users.id)),
@@ -62,7 +62,8 @@ class MessageDao extends DatabaseAccessor<MoorChatDatabase>
.getSingle();
}
///
/// Returns all the messages of a particular thread by matching
/// [messages.channelCid] with [cid]
Future<List<Message>> getThreadMessages(String cid) async {
return Future.wait(await (select(messages).join([
leftOuterJoin(users, messages.userId.equalsExp(users.id)),
@@ -74,7 +75,8 @@ class MessageDao extends DatabaseAccessor<MoorChatDatabase>
.get());
}
///
/// Returns all the messages of a particular thread by matching
/// [messages.parentId] with [parentId]
Future<List<Message>> getThreadMessagesByParentId(
String parentId, {
String lessThan,
@@ -94,7 +96,8 @@ class MessageDao extends DatabaseAccessor<MoorChatDatabase>
return msgList;
}
///
/// Returns all the messages of a channel by matching
/// [messages.channelCid] with [parentId]
Future<List<Message>> getMessagesByCid(
String cid, {
PaginationParams messagePagination,
@@ -131,7 +134,8 @@ class MessageDao extends DatabaseAccessor<MoorChatDatabase>
return msgList;
}
///
/// Updates the message data of a particular channel with
/// the new [messageList] data
Future<void> updateMessages(String cid, List<Message> messageList) {
return batch((batch) {
batch.insertAll(
@@ -7,14 +7,15 @@ import '../mapper/mapper.dart';
part 'reaction_dao.g.dart';
///
/// The Data Access Object for operations in [Reactions] table.
@UseDao(tables: [Reactions, Users])
class ReactionDao extends DatabaseAccessor<MoorChatDatabase>
with _$ReactionDaoMixin {
///
/// Creates a new reaction dao instance
ReactionDao(MoorChatDatabase db) : super(db);
///
/// Returns all the reactions of a particular message by matching
/// [reactions.messageId] with [messageId]
Future<List<Reaction>> getReactions(String messageId) {
return (select(reactions).join([
leftOuterJoin(users, reactions.userId.equalsExp(users.id)),
@@ -28,7 +29,10 @@ class ReactionDao extends DatabaseAccessor<MoorChatDatabase>
}).get();
}
///
/// Returns all the reactions of a particular message
/// added by a particular user by matching
/// [reactions.messageId] with [messageId] and
/// [reactions.userId] with [userId]
Future<List<Reaction>> getReactionsByUserId(
String messageId,
String userId,
@@ -37,7 +41,7 @@ class ReactionDao extends DatabaseAccessor<MoorChatDatabase>
return reactions.where((it) => it.userId == userId).toList();
}
///
/// Updates the reactions data with the new [reactionList] data
Future<void> updateReactions(List<Reaction> reactionList) {
return batch((it) {
it.insertAll(
@@ -7,10 +7,10 @@ import '../mapper/mapper.dart';
part 'read_dao.g.dart';
///
/// The Data Access Object for operations in [Reads] table.
@UseDao(tables: [Reads, Users])
class ReadDao extends DatabaseAccessor<MoorChatDatabase> with _$ReadDaoMixin {
///
/// Creates a new read dao instance
ReadDao(MoorChatDatabase db) : super(db);
/// Get all reads where [reads.channelCid] matches [cid]
@@ -29,7 +29,8 @@ class ReadDao extends DatabaseAccessor<MoorChatDatabase> with _$ReadDaoMixin {
}).get();
}
///
/// Updates the read data of a particular channel with
/// the new [readList] data
Future<void> updateReads(String cid, List<Read> readList) {
return batch(
(it) => it.insertAll(
@@ -6,13 +6,13 @@ import '../mapper/user_mapper.dart';
part 'user_dao.g.dart';
///
/// The Data Access Object for operations in [Users] table.
@UseDao(tables: [Users])
class UserDao extends DatabaseAccessor<MoorChatDatabase> with _$UserDaoMixin {
///
/// Creates a new user dao instance
UserDao(MoorChatDatabase db) : super(db);
///
/// Updates the users data with the new [userList] data
Future<void> updateUsers(List<User> userList) {
return batch(
(it) => it.insertAll(