Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

285
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!