Sobes.tech
Junior — Middle

On which projects and how often have you worked directly with PostgreSQL, bypassing ORM tools?

sobes.tech AI

Answer from AI

Worked directly with PostgreSQL on several projects where high performance and precise query control were required. Usually, these were projects with Node.js, where the pg library was used to execute SQL queries without ORM. The frequency was about every second project, especially when ORM did not provide the needed flexibility or there were optimization issues.

Example of using pg in Node.js:

const { Client } = require('pg');
const client = new Client({ connectionString: process.env.DATABASE_URL });

async function getUsers() {
  await client.connect();
  const res = await client.query('SELECT * FROM users WHERE active = $1', [true]);
  await client.end();
  return res.rows;
}

This approach allows writing complex queries, using PostgreSQL-specific functions, and optimizing database interactions without ORM limitations.