diff --git a/lib/src/database/database.g.dart b/lib/src/database/database.g.dart index 9b86794..488dee4 100644 --- a/lib/src/database/database.g.dart +++ b/lib/src/database/database.g.dart @@ -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 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 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', diff --git a/lib/src/database/database.moor b/lib/src/database/database.moor index 073a71f..20db688 100644 --- a/lib/src/database/database.moor +++ b/lib/src/database/database.moor @@ -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;