import { EntityRepository , Repository } from 'typeorm' ; import { LoginLog } from '../models/LoginLog' ; @ EntityRepository ( LoginLog ) export class LoginLogRepository extends Repository < LoginLog > { public async logList ( limit ) { const query = await this . manager . createQueryBuilder ( LoginLog , 'LoginLog' ) ; query . select ( [ 'COUNT(LoginLog.id) as logcount' , 'DATE(created_date) as createdDate' ] ) ; query . groupBy ( 'createdDate' ) ; query . orderBy ( 'createdDate' , 'DESC' ) ; query . limit ( limit ) ; console . log ( query . getQuery ( ) ) ; return query . getRawMany ( ) ; } }