You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Sequelize}from"sequelize-typescript";importTodofrom"./models/Todo.model";constdatabase=newSequelize({host : process.env.DB_HOST,database: process.env.DB_NAME,dialect: 'mysql',username: process.env.DB_USER,password: process.env.DB_PASS,models: [Todo],sync: {force: true},});(async()=>{try{awaitdatabase.authenticate();console.log('Database is connected');database.addModels([Todo])awaitdatabase.sync({alter: true,force: true});console.log('Models synchronized successfully.');awaitTodo.create({list: 'My Todo List',});}catch(err){console.error('Error during database setup:',err);}})();exportdefaultdatabase
everytime if I try to make an api call it will always the error ModelNotInitializedError: Model not initialized: Member "create" cannot be called. "Todo" needs to be added to a Sequelize instance. And I don't know why.
The text was updated successfully, but these errors were encountered:
@Mauzzz0 Sorry for the late response; didn't know someone answered. I’ve been working on fixing it for weeks and eventually gave up. I ended up switching to Prisma, which works perfectly. Thank you for your help; I still appreciate it.
Versions
[X] bug report
[ ] feature request
Issue
ModelNotInitializedError: Model not initialized: Member "create" cannot be called. "Todo" needs to be added to a Sequelize instance.
Context
I have 1 simple model that is Todo with name of the file Todo.model.ts.
And this is my Sequelize Configuration.
everytime if I try to make an api call it will always the error
ModelNotInitializedError: Model not initialized: Member "create" cannot be called. "Todo" needs to be added to a Sequelize instance.
And I don't know why.The text was updated successfully, but these errors were encountered: