user-group

This commit is contained in:
tamaina 2021-09-12 22:40:51 +09:00
parent d7488715df
commit 3eb79b23bc

View file

@ -1,15 +1,13 @@
import { EntityRepository, Repository } from 'typeorm'; import { EntityRepository, Repository } from 'typeorm';
import { UserGroup } from '@/models/entities/user-group'; import { UserGroup } from '@/models/entities/user-group';
import { UserGroupJoinings } from '../index'; import { UserGroupJoinings } from '../index';
import { SchemaType } from '@/misc/schema'; import { Packed } from '@/misc/schema';
export type PackedUserGroup = SchemaType<typeof packedUserGroupSchema>;
@EntityRepository(UserGroup) @EntityRepository(UserGroup)
export class UserGroupRepository extends Repository<UserGroup> { export class UserGroupRepository extends Repository<UserGroup> {
public async pack( public async pack(
src: UserGroup['id'] | UserGroup, src: UserGroup['id'] | UserGroup,
): Promise<PackedUserGroup> { ): Promise<Packed<'UserGroup'>> {
const userGroup = typeof src === 'object' ? src : await this.findOneOrFail(src); const userGroup = typeof src === 'object' ? src : await this.findOneOrFail(src);
const users = await UserGroupJoinings.find({ const users = await UserGroupJoinings.find({