Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to initialize models. #668

Open
dograshvili opened this issue Aug 8, 2024 · 0 comments
Open

How to initialize models. #668

dograshvili opened this issue Aug 8, 2024 · 0 comments

Comments

@dograshvili
Copy link

Hello guys.
It's the first time I use sequelize-auto with Typescript and I facing a bit of a problem. I am using sequelize-auto with the following flags
-l ts -o my/folder/path/ --dialect postgres --cm c (with other flags as well to connect to the database). The model files are generated successfully. Now when I try to initiate the models as the documentation says in the Typescript section using the initModels function which is exported in the init-models.ts file and I get the following error:

Argument of type 'Sequelize<PostgresDialect>' is not assignable to parameter of type 'Sequelize'.
  Type 'Sequelize<PostgresDialect>' is missing the following properties from type 'Sequelize': config, beforeInit, afterInit, set, and 4 more.ts(2345)

Here is the code that I use to create the Sequelize instance and to initiate the models

import { Sequelize } from '@sequelize/core';
import { initModels } from 'models/init-models';

const sequelize = new Sequelize({
  dialect: PostgresDialect,
  database: envVars.dbDatabase,
  schema: envVars.dbSchema,
  user: envVars.dbUser,
  password: envVars.dbPassword,
  host: envVars.dbHost,
  port: envVars.dbPort,
  ssl: true
});

initModels(sequelize);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant