#!/usr/bin/env node import pg from 'pg'; import { readFileSync } from 'fs'; const env = readFileSync('/opt/ai-fresh-delivery/server/.env', 'utf8'); const url = env.match(/^DATABASE_URL=(.+)$/m)[1].trim().replace(/^["']|["']$/g, ''); const pool = new pg.Pool({ connectionString: url }); const codes = ['ORD_MP_1783393655414VQCS', 'ORD_MP_1783394813380SLW4', 'ORD_MP_1783395334508Z0A0']; try { const r = await pool.query( `SELECT order_code, delivery_date, created_at, to_char(delivery_date AT TIME ZONE 'Asia/Shanghai', 'YYYY-MM-DD') AS china_day, to_char(delivery_date::date, 'YYYY-MM-DD') AS cast_date, to_char(COALESCE(delivery_date, created_at)::date, 'YYYY-MM-DD') AS coalesce_date FROM orders WHERE order_code = ANY($1::text[])`, [codes] ); console.log(JSON.stringify(r.rows, null, 2)); } finally { await pool.end(); }