-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
change(model): new options.underscored implementation #9304
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
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 |
| 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
| 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
projectIdto the User model. Depending on your setting forunderscoredthe column in the table will either be calledprojectIdorproject_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 testornpm run test-DIALECTpass with this change (including linting)?Description of change
Implements proposal from #6423 (comment)
Closes #6423
Closes #7255