style: Apply team linter in stream chat persistence (#331)
* lint(persistence): Apply team linter Signed-off-by: Sahil Kumar <[email protected]> * style: flutter format Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
@@ -3,7 +3,7 @@ import 'package:stream_chat/stream_chat.dart';
|
||||
import 'package:stream_chat_persistence/src/db/moor_chat_database.dart';
|
||||
import 'package:stream_chat_persistence/src/entity/reads.dart';
|
||||
import 'package:stream_chat_persistence/src/entity/users.dart';
|
||||
import '../mapper/mapper.dart';
|
||||
import 'package:stream_chat_persistence/src/mapper/mapper.dart';
|
||||
|
||||
part 'read_dao.g.dart';
|
||||
|
||||
@@ -14,30 +14,26 @@ class ReadDao extends DatabaseAccessor<MoorChatDatabase> with _$ReadDaoMixin {
|
||||
ReadDao(MoorChatDatabase db) : super(db);
|
||||
|
||||
/// Get all reads where [Reads.channelCid] matches [cid]
|
||||
Future<List<Read>> getReadsByCid(String cid) async {
|
||||
return (select(reads).join([
|
||||
leftOuterJoin(users, reads.userId.equalsExp(users.id)),
|
||||
])
|
||||
..where(reads.channelCid.equals(cid))
|
||||
..orderBy([
|
||||
OrderingTerm.asc(reads.lastRead),
|
||||
]))
|
||||
.map((row) {
|
||||
final userEntity = row.readTable(users);
|
||||
final readEntity = row.readTable(reads);
|
||||
return readEntity.toRead(user: userEntity?.toUser());
|
||||
}).get();
|
||||
}
|
||||
Future<List<Read>> getReadsByCid(String cid) async => (select(reads).join([
|
||||
leftOuterJoin(users, reads.userId.equalsExp(users.id)),
|
||||
])
|
||||
..where(reads.channelCid.equals(cid))
|
||||
..orderBy([
|
||||
OrderingTerm.asc(reads.lastRead),
|
||||
]))
|
||||
.map((row) {
|
||||
final userEntity = row.readTable(users);
|
||||
final readEntity = row.readTable(reads);
|
||||
return readEntity.toRead(user: userEntity?.toUser());
|
||||
}).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(
|
||||
reads,
|
||||
readList.map((r) => r.toEntity(cid: cid)).toList(),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
),
|
||||
);
|
||||
}
|
||||
Future<void> updateReads(String cid, List<Read> readList) => batch(
|
||||
(it) => it.insertAll(
|
||||
reads,
|
||||
readList.map((r) => r.toEntity(cid: cid)).toList(),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user