clean-my-audio-books.js 717 B

12345678910111213141516171819202122232425
  1. const { PrismaClient } = require('@prisma/client');
  2. const prisma = new PrismaClient();
  3. async function cleanMyAudioBooks() {
  4. console.log('\n🧹 清理错误的"我的音频"书籍...\n');
  5. // 删除所有标题为"我的音频"且章节数为1的书籍
  6. const result = await prisma.book.deleteMany({
  7. where: {
  8. title: '我的音频',
  9. description: '我的语音合成音频收藏',
  10. chapters: {
  11. none: {
  12. level: { gt: 1 } // 没有level>1的章节(说明不是正常的书籍)
  13. }
  14. }
  15. }
  16. });
  17. console.log(`✅ 已删除 ${result.count} 本错误的"我的音频"书籍\n`);
  18. await prisma.$disconnect();
  19. }
  20. cleanMyAudioBooks().catch(console.error);