check-before-audio-test.js 833 B

12345678910111213141516171819202122232425262728293031323334
  1. const { PrismaClient } = require('@prisma/client');
  2. const prisma = new PrismaClient();
  3. async function checkCurrentStatus() {
  4. console.log('\n📊 当前书籍状态:\n');
  5. const books = await prisma.book.findMany({
  6. orderBy: { id: 'asc' },
  7. select: {
  8. id: true,
  9. title: true,
  10. userId: true,
  11. _count: {
  12. select: { chapters: true }
  13. }
  14. }
  15. });
  16. // 统计"我的音频"书籍
  17. const myAudioCount = await prisma.book.count({
  18. where: { title: '我的音频' }
  19. });
  20. console.log(`现有书籍:${books.length}本`);
  21. console.log(`"我的音频"书籍:${myAudioCount}本\n`);
  22. books.forEach(book => {
  23. console.log(`- ${book.title} (ID:${book.id}, 章节:${book._count.chapters})`);
  24. });
  25. await prisma.$disconnect();
  26. }
  27. checkCurrentStatus().catch(console.error);