Hi chat. I'm having this type error, help me please: import { Sequelize } from…
- User
Hi chat. I'm having this type error, help me please:
import { Sequelize } from 'sequelize-typescript';
import { Database, sequelizeConfig } from './config'; import { User, User_Roles, Roles } from './models'; import { Environment } from '../constants/environment';
const { DEVELOPMENT, STAGING, PRODUCTION } = Environment; const { NODE_ENV, SQL_LOGGING, DB_FORCE_SYNC } = process.env;
export const databaseProviders = [ { provide: Database.SEQUELIZE, useFactory: async () => { let config; switch (NODE_ENV) { case DEVELOPMENT: config = sequelizeConfig.development; break; case STAGING: config = sequelizeConfig.staging; break; case PRODUCTION: config = sequelizeConfig.production; break; default: config = sequelizeConfig.development; } const sequelize = new Sequelize({ ...config, ...(NODE_ENV.trim() !== LOCAL && { dialectOptions: { ssl: { require: true, rejectUnauthorized: false, }, }, }), logging: SQL_LOGGING === 'true', }); sequelize.addModels(models); await sequelize.sync({ force: NODE_ENV !== PRODUCTION && DB_FORCE_SYNC === 'true', }); return sequelize; }, }, ];
export const models = [Roles, User, User_Roles];
No overload matches this call. Overload 1 of 4, '(options?: SequelizeOptions): Sequelize', gave the following error. Argument of type '{ logging: boolean; dialectOptions: { ssl: { require: boolean; rejectUnauthorized: boolean; }; }; username?: string; password?: string; database?: string; host?: string; port?: string | number; dialect?: string; urlDatabase?: string; }' is not assignable to parameter of type 'SequelizeOptions'. Types of property 'dialect' are incompatible. Type 'string' is not assignable to type 'Dialect'. Overload 2 of 4, '(uri: string, options?: SequelizeOptions): Sequelize', gave the following error. Argument of type '{ logging: boolean; dialectOptions: { ssl: { require: boolean; rejectUnauthorized: boolean; }; }; username?: string; password?: string; database?: string; host?: string; port?: string | number; dialect?: string; urlDatabase?: string; }' is not assignable to parameter of type 'string'.ts(2769)
- Assistant