question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'isInitialized' of undefined association problem.

See original GitHub issue

Looks like that when we try to put an association of model B.model.ts on an A.model.ts results in the following error:

TypeError: Cannot read property 'isInitialized' of undefined

/node_modules/sequelize-typescript/lib/models/association/BaseAssociation.js:19
        if (!modelClass.isInitialized) {
                        ^
TypeError: Cannot read property 'isInitialized' of undefined
    at BelongsToAssociation.BaseAssociation.getAssociatedClass (/node_modules/sequelize-typescript/lib/models/association/BaseAssociation.js:19:25)

The file os model names must be ordered by his association as well ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
eboswortcommented, Dec 6, 2018

I just ran into the same issue. Thanks @Mreddi1 for pointing me in the right direction. I just want to add a little info for the next person who comes here looking for answers. In my case I was importing the association via import { AssociatedModel } from "../models" where models is a module that imports and reexports all my models. The fix for me was to use import { AssociatedModel } from "./AssociatedModel". Guess it’s something about the indirect import?

1reaction
RoelRoelcommented, May 24, 2019

The errorhandling could be better. A wrong import caused my problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'isInitialized' of undefined association problem. #357 - GitHub
Looks like that when we try to put an association of model B.model.ts on an A.model.ts results in the following error: TypeError: Cannot...
Read more >
node.js - Sequelize Association Error Cannot read property ...
I have a one-to-one relationship between the tables and am not sure if this is causing the error or if it is somewhere...
Read more >
Class Model<TModelAttributes, TCreationAttributes> Abstract
A dummy variable that doesn't exist on the real object. This exists so Typescript can infer the type of the attributes in static...
Read more >
Link - Troubleshooting | Plaid Docs
Make sure Link is initialized for the country in which the institution operates. If the problem occurs in Production but not in Sandbox...
Read more >
Hibernate ORM 5.4.33.Final User Guide - Red Hat on GitHub
Use Hibernate and report any bugs or issues you find. ... While the java.sql classes define a direct association to the SQL ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found