Merge branch 'soru/query-single-room' into 'master'

add database.getRoom

See merge request famedly/famedlysdk!357
This commit is contained in:
Niklas Zender 2020-06-23 12:07:54 +00:00
commit 36cb6d63db
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;