| 12345678910111213141516171819202122232425262728293031323334 |
- const { PrismaClient } = require('@prisma/client');
- const prisma = new PrismaClient();
- async function checkStatus() {
- const book = await prisma.book.findUnique({
- where: { id: 1 },
- include: { chapters: true }
- });
-
- if (!book) {
- console.log('书籍不存在');
- return;
- }
-
- const level1 = book.chapters.filter(c => c.level === 1).length;
- const level2 = book.chapters.filter(c => c.level === 2).length;
- const level3 = book.chapters.filter(c => c.level === 3).length;
-
- console.log(`状态: ${book.status}`);
- console.log(`进度: ${book.progress}%`);
- console.log(`章: ${level1}, 节: ${level2}, 小节: ${level3}`);
- console.log(`总计: ${book.chapters.length} 条记录`);
-
- if (level1 > 0) {
- console.log('\n章节列表:');
- book.chapters.filter(c => c.level === 1).forEach(c => {
- console.log(` - 第${c.number}章: ${c.title} [${c.status}]`);
- });
- }
-
- await prisma.$disconnect();
- }
- checkStatus().catch(console.error);
|