Files
backend_fiesta/scratch/query_stores.js
2026-07-09 18:03:44 +05:30

37 lines
885 B
JavaScript

const { Client } = require('pg');
const client = new Client({
host: '66.116.207.225',
port: 5433,
database: 'nearledb',
user: 'admin',
password: 'Package@123#',
ssl: false,
});
async function main() {
try {
await client.connect();
console.log('Connected to PostgreSQL successfully!');
const query = `
SELECT a.tenantcustomerid, a.customerid, a.tenantid, a.locationid,
b.tenantname, c.locationname
FROM tenantcustomers a
LEFT JOIN tenants b ON a.tenantid = b.tenantid
INNER JOIN tenantlocations c ON a.locationid = c.locationid
WHERE a.tenantid = 1135
`;
const res = await client.query(query);
console.log('\n--- Tenant Customers Links (tid = 1135) ---');
console.table(res.rows);
} catch (err) {
console.error('Error connecting:', err);
} finally {
await client.end();
}
}
main();