Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { db } from "../../db/postgre.js";
|
||||
import { Clip } from "../entities/clip.js";
|
||||
import { Users } from "../index.js";
|
||||
import { awaitAll } from "../../prelude/await-all.js";
|
||||
export const ClipRepository = db.getRepository(Clip).extend({
|
||||
async pack (src) {
|
||||
const clip = typeof src === "object" ? src : await this.findOneByOrFail({
|
||||
id: src
|
||||
});
|
||||
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
|
||||
});
|
||||
},
|
||||
packMany (clips) {
|
||||
return Promise.all(clips.map((x)=>this.pack(x)));
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user