const { PrismaClient } = require('@prisma/client'); const p = new PrismaClient(); (async () => { // 1. book 43 真实状态 const b = await p.book.findUnique({ where: { id: 43 }, select: { id: true, title: true, userId: true, genStage: true, failedStage: true, errorMsg: true, progress: true, totalChapters: true, updatedAt: true, createdAt: true }, }); console.log('=== book 43 ==='); console.log(JSON.stringify(b, null, 2)); // 2. book 43 的章节 const chapters = await p.bookChapter.findMany({ where: { bookId: 43 }, select: { id: true, number: true, title: true, level: true, genStage: true, contentStatus: true, contentError: true, contentLength: true }, }); console.log('\n=== chapters ==='); console.log(JSON.stringify(chapters, null, 2)); // 3. 全部 failed 状态的书(按时间倒序) const failed = await p.book.findMany({ where: { OR: [{ genStage: 'failed' }, { failedStage: { not: null } }] }, select: { id: true, title: true, userId: true, genStage: true, failedStage: true, errorMsg: true, progress: true, totalChapters: true, updatedAt: true }, orderBy: { updatedAt: 'desc' }, take: 10, }); console.log('\n=== failed books (latest 10) ==='); failed.forEach(bk => console.log(JSON.stringify(bk))); // 4. 找 errorMsg 含 "Request timed out" 的所有书 const t = await p.book.findMany({ where: { errorMsg: { contains: 'Request timed out' } }, select: { id: true, title: true, userId: true, genStage: true, failedStage: true, errorMsg: true, updatedAt: true }, orderBy: { updatedAt: 'desc' }, }); console.log('\n=== books with "Request timed out" in errorMsg ==='); t.forEach(bk => console.log(JSON.stringify(bk))); await p.$disconnect(); })();