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.

Problem with hooks and association

See original GitHub issue

I spent 2 hours to find how to make it works because seems to be broken

This don’t call my hook

Restaurants.hasMany(RestaurantPictures, {
    as: "Pictures",
    foreignKey: "restaurant",
    onDelete: "CASCADE",
    hooks: true
  })

This call my hook

Restaurants.hasMany(RestaurantPictures, {
    as: "Pictures",
    foreignKey: "restaurant",
    onDelete: "cascade",
    hooks: true
  })

can you please fix it ? (like do a string.toLowerCase())

thanks

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mickhansencommented, Jun 3, 2015

@lomberas Use foreignKey: 'user_id' on both your hasMany and belongsTo relation so it matches what you have in the database.

0reactions
janmeiercommented, Jul 26, 2015

Tested, and the hooks is invoked for me regardless of the casing of cascade. If you still have issues, please open a PR with failing test case @gossel-j

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with destroy hooks on n:m association #4777 - GitHub
Hi, I am having a weird behavior despite applying what the documentation says. I have 2 models and an n:m association via a...
Read more >
React.useEffect Hook – Common Problems and How to Fix ...
We are checking if the hook is receiving a user object. After that, we are fetching a list of our users from a...
Read more >
The Ugly side Of React Hooks | The Startup - Medium
Isn't it ironic? The biggest problem of React, in my opinion at least, is that it doesn't provide an out-of-the-box state management solution...
Read more >
Rules of Hooks - React
Only Call Hooks at the Top Level ... Don't call Hooks inside loops, conditions, or nested functions. Instead, always use Hooks at the...
Read more >
Avoiding common mistakes in React Hooks - LogRocket Blog
Even though React Hooks components have been around for a few years now, there are still some common mistakes that we can learn...
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