add database.getRoom

This commit is contained in:
Sorunome 2020-06-23 13:35:22 +02:00
parent 5a57c886ae
commit 1a9f6e38dc
No known key found for this signature in database
GPG key ID: B19471D07FC9BE9C
2 changed files with 24 additions and 0 deletions

View file

@ -5406,6 +5406,29 @@ abstract class _$Database extends GeneratedDatabase {
);
}
DbRoom _rowToDbRoom(QueryRow row) {
return DbRoom(
clientId: row.readInt('client_id'),
roomId: row.readString('room_id'),
membership: row.readString('membership'),
highlightCount: row.readInt('highlight_count'),
notificationCount: row.readInt('notification_count'),
prevBatch: row.readString('prev_batch'),
joinedMemberCount: row.readInt('joined_member_count'),
invitedMemberCount: row.readInt('invited_member_count'),
newestSortOrder: row.readDouble('newest_sort_order'),
oldestSortOrder: row.readDouble('oldest_sort_order'),
heroes: row.readString('heroes'),
);
}
Selectable<DbRoom> getRoom(int client_id, String room_id) {
return customSelect(
'SELECT * FROM rooms WHERE client_id = :client_id AND room_id = :room_id',
variables: [Variable.withInt(client_id), Variable.withString(room_id)],
readsFrom: {rooms}).map(_rowToDbRoom);
}
Selectable<DbEvent> getEvent(int client_id, String event_id, String room_id) {
return customSelect(
'SELECT * FROM events WHERE client_id = :client_id AND event_id = :event_id AND room_id = :room_id',

View file

@ -190,6 +190,7 @@ dbGetUser: SELECT * FROM room_states WHERE client_id = :client_id AND type = 'm.
dbGetEventList: SELECT * FROM events WHERE client_id = :client_id AND room_id = :room_id GROUP BY event_id ORDER BY sort_order DESC;
getStates: SELECT * FROM room_states WHERE client_id = :client_id AND room_id = :room_id;
resetNotificationCount: UPDATE rooms SET notification_count = 0, highlight_count = 0 WHERE client_id = :client_id AND room_id = :room_id;
getRoom: SELECT * FROM rooms WHERE client_id = :client_id AND room_id = :room_id;
getEvent: SELECT * FROM events WHERE client_id = :client_id AND event_id = :event_id AND room_id = :room_id;
removeEvent: DELETE FROM events WHERE client_id = :client_id AND event_id = :event_id AND room_id = :room_id;
removeRoom: DELETE FROM rooms WHERE client_id = :client_id AND room_id = :room_id;