hippofish/packages/backend/src/models/repositories/user-group-invitation.ts
syuilo 1c67c26bd8
refactor: migrate to typeorm 3.0 (#8443)
* wip

* wip

* wip

* Update following.ts

* wip

* wip

* wip

* Update resolve-user.ts

* maxQueryExecutionTime

* wip

* wip
2022-03-26 15:34:00 +09:00

22 lines
652 B
TypeScript

import { db } from '@/db/postgre.js';
import { UserGroupInvitation } from '@/models/entities/user-group-invitation.js';
import { UserGroups } from '../index.js';
export const UserGroupInvitationRepository = db.getRepository(UserGroupInvitation).extend({
async pack(
src: UserGroupInvitation['id'] | UserGroupInvitation,
) {
const invitation = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src });
return {
id: invitation.id,
group: await UserGroups.pack(invitation.userGroup || invitation.userGroupId),
};
},
packMany(
invitations: any[],
) {
return Promise.all(invitations.map(x => this.pack(x)));
},
});