import { dataSource } from "../data-source"; import { membershipStatus } from "../entity/membershipStatus"; import { user } from "../entity/user"; import InternalException from "../exceptions/internalException"; export default abstract class MembershipStatusService { /** * @description get all membershipStatuss * @returns {Promise>} */ static async getAll(): Promise> { return await dataSource .getRepository(membershipStatus) .createQueryBuilder("membershipStatus") .getMany() .then((res) => { return res; }) .catch((err) => { throw new InternalException("membershipStatuss not found", err); }); } /** * @description get membershipStatus by id * @returns {Promise} */ static async getById(id: number): Promise { return await dataSource .getRepository(membershipStatus) .createQueryBuilder("membershipStatus") .andWhere("membershipStatus.id = :id", { id: id }) .getOneOrFail() .then((res) => { return res; }) .catch((err) => { throw new InternalException("membershipStatus not found by id", err); }); } // /** // * @description get members assigned to membershipStatus // * @returns {Promise>} // */ // static async getMembersBymembershipStatusId(id: number): Promise> { // return await dataSource // .getRepository(membershipStatus) // .createQueryBuilder("membershipStatus") // .leftJoinAndSelect("membershipStatus.members", "members") // .andWhere("membershipStatus.id = :id", { id: id }) // .getOneOrFail() // .then((res) => { // return []; // }) // .catch((err) => { // throw new InternalException("membershipStatus assigned members not found by id", err); // }); // } }