13 lines
512 B
TypeScript
13 lines
512 B
TypeScript
import { DataSource } from 'typeorm';
|
|
import { RoomEntity } from '../../../entities';
|
|
import { rowToRoom } from '../../mappers';
|
|
import { loadRoomRelationsMap } from '../../relations';
|
|
|
|
export async function handleGetAllRooms(dataSource: DataSource) {
|
|
const repo = dataSource.getRepository(RoomEntity);
|
|
const rows = await repo.find();
|
|
const relationsByRoomId = await loadRoomRelationsMap(dataSource, rows.map((row) => row.id));
|
|
|
|
return rows.map((row) => rowToRoom(row, relationsByRoomId.get(row.id)));
|
|
}
|