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

283
Visualizações
How can I resolve TypeError: Cannot read property 'findAll' of undefined (Sequelize)?

In my project I am using PostgreSql as database. I have tables in PgAdmin, I am developing API's by calling tables in PgAdmin using Sequelize ORM

All API has GET request. Below is the index.js file where I write simple SQL to get the data.

index.js

class Person_Table extends Model {
    conn;
    rec;

    constructor(conn, schema, rec) {
        super(conn, schema, "Person_Table", {
            code: character(2, true),
            date: date(true),
            className: character(1, true),
            .....// many more columns
        }, true);
        this.rec = rec;
    }

    async getData(date) {
        try {
             const data = await this._conn.query(`
            (SELECT ${this._schema}."Person_Table"."code", ${this._schema}."Person_Table"."date", ${this._schema}."Person_Table"."className",${this._schema}."Person_Table"."ui" FROM ${this._schema}."Person_Table" WHERE "date" = '${date}')`); 

           return data[0];
        
    
          })
        } catch (error) {
            throw error;
        }
    }
}

Problem is there are multiple columns in table. So I don’t want return rows straight from the DB as is, in a long, flat object structure. Instead, reorganize each row in a nested object model, so the structure is apparent to the client. Something like below:

return (await this._model.findAll()).map(term => {
code: term.code,
trans: {
code: term.transCode,
date: term.date
},

// and so on....

I am getting TypeError: Cannot read property 'findAll' of undefined (Sequelize) error. I am not sure why. I need help to reorganize each row in a nested object model

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