Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 20x 20x 20x 1x 1x 1x 20x 4x 4x 4x 4x 20x 3x 3x 3x 3x 20x | /**
* Services for the location type table.
* @packageDocumentation
*/
import { BaseService } from "./util";
/**
* Location type architecture.
*/
export interface LocationType {
id: number;
name: string;
}
/**
* Location type with only ID architecture.
*/
interface LocationTypeID {
id: number;
}
/**
* Location type with only name architecture.
*/
interface LocationTypeName {
name: string;
}
/**
* Location type services.
*/
export class LocationTypeService extends BaseService {
/**
* Get all locations.
*
* @returns All location types.
*/
public async getLocations(): Promise<LocationType[]> {
const sql = `SELECT * FROM LocationType ORDER BY id;`;
const rows: LocationType[] = await this.dbm.execute(sql);
return rows;
}
/**
* Get the name of a location by ID.
*
* @param locationID A location's ID.
* @returns The location's name.
*/
public async getLocationName(locationID: number): Promise<string> {
const sql = `SELECT name FROM LocationType WHERE id = ?;`;
const params = [locationID];
const rows: LocationTypeName[] = await this.dbm.execute(sql, params);
return rows[0]?.name;
}
/**
* Check if a location is valid.
*
* @param locationID A location's ID.
* @returns Whether or not the location is valid.
*/
public async validLocation(locationID: number): Promise<boolean> {
const sql = `SELECT id FROM LocationType WHERE id = ?;`;
const params = [locationID];
const rows: LocationTypeID[] = await this.dbm.execute(sql, params);
return rows.length > 0;
}
}
|