50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { Pool } from 'pg';
|
|
|
|
const pool = new Pool({
|
|
connectionString: 'postgresql://sail:password@localhost:5432/dutchie_menus'
|
|
});
|
|
|
|
async function checkStore() {
|
|
try {
|
|
const store = await pool.query(`
|
|
SELECT id, name, slug FROM stores WHERE slug = 'curaleaf-az-48th-street'
|
|
`);
|
|
|
|
if (store.rows.length > 0) {
|
|
console.log('Store found:', store.rows[0]);
|
|
|
|
// Check if it has products
|
|
const products = await pool.query(`
|
|
SELECT COUNT(*) as total, COUNT(DISTINCT brand) as brands
|
|
FROM products WHERE store_id = $1
|
|
`, [store.rows[0].id]);
|
|
|
|
console.log('Store products:', products.rows[0]);
|
|
|
|
// Check distinct brands
|
|
const brands = await pool.query(`
|
|
SELECT DISTINCT brand FROM products
|
|
WHERE store_id = $1 AND brand IS NOT NULL
|
|
ORDER BY brand
|
|
`, [store.rows[0].id]);
|
|
|
|
console.log('\nCurrent brands:', brands.rows.map(r => r.brand));
|
|
} else {
|
|
console.log('Store not found');
|
|
|
|
// Show available stores
|
|
const stores = await pool.query(`
|
|
SELECT slug FROM stores WHERE slug LIKE '%48th%'
|
|
`);
|
|
console.log('Stores with 48th:', stores.rows.map(r => r.slug));
|
|
}
|
|
|
|
} catch (error: any) {
|
|
console.error('Error:', error.message);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|
|
|
|
checkStore();
|