不要怂,就是干,撸起袖子干!

Commit 94d1b122 by Mick Hansen

[ci skip] docs

1 parent 93b843be
Showing with 3 additions and 1 deletions
...@@ -46,10 +46,12 @@ And if your model has no primary key at all you can use `Model.removeAttribute(' ...@@ -46,10 +46,12 @@ And if your model has no primary key at all you can use `Model.removeAttribute('
## Foreign keys ## Foreign keys
```js ```js
// 1:1 // 1:1
User.belongsTo(Organization, {foreignKey: 'organization_id'}); Organization.belongsTo(User, {foreignKey: 'owner_id'});
User.hasOne(Organization, {foreignKey: 'owner_id'});
// 1:M // 1:M
Project.hasMany(Task, {foreignkey: 'tasks_pk'}); Project.hasMany(Task, {foreignkey: 'tasks_pk'});
Task.belongsTo(Project, {foreignKey: 'tasks_pk'});
// N:M // N:M
User.hasMany(Role, {through: 'user_has_roles', foreignKey: 'user_role_user_id'}); User.hasMany(Role, {through: 'user_has_roles', foreignKey: 'user_role_user_id'});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!