001project_wildgrowth/backend/scripts/check-course-cover.ts

38 lines
997 B
TypeScript
Raw Permalink Normal View History

2026-02-11 15:26:03 +08:00
/**
* //
* 使用: npx ts-node scripts/check-course-cover.ts []
* : npx ts-node scripts/check-course-cover.ts
*/
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
const keyword = process.argv[2] || '产品思维';
const courses = await prisma.course.findMany({
where: {
deletedAt: null,
title: { contains: keyword, mode: 'insensitive' },
},
select: {
id: true,
title: true,
coverImage: true,
},
});
console.log(`\n课程标题含「${keyword}」的记录数: ${courses.length}\n`);
for (const c of courses) {
console.log('---');
console.log('id:', c.id);
console.log('title:', c.title);
console.log('cover_image:', c.coverImage ?? '(null)');
console.log('');
}
}
main()
.catch((e) => { console.error(e); process.exit(1); })
.finally(() => prisma.$disconnect());