13 lines
757 B
JavaScript
13 lines
757 B
JavaScript
const { Client } = require('pg');
|
|
require('dotenv').config({ path: '/root/miaojingAI/.env.local' });
|
|
const c = new Client({ connectionString: process.env.LOCAL_DB_URL });
|
|
(async () => {
|
|
await c.connect();
|
|
for (const [name, sql] of [
|
|
['works_public', `select is_public, count(*)::int from works group by is_public order by is_public`],
|
|
['works_urls', `select id,user_id,is_public,type,result_url,thumbnail_url from works order by created_at desc`],
|
|
['orphan_credit', `select id,user_id,amount,type,description from credit_transactions where user_id not in (select id from profiles)`]
|
|
]) { const r=await c.query(sql); console.log('--- '+name); console.table(r.rows); }
|
|
await c.end();
|
|
})().catch(e=>{console.error(e);process.exit(1)});
|