-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change(model): new options.underscored implementation #9304
Conversation
looks good so far but this is a breaking change, isn't it? |
We are under v5 beta process so we can break things |
oh I thought it was still the v5 branch |
@@ -22,13 +22,14 @@ Player.belongsTo(Team); // Will add a teamId attribute to Player to hold the pri | |||
|
|||
By default the foreign key for a belongsTo relation will be generated from the target model name and the target primary key name. | |||
|
|||
The default casing is `camelCase` however if the source model is configured with `underscored: true` the foreignKey will be `snake_case`. | |||
The default casing is `camelCase`. If the source model is configured with `underscored: true` the foreignKey will be created with field `snake_case`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users might not know the field
terminology yet - So maybe an explainer here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this explainer should also be moved further up - It relates to all types of associations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was section about foreign keys further down, I have moved that up and corrected old examples
@@ -191,7 +193,7 @@ const Project = sequelize.define('project', {/* ... */}) | |||
Project.hasMany(User, {as: 'Workers'}) | |||
``` | |||
|
|||
This will add the attribute `projectId` or `project_id` to User. Instances of Project will get the accessors `getWorkers` and `setWorkers`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will add the attribute
projectId
to the User model. Depending on your setting forunderscored
the column in the table will either be calledprojectId
orproject_id
I'm super happy that this issue is closed! I was really anxious about this feature. Is there any idea on when (or which version) is this going to be released? |
Pull Request check-list
Please make sure to review and check all of these items:
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description of change
Implements proposal from #6423 (comment)
Closes #6423
Closes #7255