check-book2-chapters.js 649 B

1234567891011121314151617181920212223
  1. const { PrismaClient } = require('@prisma/client');
  2. const prisma = new PrismaClient();
  3. async function checkBook2Chapters() {
  4. const bookId = 2;
  5. const chapters = await prisma.bookChapter.findMany({
  6. where: { bookId, level: 1 },
  7. orderBy: { number: 'asc' },
  8. select: { id: true, number: true, title: true, status: true }
  9. });
  10. console.log(`bookId=${bookId} 的章列表:`);
  11. chapters.forEach(c => {
  12. console.log(` 章${c.number}: ${c.title.substring(0, 30)}... (status: ${c.status})`);
  13. });
  14. console.log(`\n总共: ${chapters.length} 章`);
  15. await prisma.$disconnect();
  16. }
  17. checkBook2Chapters().catch(console.error);