13 lines
630 B
TypeScript
13 lines
630 B
TypeScript
import { prisma, tenantDb } from '../src/config/database.js';
|
|
const prefix = process.argv[2];
|
|
async function main() {
|
|
const ts = await prisma.tenant.findMany({ where: { active: true }, select: { id: true, rfc: true, databaseName: true } });
|
|
for (const t of ts) {
|
|
const pool = await tenantDb.getPool(t.id, t.databaseName);
|
|
const { rows } = await pool.query(`SELECT uuid FROM cfdis WHERE uuid LIKE $1 || '%'`, [prefix]);
|
|
for (const r of rows) console.log(t.rfc, r.uuid);
|
|
}
|
|
await prisma.$disconnect();
|
|
}
|
|
main().catch(async e => { console.error(e); await prisma.$disconnect().catch(() => {}); process.exit(1); });
|