2020-03-31 00:15:04 +00:00
|
|
|
import { EntityRepository, Repository } from 'typeorm';
|
2021-08-19 09:33:41 +00:00
|
|
|
import { Emoji } from '../entities/emoji.js';
|
2020-03-31 00:15:04 +00:00
|
|
|
|
|
|
|
@EntityRepository(Emoji)
|
|
|
|
export class EmojiRepository extends Repository<Emoji> {
|
|
|
|
public async pack(
|
|
|
|
src: Emoji['id'] | Emoji,
|
|
|
|
) {
|
2021-02-13 06:33:38 +00:00
|
|
|
const emoji = typeof src === 'object' ? src : await this.findOneOrFail(src);
|
2020-03-31 00:15:04 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
id: emoji.id,
|
|
|
|
aliases: emoji.aliases,
|
|
|
|
name: emoji.name,
|
|
|
|
category: emoji.category,
|
|
|
|
host: emoji.host,
|
|
|
|
url: emoji.url,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public packMany(
|
|
|
|
emojis: any[],
|
|
|
|
) {
|
|
|
|
return Promise.all(emojis.map(x => this.pack(x)));
|
|
|
|
}
|
|
|
|
}
|