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.

many to many (through model, with extra field in junction table) error "<Model1> is not associated to <Model2>"

See original GitHub issue

Hi. I’m new in feathersj , sequelize and web. So i’m trying to create simple first app and i need some backend for it. Now about the current problem: I have 3 sequelize models - receipts,ingredients and receiptsIngredients You can see all code here (hooks, models, associations etc.) https://github.com/kk4fun/feathers-server-receiptsmania

So , when i send get request in postman i get an error:

{
    "name": "GeneralError",
    "message": "ingredients is not associated to receipts!",
    "code": 500,
    "className": "general-error",
    "data": {},
    "errors": {}
}

And there’s one note: in postgres.js file here, where associations are set i don’t see this log. But it auto-generated feathers code. May be it helps.

 Object.keys(models).forEach(name => {
      if ('associate' in models[name]) {
        console.log('!!!');
        models[name].associate(models);
      }
    });

And i don’t understand now what is wrong and why i can’t see receipts with ingredients throw receipts service with sequelize include before hook. Help me, please 😃

======================================= I’m doing it on Windows 10 x64, in VS code editor.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
eddyystopcommented, Jun 13, 2017

That looks like a DB error, and not from postman.

Since you are new to web development, wouldn’t it be a better learning experience to start with the straightforward NeDB DB rather than with the complexity of Sequelize?

If you insist on Sequelize, I suggest you look at bestbuy/api-playground and feathersjs/api-playground-client

0reactions
kk4funcommented, Jun 14, 2017

This is the kind of situation you don’t really want while learnin and why I recommended nedb.

Yes, i agree. Thanks a lot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sequelize many-to-many M:N relationship not functioning. Error
My models and relationships are arranged on separate pages, but they're all joining up fine as I can see the 1:M relationships are...
Read more >
Advanced M:N Associations - Sequelize
We established a Many-to-Many relationship between User and Profile using the Grant model as the through table: User.belongsToMany(Profile, { ...
Read more >
Models - Django documentation
A model is the single, definitive source of information about your data. It contains the essential fields and behaviors of the data you're...
Read more >
timestamps false sequelize - You.com | The Search Engine You ...
I think the error is that you have timestamps enabled in sequelize, but your actual table definitions in the DB do not contain...
Read more >
Junction Model Pattern: Many-to-Many - Sequelize
Great. Now how do we model the many-to-many relationship between them? Modeling the junction table. We need to create ...
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