| 12345678910111213141516171819202122232425262728293031323334353637 |
- const { PrismaClient } = require('@prisma/client');
- const prisma = new PrismaClient();
- async function checkBookFields() {
- try {
- const book = await prisma.book.findUnique({
- where: { id: 1 }
- });
- console.log('📖 Book ID=1 字段检查:');
- console.log(` title: ${book.title}`);
- console.log(` bookScale: ${book.bookScale}`);
- console.log(` description: ${book.description}`);
- console.log(` targetAudience: ${book.targetAudience}`);
- console.log(` style: ${book.style}`);
- console.log(` status: ${book.status}`);
- console.log('');
- if (!book.bookScale) {
- console.log('⚠️ bookScale为空,需要设置默认值');
- await prisma.book.update({
- where: { id: 1 },
- data: {
- bookScale: '标准教程'
- }
- });
- console.log('✅ 已设置 bookScale = 标准教程');
- }
- } catch (error) {
- console.error('错误:', error);
- } finally {
- await prisma.$disconnect();
- }
- }
- checkBookFields();
|