check-books.js 480 B

12345678910111213141516171819
  1. const { PrismaClient } = require('@prisma/client');
  2. const prisma = new PrismaClient();
  3. async function checkBooks() {
  4. const books = await prisma.book.findMany({
  5. orderBy: { id: 'desc' },
  6. take: 3,
  7. include: { _count: { select: { chapters: true } } }
  8. });
  9. console.log('最新3本书:');
  10. books.forEach(b => {
  11. console.log(` id=${b.id}, title=${b.title}, status=${b.status}, chapters=${b._count.chapters}`);
  12. });
  13. await prisma.$disconnect();
  14. }
  15. checkBooks();