Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
"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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda