Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
"PostgreSQL Error: relation "table_name" does not exist" When trying to SELECT * FROM "table_name"

I am trying to run a simple script on a simple PostgreSQL database with one table. When I use db.query('SELECT * FROM groups')

I get the error ERROR: relation "groups" does not exist at character 15

I ran the SQL in a Postgresql sandbox and it worked fine when I selected *, so I don't know what the problem here is. Here is the SQL Code

DROP TABLE IF EXISTS groups;

CREATE TABLE groups (
    id serial PRIMARY KEY,
    name varchar(255) NOT NULL,
    birthPlace varchar(255) NOT NULL; );

INSERT INTO groups (name, birthPlace) VALUES
    ( 'Marco', 'Italy' ),
    ( 'Callum', 'Scotland' ),
    ( 'Bob, Ireland' );

And this is the javascript code where I use db.query

const db = require ('../dbConfig')

class Groups {
    constructor(data){
        this.id = data.id
        this.name = data.name
        this.birthPlace = data.birthPlace
    }

        static get all() {
            return new Promise (async (resolve, reject) => {
                try {
                    const groupData = await db.query('SELECT * FROM groups;')
                    const groups = groupData.rows.map(d => new Groups(d))
                    resolve(groups);
                } catch (err) {
                    reject("Error retrieving groups")
                }
            })
        }
   }  
module.exports = Groups;

I have read that this error can arise when quotes or capitals were used when the table is created but I haven't used either anywhere in my code. I hope these code snippets suffice, any help would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda