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 |
| 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.
Users might not know the field terminology yet - So maybe an explainer here
There was a problem hiding this comment.
I think this explainer should also be moved further up - It relates to all types of associations.
There was a problem hiding this comment.
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.
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