members method
Returns the DtoChatMembers of the provided chatId
.
Implementation
Future<List<DtoChatMember>> members(ChatId chatId, {int? limit}) async {
final result = await safe(
(db) async {
final stmt = db.select(db.chatMembers).join([
innerJoin(db.users, db.users.id.equalsExp(db.chatMembers.userId)),
]);
stmt.where(db.chatMembers.chatId.equals(chatId.val));
stmt.orderBy([OrderingTerm.desc(db.chatMembers.joinedAt)]);
if (limit != null) {
stmt.limit(limit);
}
return (await stmt.get())
.map(
(rows) => _ChatMemberDb.fromDb(
rows.readTable(db.chatMembers),
rows.readTableOrNull(db.users),
),
)
.toList();
},
tag: 'chat_member.members($chatId, limit: $limit)',
exclusive: false,
);
return result ?? [];
}