Skip to content

How to initialize models. #668

Open
Open
@dograshvili

Description

@dograshvili

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);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions