controller

This commit is contained in:
Julian Krauser 2025-06-02 13:14:09 +02:00
parent 9f2a08ccc9
commit 2609ecc1bf
17 changed files with 320 additions and 95 deletions

View file

@ -21,8 +21,7 @@ export async function getAllEquipments(req: Request, res: Response): Promise<any
let noLimit = req.query.noLimit === "true"; let noLimit = req.query.noLimit === "true";
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i); let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
//{ offset, count, search, noLimit, ids } let [equipments, total] = await EquipmentService.getAll({ offset, count, search, noLimit, ids });
let [equipments, total] = await EquipmentService.getAll();
res.json({ res.json({
equipments: equipments, equipments: equipments,
@ -45,6 +44,25 @@ export async function getEquipmentById(req: Request, res: Response): Promise<any
res.json(EquipmentFactory.mapToSingle(equipment)); res.json(EquipmentFactory.mapToSingle(equipment));
} }
/**
* @description get equipment by Ids
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function getEquipmentsByIds(req: Request, res: Response): Promise<any> {
let ids = req.body.ids as Array<string>;
let [equipments, total] = await EquipmentService.getAll({ noLimit: true, ids });
res.json({
equipments: EquipmentFactory.mapToBase(equipments),
total: total,
offset: 0,
count: total,
});
}
/** /**
* @description create equipment * @description create equipment
* @param req {Request} Express req object * @param req {Request} Express req object

View file

@ -21,8 +21,7 @@ export async function getAllEquipmentTypes(req: Request, res: Response): Promise
let noLimit = req.query.noLimit === "true"; let noLimit = req.query.noLimit === "true";
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i); let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
//{ offset, count, search, noLimit, ids } let [equipmentTypes, total] = await EquipmentTypeService.getAll({ offset, count, search, noLimit, ids });
let [equipmentTypes, total] = await EquipmentTypeService.getAll();
res.json({ res.json({
equipmentTypes: equipmentTypes, equipmentTypes: equipmentTypes,

View file

@ -19,12 +19,10 @@ export async function getAllInspectionsForRelated(req: Request, res: Response):
let relationId = req.params.relatedId as string; let relationId = req.params.relatedId as string;
let offset = parseInt((req.query.offset as string) ?? "0"); let offset = parseInt((req.query.offset as string) ?? "0");
let count = parseInt((req.query.count as string) ?? "25"); let count = parseInt((req.query.count as string) ?? "25");
let search = (req.query.search as string) ?? "";
let noLimit = req.query.noLimit === "true"; let noLimit = req.query.noLimit === "true";
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
//{ offset, count, search, noLimit, ids } let where = relation === "equipment" ? { equipmentId: relationId } : { vehicleId: relationId };
let [inspections, total] = await InspectionService.getAllForRelated({ equipmentId: relationId }); let [inspections, total] = await InspectionService.getAllForRelated(where, { offset, count, noLimit });
res.json({ res.json({
inspections: inspections, inspections: inspections,

View file

@ -23,8 +23,14 @@ export async function getAllInspectionPlansForRelated(req: Request, res: Respons
let noLimit = req.query.noLimit === "true"; let noLimit = req.query.noLimit === "true";
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i); let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
//{ offset, count, search, noLimit, ids } let where = relation === "equipment" ? { equipmentId: relationId } : { vehicleId: relationId };
let [inspectionPlans, total] = await InspectionPlanService.getAllForRelated({ equipmentId: relationId }); let [inspectionPlans, total] = await InspectionPlanService.getAllForRelated(where, {
offset,
count,
search,
noLimit,
ids,
});
res.json({ res.json({
inspectionPlans: inspectionPlans, inspectionPlans: inspectionPlans,

View file

@ -21,8 +21,7 @@ export async function getAllVehicles(req: Request, res: Response): Promise<any>
let noLimit = req.query.noLimit === "true"; let noLimit = req.query.noLimit === "true";
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i); let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
//{ offset, count, search, noLimit, ids } let [vehicles, total] = await VehicleService.getAll({ offset, count, search, noLimit, ids });
let [vehicles, total] = await VehicleService.getAll();
res.json({ res.json({
vehicles: vehicles, vehicles: vehicles,

View file

@ -21,8 +21,7 @@ export async function getAllVehicleTypes(req: Request, res: Response): Promise<a
let noLimit = req.query.noLimit === "true"; let noLimit = req.query.noLimit === "true";
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i); let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
//{ offset, count, search, noLimit, ids } let [vehicleTypes, total] = await VehicleTypeService.getAll({ offset, count, search, noLimit, ids });
let [vehicleTypes, total] = await VehicleTypeService.getAll();
res.json({ res.json({
vehicleTypes: vehicleTypes, vehicleTypes: vehicleTypes,

View file

@ -21,8 +21,7 @@ export async function getAllWearables(req: Request, res: Response): Promise<any>
let noLimit = req.query.noLimit === "true"; let noLimit = req.query.noLimit === "true";
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i); let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
//{ offset, count, search, noLimit, ids } let [wearables, total] = await WearableService.getAll({ offset, count, search, noLimit, ids });
let [wearables, total] = await WearableService.getAll();
res.json({ res.json({
wearables: wearables, wearables: wearables,

View file

@ -21,8 +21,7 @@ export async function getAllWearableTypes(req: Request, res: Response): Promise<
let noLimit = req.query.noLimit === "true"; let noLimit = req.query.noLimit === "true";
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i); let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
//{ offset, count, search, noLimit, ids } let [wearableTypes, total] = await WearableTypeService.getAll({ offset, count, search, noLimit, ids });
let [wearableTypes, total] = await WearableTypeService.getAll();
res.json({ res.json({
wearableTypes: wearableTypes, wearableTypes: wearableTypes,

View file

@ -5,6 +5,7 @@ import {
deleteEquipmentById, deleteEquipmentById,
getAllEquipments, getAllEquipments,
getEquipmentById, getEquipmentById,
getEquipmentsByIds,
updateEquipmentById, updateEquipmentById,
} from "../../../controller/admin/unit/equipmentController"; } from "../../../controller/admin/unit/equipmentController";
@ -18,6 +19,10 @@ router.get("/:id", async (req: Request, res: Response) => {
await getEquipmentById(req, res); await getEquipmentById(req, res);
}); });
router.post("/ids", async (req: Request, res: Response) => {
await getEquipmentsByIds(req, res);
});
router.post( router.post(
"/", "/",
PermissionHelper.passCheckMiddleware("create", "unit", "equipment"), PermissionHelper.passCheckMiddleware("create", "unit", "equipment"),

View file

@ -1,3 +1,4 @@
import { In, Like } from "typeorm";
import { dataSource } from "../../../data-source"; import { dataSource } from "../../../data-source";
import { equipment } from "../../../entity/unit/equipment/equipment"; import { equipment } from "../../../entity/unit/equipment/equipment";
import DatabaseActionException from "../../../exceptions/databaseActionException"; import DatabaseActionException from "../../../exceptions/databaseActionException";
@ -5,15 +6,45 @@ import DatabaseActionException from "../../../exceptions/databaseActionException
export default abstract class EquipmentService { export default abstract class EquipmentService {
/** /**
* @description get all equipment * @description get all equipment
* @returns {Promise<Array<equipment>>} * @returns {Promise<[Array<equipment>, number]>}
*/ */
static async getAll(): Promise<Array<equipment>> { static async getAll({
return await dataSource offset = 0,
count = 25,
search = "",
noLimit = false,
ids = [],
}: {
offset?: number;
count?: number;
search?: string;
noLimit?: boolean;
ids?: Array<string>;
}): Promise<[Array<equipment>, number]> {
let query = dataSource
.getRepository(equipment) .getRepository(equipment)
.createQueryBuilder("equipment") .createQueryBuilder("equipment")
.leftJoinAndSelect("equipment.equipmentType", "equipmenttype") .leftJoinAndSelect("equipment.equipmentType", "equipmenttype");
if (search != "") {
query = query.where({
code: Like(search),
name: Like(search),
location: Like(search),
});
}
if (ids.length != 0) {
query = query.where({ id: In(ids) });
}
if (!noLimit) {
query = query.offset(offset).limit(count);
}
return await query
.orderBy("name", "ASC") .orderBy("name", "ASC")
.getMany() .getManyAndCount()
.then((res) => { .then((res) => {
return res; return res;
}) })

View file

@ -1,3 +1,4 @@
import { Like, In } from "typeorm";
import { dataSource } from "../../../data-source"; import { dataSource } from "../../../data-source";
import { equipmentType } from "../../../entity/unit/equipment/equipmentType"; import { equipmentType } from "../../../entity/unit/equipment/equipmentType";
import DatabaseActionException from "../../../exceptions/databaseActionException"; import DatabaseActionException from "../../../exceptions/databaseActionException";
@ -5,14 +6,40 @@ import DatabaseActionException from "../../../exceptions/databaseActionException
export default abstract class EquipmentTypeService { export default abstract class EquipmentTypeService {
/** /**
* @description get all equipmentTypes * @description get all equipmentTypes
* @returns {Promise<Array<equipmentType>>} * @returns {Promise<[Array<equipmentType>, number]>}
*/ */
static async getAll(): Promise<Array<equipmentType>> { static async getAll({
return await dataSource offset = 0,
.getRepository(equipmentType) count = 25,
.createQueryBuilder("equipmentType") search = "",
noLimit = false,
ids = [],
}: {
offset?: number;
count?: number;
search?: string;
noLimit?: boolean;
ids?: Array<string>;
}): Promise<[Array<equipmentType>, number]> {
let query = dataSource.getRepository(equipmentType).createQueryBuilder("equipmentType");
if (search != "") {
query = query.where({
type: Like(search),
});
}
if (ids.length != 0) {
query = query.where({ id: In(ids) });
}
if (!noLimit) {
query = query.offset(offset).limit(count);
}
return await query
.orderBy("type", "ASC") .orderBy("type", "ASC")
.getMany() .getManyAndCount()
.then((res) => { .then((res) => {
return res; return res;
}) })

View file

@ -1,17 +1,12 @@
import { Like, In } from "typeorm";
import { dataSource } from "../../../data-source"; import { dataSource } from "../../../data-source";
import { inspectionPlan } from "../../../entity/unit/inspection/inspectionPlan"; import { inspectionPlan } from "../../../entity/unit/inspection/inspectionPlan";
import { DB_TYPE } from "../../../env.defaults"; import { DB_TYPE } from "../../../env.defaults";
import DatabaseActionException from "../../../exceptions/databaseActionException"; import DatabaseActionException from "../../../exceptions/databaseActionException";
export default abstract class InspectionPlanService { export default abstract class InspectionPlanService {
/** private static query = () =>
* @description get all inspectionPlans for related dataSource
* @returns {Promise<Array<inspectionPlan>>}
*/
static async getAllForRelated(
where: { equipmentId: string } | { vehicleId: string }
): Promise<Array<inspectionPlan>> {
return await dataSource
.getRepository(inspectionPlan) .getRepository(inspectionPlan)
.createQueryBuilder("inspectionPlan") .createQueryBuilder("inspectionPlan")
.leftJoinAndMapOne( .leftJoinAndMapOne(
@ -24,10 +19,47 @@ export default abstract class InspectionPlanService {
) )
.leftJoinAndSelect("latestVersionedPlan.inspectionPoints", "inspectionPoints") .leftJoinAndSelect("latestVersionedPlan.inspectionPoints", "inspectionPoints")
.leftJoinAndSelect("inspectionPlan.equipment", "equipment") .leftJoinAndSelect("inspectionPlan.equipment", "equipment")
.leftJoinAndSelect("inspectionPlan.vehicle", "vehicle") .leftJoinAndSelect("inspectionPlan.vehicle", "vehicle");
.where(where)
/**
* @description get all inspectionPlans for related
* @returns {Promise<[Array<inspectionPlan>, number]>}
*/
static async getAllForRelated(
where: { equipmentId: string } | { vehicleId: string },
{
offset = 0,
count = 25,
search = "",
noLimit = false,
ids = [],
}: {
offset?: number;
count?: number;
search?: string;
noLimit?: boolean;
ids?: Array<string>;
}
): Promise<[Array<inspectionPlan>, number]> {
let query = this.query().where(where);
if (search != "") {
query = query.where({
title: Like(search),
});
}
if (ids.length != 0) {
query = query.where({ id: In(ids) });
}
if (!noLimit) {
query = query.offset(offset).limit(count);
}
return await query
.orderBy("title", "ASC") .orderBy("title", "ASC")
.getMany() .getManyAndCount()
.then((res) => { .then((res) => {
return res; return res;
}) })
@ -41,20 +73,7 @@ export default abstract class InspectionPlanService {
* @returns {Promise<inspectionPlan>} * @returns {Promise<inspectionPlan>}
*/ */
static async getById(id: string): Promise<inspectionPlan> { static async getById(id: string): Promise<inspectionPlan> {
return await dataSource return await this.query()
.getRepository(inspectionPlan)
.createQueryBuilder("inspectionPlan")
.leftJoinAndMapOne(
"inspectionPlan.latestVersionedPlan",
"inspectionPlan.versionedPlans",
"latestVersionedPlan",
DB_TYPE == "postgres"
? 'latestVersionedPlan.inspectionPlanId = inspectionPlan.id AND latestVersionedPlan.version = (SELECT MAX("ivp"."start") FROM "inspection_versioned_plan" "ivp" WHERE "ivp"."inspectionPlanId" = "inspectionPlan"."id")'
: "latestVersionedPlan.inspectionPlanId = inspectionPlan.id AND latestVersionedPlan.version = (SELECT MAX(ivp.start) FROM inspection_versioned_plan ivp WHERE ivp.inspectionPlanId = inspectionPlan.id)"
)
.leftJoinAndSelect("latestVersionedPlan.inspectionPoints", "inspectionPoints")
.leftJoinAndSelect("inspectionPlan.equipment", "equipment")
.leftJoinAndSelect("inspectionPlan.vehicle", "vehicle")
.where({ id }) .where({ id })
.getOneOrFail() .getOneOrFail()
.then((res) => { .then((res) => {

View file

@ -3,12 +3,8 @@ import { inspection } from "../../../entity/unit/inspection/inspection";
import DatabaseActionException from "../../../exceptions/databaseActionException"; import DatabaseActionException from "../../../exceptions/databaseActionException";
export default abstract class InspectionService { export default abstract class InspectionService {
/** private static query = () =>
* @description get all inspections for related dataSource
* @returns {Promise<Array<inspection>>}
*/
static async getAllForRelated(where: { equipmentId: string } | { vehicleId: string }): Promise<Array<inspection>> {
return await dataSource
.getRepository(inspection) .getRepository(inspection)
.createQueryBuilder("inspection") .createQueryBuilder("inspection")
.leftJoinAndSelect("inspection.inspectionPlan", "inspectionPlan") .leftJoinAndSelect("inspection.inspectionPlan", "inspectionPlan")
@ -17,10 +13,33 @@ export default abstract class InspectionService {
.leftJoinAndSelect("inspection.pointResults", "pointResults") .leftJoinAndSelect("inspection.pointResults", "pointResults")
.leftJoinAndSelect("pointResults.inspectionPoint", "inspectionPoint") .leftJoinAndSelect("pointResults.inspectionPoint", "inspectionPoint")
.leftJoinAndSelect("inspection.equipment", "equipment") .leftJoinAndSelect("inspection.equipment", "equipment")
.leftJoinAndSelect("inspection.vehicle", "vehicle") .leftJoinAndSelect("inspection.vehicle", "vehicle");
.where(where)
/**
* @description get all inspections for related
* @returns {Promise<Array<inspection>>}
*/
static async getAllForRelated(
where: { equipmentId: string } | { vehicleId: string },
{
offset = 0,
count = 25,
noLimit = false,
}: {
offset?: number;
count?: number;
noLimit?: boolean;
}
): Promise<[Array<inspection>, number]> {
let query = this.query().where(where);
if (!noLimit) {
query = query.offset(offset).limit(count);
}
return await query
.orderBy("createdAt", "DESC") .orderBy("createdAt", "DESC")
.getMany() .getManyAndCount()
.then((res) => { .then((res) => {
return res; return res;
}) })
@ -34,16 +53,7 @@ export default abstract class InspectionService {
* @returns {Promise<inspection>} * @returns {Promise<inspection>}
*/ */
static async getById(id: string): Promise<inspection> { static async getById(id: string): Promise<inspection> {
return await dataSource return await this.query()
.getRepository(inspection)
.createQueryBuilder("inspection")
.leftJoinAndSelect("inspection.inspectionPlan", "inspectionPlan")
.leftJoinAndSelect("inspection.inspectionVersionedPlan", "inspectionVersionedPlan")
.leftJoinAndSelect("inspectionVersionedPlan.inspectionPoints", "inspectionPoints")
.leftJoinAndSelect("inspection.pointResults", "pointResults")
.leftJoinAndSelect("pointResults.inspectionPoint", "inspectionPoint")
.leftJoinAndSelect("inspection.equipment", "equipment")
.leftJoinAndSelect("inspection.vehicle", "vehicle")
.where({ id }) .where({ id })
.getOneOrFail() .getOneOrFail()
.then((res) => { .then((res) => {

View file

@ -1,3 +1,4 @@
import { Like, In } from "typeorm";
import { dataSource } from "../../../data-source"; import { dataSource } from "../../../data-source";
import { vehicle } from "../../../entity/unit/vehicle/vehicle"; import { vehicle } from "../../../entity/unit/vehicle/vehicle";
import DatabaseActionException from "../../../exceptions/databaseActionException"; import DatabaseActionException from "../../../exceptions/databaseActionException";
@ -5,15 +6,45 @@ import DatabaseActionException from "../../../exceptions/databaseActionException
export default abstract class VehicleService { export default abstract class VehicleService {
/** /**
* @description get all vehicles * @description get all vehicles
* @returns {Promise<Array<vehicle>>} * @returns {Promise<[Array<vehicle>, number]>}
*/ */
static async getAll(): Promise<Array<vehicle>> { static async getAll({
return await dataSource offset = 0,
count = 25,
search = "",
noLimit = false,
ids = [],
}: {
offset?: number;
count?: number;
search?: string;
noLimit?: boolean;
ids?: Array<string>;
}): Promise<[Array<vehicle>, number]> {
let query = dataSource
.getRepository(vehicle) .getRepository(vehicle)
.createQueryBuilder("vehicle") .createQueryBuilder("vehicle")
.leftJoinAndSelect("vehicle.vehicleType", "vehicletype") .leftJoinAndSelect("vehicle.vehicleType", "vehicletype");
if (search != "") {
query = query.where({
code: Like(search),
name: Like(search),
location: Like(search),
});
}
if (ids.length != 0) {
query = query.where({ id: In(ids) });
}
if (!noLimit) {
query = query.offset(offset).limit(count);
}
return await query
.orderBy("name", "ASC") .orderBy("name", "ASC")
.getMany() .getManyAndCount()
.then((res) => { .then((res) => {
return res; return res;
}) })

View file

@ -1,3 +1,4 @@
import { Like, In } from "typeorm";
import { dataSource } from "../../../data-source"; import { dataSource } from "../../../data-source";
import { vehicleType } from "../../../entity/unit/vehicle/vehicleType"; import { vehicleType } from "../../../entity/unit/vehicle/vehicleType";
import DatabaseActionException from "../../../exceptions/databaseActionException"; import DatabaseActionException from "../../../exceptions/databaseActionException";
@ -5,14 +6,40 @@ import DatabaseActionException from "../../../exceptions/databaseActionException
export default abstract class VehicleTypeService { export default abstract class VehicleTypeService {
/** /**
* @description get all vehicleTypes * @description get all vehicleTypes
* @returns {Promise<Array<vehicleType>>} * @returns {Promise<[Array<vehicleType>, number]>}
*/ */
static async getAll(): Promise<Array<vehicleType>> { static async getAll({
return await dataSource offset = 0,
.getRepository(vehicleType) count = 25,
.createQueryBuilder("vehicleType") search = "",
noLimit = false,
ids = [],
}: {
offset?: number;
count?: number;
search?: string;
noLimit?: boolean;
ids?: Array<string>;
}): Promise<[Array<vehicleType>, number]> {
let query = dataSource.getRepository(vehicleType).createQueryBuilder("vehicleType");
if (search != "") {
query = query.where({
type: Like(search),
});
}
if (ids.length != 0) {
query = query.where({ id: In(ids) });
}
if (!noLimit) {
query = query.offset(offset).limit(count);
}
return await query
.orderBy("type", "ASC") .orderBy("type", "ASC")
.getMany() .getManyAndCount()
.then((res) => { .then((res) => {
return res; return res;
}) })

View file

@ -1,3 +1,4 @@
import { Like, In } from "typeorm";
import { dataSource } from "../../../data-source"; import { dataSource } from "../../../data-source";
import { wearable } from "../../../entity/unit/wearable/wearable"; import { wearable } from "../../../entity/unit/wearable/wearable";
import DatabaseActionException from "../../../exceptions/databaseActionException"; import DatabaseActionException from "../../../exceptions/databaseActionException";
@ -5,16 +6,46 @@ import DatabaseActionException from "../../../exceptions/databaseActionException
export default abstract class WearableService { export default abstract class WearableService {
/** /**
* @description get all wearables * @description get all wearables
* @returns {Promise<Array<wearable>>} * @returns {Promise<[Array<wearable>, number]>}
*/ */
static async getAll(): Promise<Array<wearable>> { static async getAll({
return await dataSource offset = 0,
count = 25,
search = "",
noLimit = false,
ids = [],
}: {
offset?: number;
count?: number;
search?: string;
noLimit?: boolean;
ids?: Array<string>;
}): Promise<[Array<wearable>, number]> {
let query = dataSource
.getRepository(wearable) .getRepository(wearable)
.createQueryBuilder("wearable") .createQueryBuilder("wearable")
.leftJoinAndSelect("wearable.wearableType", "wearabletype") .leftJoinAndSelect("wearable.wearableType", "wearabletype")
.leftJoinAndSelect("wearable.wearer", "wearer") .leftJoinAndSelect("wearable.wearer", "wearer");
if (search != "") {
query = query.where({
code: Like(search),
name: Like(search),
location: Like(search),
});
}
if (ids.length != 0) {
query = query.where({ id: In(ids) });
}
if (!noLimit) {
query = query.offset(offset).limit(count);
}
return await query
.orderBy("name", "ASC") .orderBy("name", "ASC")
.getMany() .getManyAndCount()
.then((res) => { .then((res) => {
return res; return res;
}) })

View file

@ -1,3 +1,4 @@
import { In, Like } from "typeorm";
import { dataSource } from "../../../data-source"; import { dataSource } from "../../../data-source";
import { wearableType } from "../../../entity/unit/wearable/wearableType"; import { wearableType } from "../../../entity/unit/wearable/wearableType";
import DatabaseActionException from "../../../exceptions/databaseActionException"; import DatabaseActionException from "../../../exceptions/databaseActionException";
@ -5,14 +6,40 @@ import DatabaseActionException from "../../../exceptions/databaseActionException
export default abstract class WearableTypeService { export default abstract class WearableTypeService {
/** /**
* @description get all wearableTypes * @description get all wearableTypes
* @returns {Promise<Array<wearableType>>} * @returns {Promise<[Array<wearableType>, number]>}
*/ */
static async getAll(): Promise<Array<wearableType>> { static async getAll({
return await dataSource offset = 0,
.getRepository(wearableType) count = 25,
.createQueryBuilder("wearableType") search = "",
noLimit = false,
ids = [],
}: {
offset?: number;
count?: number;
search?: string;
noLimit?: boolean;
ids?: Array<string>;
}): Promise<[Array<wearableType>, number]> {
let query = dataSource.getRepository(wearableType).createQueryBuilder("wearableType");
if (search != "") {
query = query.where({
type: Like(search),
});
}
if (ids.length != 0) {
query = query.where({ id: In(ids) });
}
if (!noLimit) {
query = query.offset(offset).limit(count);
}
return await query
.orderBy("type", "ASC") .orderBy("type", "ASC")
.getMany() .getManyAndCount()
.then((res) => { .then((res) => {
return res; return res;
}) })