| 123456789101112131415161718192021 |
- const { prisma } = require('../src/models');
- async function main() {
- const types = await prisma.aiCallLog.groupBy({
- by: ['callType'],
- _count: { id: true },
- });
- types.sort((a: any, b: any) => b._count.id - a._count.id);
- console.log('=== AiCallLog 所有 callType ===');
- for (const t of types) {
- console.log(` ${t.callType.padEnd(30)} | ${t._count.id} 次`);
- }
-
- // Also check earliest/latest
- const first = await prisma.aiCallLog.findFirst({ orderBy: { createdAt: 'asc' }, select: { createdAt: true } });
- const last = await prisma.aiCallLog.findFirst({ orderBy: { createdAt: 'desc' }, select: { createdAt: true } });
- console.log(`\n 最早记录: ${first?.createdAt}`);
- console.log(` 最新记录: ${last?.createdAt}`);
-
- await prisma.$disconnect();
- }
- main().catch(e => { console.error(e); process.exit(1); });
|