basic services joins
This commit is contained in:
parent
e404989a28
commit
fcbfe560c3
13 changed files with 75 additions and 26 deletions
|
@ -4,14 +4,15 @@ import DatabaseActionException from "../../../exceptions/databaseActionException
|
|||
|
||||
export default abstract class EquipmentService {
|
||||
/**
|
||||
* @description get all equipment types
|
||||
* @description get all equipment
|
||||
* @returns {Promise<Array<equipment>>}
|
||||
*/
|
||||
static async getAll(): Promise<Array<equipment>> {
|
||||
return await dataSource
|
||||
.getRepository(equipment)
|
||||
.createQueryBuilder("equipment")
|
||||
.orderBy("type", "ASC")
|
||||
.leftJoinAndSelect("equipment.equipmentType", "equipmenttype")
|
||||
.orderBy("name", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
|
@ -29,6 +30,7 @@ export default abstract class EquipmentService {
|
|||
return await dataSource
|
||||
.getRepository(equipment)
|
||||
.createQueryBuilder("equipment")
|
||||
.leftJoinAndSelect("equipment.equipmentType", "equipmenttype")
|
||||
.where({ id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue