import { db } from "../../db/postgre.js";
import { PageLike } from "../entities/page-like.js";
import { Pages } from "../index.js";
export const PageLikeRepository = db.getRepository(PageLike).extend({
    async pack (src, me) {
        const like = typeof src === "object" ? src : await this.findOneByOrFail({
            id: src
        });
        return {
            id: like.id,
            page: await Pages.pack(like.page || like.pageId, me)
        };
    },
    packMany (likes, me) {
        return Promise.all(likes.map((x)=>this.pack(x, me)));
    }
});
