2018-11-01 18:59:40 -05:00
|
|
|
import db from '../db/mongodb';
|
|
|
|
|
|
|
|
const Emoji = db.get<IEmoji>('emoji');
|
2018-11-01 22:08:28 -05:00
|
|
|
Emoji.createIndex('name');
|
|
|
|
Emoji.createIndex('host');
|
2018-11-01 18:59:40 -05:00
|
|
|
Emoji.createIndex(['name', 'host'], { unique: true });
|
|
|
|
|
|
|
|
export default Emoji;
|
|
|
|
|
|
|
|
export type IEmoji = {
|
|
|
|
name: string;
|
|
|
|
host: string;
|
|
|
|
url: string;
|
|
|
|
aliases?: string[];
|
|
|
|
updatedAt?: Date;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const packEmojis = async (
|
|
|
|
host: string,
|
|
|
|
// MeiTODO: filter
|
|
|
|
) => {
|
2018-11-03 01:21:07 -05:00
|
|
|
return await Emoji.find({ host }, {
|
|
|
|
fields: {
|
|
|
|
_id: false
|
|
|
|
}
|
|
|
|
});
|
2018-11-01 18:59:40 -05:00
|
|
|
};
|