1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-20 01:29:02 +09:00
misskey/src/misc/count-same-renotes.ts
2020-05-10 17:25:16 +09:00

16 lines
570 B
TypeScript

import { Notes } from '../models';
export async function countSameRenotes(userId: string, renoteId: string, excludeNoteId: string | undefined): Promise<number> {
// 指定したユーザーの指定したノートのリノートがいくつあるか数える
const query = Notes.createQueryBuilder('note')
.where('note.userId = :userId', { userId })
.andWhere('note.renoteId = :renoteId', { renoteId });
// 指定した投稿を除く
if (excludeNoteId) {
query.andWhere('note.id != :excludeNoteId', { excludeNoteId });
}
return await query.getCount();
}