import { dataSource } from "../../data-source"; import { query } from "../../entity/settings/query"; import InternalException from "../../exceptions/internalException"; export default abstract class QueryStoreService { /** * @description get all queryStores * @returns {Promise>} */ static async getAll(): Promise> { return await dataSource .getRepository(query) .createQueryBuilder("queryStore") .orderBy("title", "ASC") .getMany() .then((res) => { return res; }) .catch((err) => { throw new InternalException("queryStores not found", err); }); } /** * @description get queryStore by id * @returns {Promise} */ static async getById(id: number): Promise { return await dataSource .getRepository(query) .createQueryBuilder("queryStore") .where("queryStore.id = :id", { id: id }) .getOneOrFail() .then((res) => { return res; }) .catch((err) => { throw new InternalException("queryStore not found by id", err); }); } }