const { Client } = require('pg');

async function testProject() {
    require('dotenv').config({ path: '../.env' });
const client = new Client({
    host: process.env.DB_HOST,
    port: process.env.DB_PORT,
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_NAME
});
    
    try {
        await client.connect();
        const input = 'BWSamern-Ohne'; 
        const normalized = input.toLowerCase().replace(/[-_]/g, '');
        const res = await client.query(
            'SELECT id FROM geodaten.projekte WHERE LOWER(REPLACE(REPLACE(name, \'-\', \'\'), \'_\', \'\')) = $1', 
            [normalized]
        );
        console.log(`Projekt ID für '${input}':`, res.rows.length > 0 ? res.rows[0].id : null);
    } catch (e) {
        console.error("Error:", e);
    } finally {
        await client.end();
    }
}
testProject();
