1

I am new in node.js, i want to fetch the data from table of the postgresql using sequelize ORM in node.js. I am using below code but its not working.

  const apisListModel = sequelize.define('apisList', {});
  apisListModel.findAll().then((data)=>{
              JSON.stringify(data,undefined,2);
            },(e)=>{
                console.log(e);

             }); 

Its give me error

        Executing (default): SELECT "id", "createdAt", "updatedAt" FROM 
           "apisLists" AS "apisList";
      { SequelizeDatabaseError: relation "apisLists" does not exist

But apiList table exist in my DATABASE

2 Answers 2

0

Sequelize changes the tableName to plural implicitly. You can define options as

const apisListModel = sequelize.define('apisList', {}, {
  tableName: 'apisList'
})
Sign up to request clarification or add additional context in comments.

Comments

0

The query trying to fetch data from apisLists but your table name is apiList. Note the "s" in table name.

If this is the case, you can specify the table name using the option

tableName: 'apiList'

Here is the Documentation link

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.