chinak2 / server /scripts /check_db_mojibake.js
shanshel6
Release v1.0.32: Fix scraper navigation, logs, 500 error, and bump version
8395368
Raw History Blame Contribute Delete
1.34 kB
import { PrismaClient } from '@prisma/client';
import fs from 'fs';
const prisma = new PrismaClient();
async function checkDb() {
const products = await prisma.product.findMany({
take: 5,
where: {
OR: [
{ specs: { contains: 'ط§ظ„ظ…ط§ط±ظƒط©' } },
{ specs: { contains: 'الماركة' } }
]
}
});
const options = await prisma.productOption.findMany({
take: 5,
where: {
OR: [
{ name: { contains: 'ط§ظ„ظ…ط§ط±ظƒط©' } },
{ name: { contains: 'الماركة' } }
]
}
});
let output = "DB Check Results:\n";
output += `Found ${products.length} products with relevant specs.\n`;
products.forEach(p => {
output += `Product ID: ${p.id}, Name: ${p.name}\nSpecs: ${p.specs}\n\n`;
});
output += `Found ${options.length} options with relevant names.\n`;
options.forEach(o => {
output += `Option ID: ${o.id}, Name: ${o.name}\nValues: ${o.values}\n\n`;
});
console.log(output);
fs.writeFileSync('db_check_result.txt', output);
}
checkDb()
.catch(e => fs.writeFileSync('db_check_result.txt', `Error: ${e.message}`))
.finally(async () => {
await prisma.$disconnect();
});