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

Commit 45648dd0 by Pedro Augusto de Paula Barbosa Committed by Sushant

docs(legacy): fix N:M example (#10509)

1 parent 10c34e3a
Showing with 8 additions and 8 deletions
# Working with legacy tables
While out of the box Sequelize will seem a bit opinionated it's trivial to both legacy and forward proof your application by defining (otherwise generated) table and field names.
While out of the box Sequelize will seem a bit opinionated it's easy to work legacy tables and forward proof your application by defining (otherwise generated) table and field names.
## Tables
```js
sequelize.define('user', {
// ...
}, {
tableName: 'users'
});
......@@ -48,14 +48,14 @@ And if your model has no primary key at all you can use `Model.removeAttribute('
## Foreign keys
```js
// 1:1
Organization.belongsTo(User, {foreignKey: 'owner_id'});
User.hasOne(Organization, {foreignKey: 'owner_id'});
Organization.belongsTo(User, { foreignKey: 'owner_id' });
User.hasOne(Organization, { foreignKey: 'owner_id' });
// 1:M
Project.hasMany(Task, {foreignKey: 'tasks_pk'});
Task.belongsTo(Project, {foreignKey: 'tasks_pk'});
Project.hasMany(Task, { foreignKey: 'tasks_pk' });
Task.belongsTo(Project, { foreignKey: 'tasks_pk' });
// N:M
User.hasMany(Role, {through: 'user_has_roles', foreignKey: 'user_role_user_id'});
Role.hasMany(User, {through: 'user_has_roles', foreignKey: 'roles_identifier'});
User.belongsToMany(Role, { through: 'user_has_roles', foreignKey: 'user_role_user_id' });
Role.belongsToMany(User, { through: 'user_has_roles', foreignKey: 'roles_identifier' });
```
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!