This commit is contained in:
tamaina 2021-09-12 22:57:23 +09:00
parent 4dfebbd0fe
commit 2c7daf8f0e
1 changed files with 2 additions and 4 deletions

View File

@ -1,19 +1,17 @@
import { EntityRepository, Repository } from 'typeorm'; import { EntityRepository, Repository } from 'typeorm';
import { Page } from '@/models/entities/page'; import { Page } from '@/models/entities/page';
import { SchemaType } from '@/misc/schema'; import { Packed } from '@/misc/schema';
import { Users, DriveFiles, PageLikes } from '../index'; import { Users, DriveFiles, PageLikes } from '../index';
import { awaitAll } from '@/prelude/await-all'; import { awaitAll } from '@/prelude/await-all';
import { DriveFile } from '@/models/entities/drive-file'; import { DriveFile } from '@/models/entities/drive-file';
import { User } from '@/models/entities/user'; import { User } from '@/models/entities/user';
export type PackedPage = SchemaType<typeof packedPageSchema>;
@EntityRepository(Page) @EntityRepository(Page)
export class PageRepository extends Repository<Page> { export class PageRepository extends Repository<Page> {
public async pack( public async pack(
src: Page['id'] | Page, src: Page['id'] | Page,
me?: { id: User['id'] } | null | undefined, me?: { id: User['id'] } | null | undefined,
): Promise<PackedPage> { ): Promise<Packed<'Page'>> {
const meId = me ? me.id : null; const meId = me ? me.id : null;
const page = typeof src === 'object' ? src : await this.findOneOrFail(src); const page = typeof src === 'object' ? src : await this.findOneOrFail(src);