#!/usr/bin/env node import pg from 'pg'; import dotenv from 'dotenv'; import path from 'path'; import { fileURLToPath } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); dotenv.config({ path: path.join(__dirname, '..', '.env') }); const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL }); const { rows } = await pool.query(` SELECT inv.id, inv.sku_code, inv.batch_no, inv.available_qty FROM inventory inv WHERE NOT EXISTS ( SELECT 1 FROM inspections i WHERE i.batch_no = inv.batch_no AND i.sku_code IS NOT DISTINCT FROM inv.sku_code ) LIMIT 25`); console.log('inventory without matching inspection:', rows.length); console.log(JSON.stringify(rows, null, 2)); await pool.end();