wip: clip
This commit is contained in:
parent
f0d0a1546a
commit
cac99ebdd4
2 changed files with 25 additions and 2 deletions
|
@ -2,6 +2,8 @@ import { EntityRepository, Repository } from 'typeorm';
|
|||
import { Clip } from '../entities/clip';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { SchemaType } from '../../misc/schema';
|
||||
import { Users } from '..';
|
||||
import { awaitAll } from '../../prelude/await-all';
|
||||
|
||||
export type PackedClip = SchemaType<typeof packedClipSchema>;
|
||||
|
||||
|
@ -12,14 +14,15 @@ export class ClipRepository extends Repository<Clip> {
|
|||
): Promise<PackedClip> {
|
||||
const clip = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||
|
||||
return {
|
||||
return await awaitAll({
|
||||
id: clip.id,
|
||||
createdAt: clip.createdAt.toISOString(),
|
||||
userId: clip.userId,
|
||||
user: Users.pack(clip.user || clip.userId),
|
||||
name: clip.name,
|
||||
description: clip.description,
|
||||
isPublic: clip.isPublic,
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +48,11 @@ export const packedClipSchema = {
|
|||
optional: false as const, nullable: false as const,
|
||||
format: 'id',
|
||||
},
|
||||
user: {
|
||||
type: 'object' as const,
|
||||
ref: 'User',
|
||||
optional: false as const, nullable: false as const,
|
||||
},
|
||||
name: {
|
||||
type: 'string' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue