I already have tables in postgresql. I want to retrieve data from them using sequelize. I used several ways to do it. But still can't map the db schma to sequelize in node.js.
const Test = Conn.define('test', {
race_id:
{
type: Sequelize.STRING,
allowNull: false
},
race_name:
{
type: Sequelize.STRING,
allowNull: false
}
});
Conn.sync();
export default Conn;
I define the schema in node.js and have a table with same schema in postgresql.
But when execute Db.models.test.findAll({ where: args });
The console will output result as following:
Executing (default): SELECT "id", "race_id", "race_name", "createdAt", "updatedAt" FROM "tests" AS "test";
And I will get another output that is
column \"id\" does not exist
I can't figure out why sequelize retrieve data from tests table and it retrieve columns that I don't have.
How could I select table from existing tables using sequelize? I need to use ORM for requirement and can't use other way to get data.