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

Commit 75e363ee by Sushant Committed by GitHub

docs: use modelName with init for proper include alias (#10725)

1 parent d87dab54
...@@ -21,6 +21,7 @@ User.init({ ...@@ -21,6 +21,7 @@ User.init({
email: Sequelize.STRING email: Sequelize.STRING
}, { }, {
sequelize, sequelize,
modelName: 'user'
}); });
class Project extends Model {} class Project extends Model {}
...@@ -28,6 +29,7 @@ Project.init({ ...@@ -28,6 +29,7 @@ Project.init({
name: Sequelize.STRING name: Sequelize.STRING
}, { }, {
sequelize, sequelize,
modelName: 'project'
}); });
User.hasOne(Project); User.hasOne(Project);
...@@ -41,9 +43,9 @@ When you create associations between your models in sequelize, foreign key refer ...@@ -41,9 +43,9 @@ When you create associations between your models in sequelize, foreign key refer
```js ```js
class Task extends Model {} class Task extends Model {}
Task.init({ title: Sequelize.STRING }, { sequelize }); Task.init({ title: Sequelize.STRING }, { sequelize, modelName: 'task' });
class User extends Model {} class User extends Model {}
User.init({ username: Sequelize.STRING }, { sequelize }); User.init({ username: Sequelize.STRING }, { sequelize, modelName: 'user' });
User.hasMany(Task); // Will add userId to Task model User.hasMany(Task); // Will add userId to Task model
Task.belongsTo(User); // Will also add userId to Task model Task.belongsTo(User); // Will also add userId to Task model
...@@ -91,6 +93,7 @@ Task.init({ ...@@ -91,6 +93,7 @@ Task.init({
}, { }, {
underscored: true, underscored: true,
sequelize, sequelize,
modelName: 'task'
}); });
class User extends Model {} class User extends Model {}
...@@ -99,6 +102,7 @@ User.init({ ...@@ -99,6 +102,7 @@ User.init({
}, { }, {
underscored: true, underscored: true,
sequelize, sequelize,
modelName: 'user'
}); });
// Will add userId to Task model, but field will be set to `user_id` // Will add userId to Task model, but field will be set to `user_id`
...@@ -143,11 +147,11 @@ Adding constraints between tables means that tables must be created in the datab ...@@ -143,11 +147,11 @@ Adding constraints between tables means that tables must be created in the datab
class Document extends Model {} class Document extends Model {}
Document.init({ Document.init({
author: Sequelize.STRING author: Sequelize.STRING
}, { sequelize }); }, { sequelize, modelName: 'document' });
class Version extends Model {} class Version extends Model {}
Version.init({ Version.init({
timestamp: Sequelize.DATE timestamp: Sequelize.DATE
}, { sequelize }); }, { sequelize, modelName: 'version' });
Document.hasMany(Version); // This adds documentId attribute to version Document.hasMany(Version); // This adds documentId attribute to version
Document.belongsTo(Version, { Document.belongsTo(Version, {
...@@ -202,7 +206,7 @@ class Trainer extends Model {} ...@@ -202,7 +206,7 @@ class Trainer extends Model {}
Trainer.init({ Trainer.init({
firstName: Sequelize.STRING, firstName: Sequelize.STRING,
lastName: Sequelize.STRING lastName: Sequelize.STRING
}, { sequelize }); }, { sequelize, modelName: 'trainer' });
// Series will have a trainerId = Trainer.id foreign reference key // Series will have a trainerId = Trainer.id foreign reference key
// after we call Trainer.hasMany(series) // after we call Trainer.hasMany(series)
...@@ -219,7 +223,7 @@ Series.init({ ...@@ -219,7 +223,7 @@ Series.init({
key: 'id' key: 'id'
} }
} }
}, { sequelize }); }, { sequelize, modelName: 'series' });
// Video will have seriesId = Series.id foreign reference key // Video will have seriesId = Series.id foreign reference key
// after we call Series.hasOne(Video) // after we call Series.hasOne(Video)
...@@ -236,7 +240,7 @@ Video.init({ ...@@ -236,7 +240,7 @@ Video.init({
key: 'id' key: 'id'
} }
} }
}, { sequelize }); }, { sequelize, modelName: 'video' });
Series.hasOne(Video); Series.hasOne(Video);
Trainer.hasMany(Series); Trainer.hasMany(Series);
...@@ -254,9 +258,9 @@ A simple example would be a **Player** being part of a **Team** with the foreign ...@@ -254,9 +258,9 @@ A simple example would be a **Player** being part of a **Team** with the foreign
```js ```js
class Player extends Model {} class Player extends Model {}
Player.init({/* attributes */}, { sequelize }); Player.init({/* attributes */}, { sequelize, modelName: 'player' });
class Team extends Model {} class Team extends Model {}
Team.init({/* attributes */}, { sequelize }); Team.init({/* attributes */}, { sequelize, modelName: 'team' });
Player.belongsTo(Team); // Will add a teamId attribute to Player to hold the primary key value for Team Player.belongsTo(Team); // Will add a teamId attribute to Player to hold the primary key value for Team
``` ```
...@@ -269,22 +273,22 @@ The default casing is `camelCase`. If the source model is configured with `under ...@@ -269,22 +273,22 @@ The default casing is `camelCase`. If the source model is configured with `under
```js ```js
class User extends Model {} class User extends Model {}
User.init({/* attributes */}, { sequelize }) User.init({/* attributes */}, { sequelize, modelName: 'user' })
class Company extends Model {} class Company extends Model {}
Company.init({/* attributes */}, { sequelize }); Company.init({/* attributes */}, { sequelize, modelName: 'company' });
// will add companyId to user // will add companyId to user
User.belongsTo(Company); User.belongsTo(Company);
class User extends Model {} class User extends Model {}
User.init({/* attributes */}, {underscored: true, sequelize}) User.init({/* attributes */}, { underscored: true, sequelize, modelName: 'user' })
class Company extends Model {} class Company extends Model {}
Company.init({ Company.init({
uuid: { uuid: {
type: Sequelize.UUID, type: Sequelize.UUID,
primaryKey: true primaryKey: true
} }
}, { sequelize }); }, { sequelize, modelName: 'company' });
// will add companyUuid to user with field company_uuid // will add companyUuid to user with field company_uuid
User.belongsTo(Company); User.belongsTo(Company);
...@@ -294,9 +298,9 @@ In cases where `as` has been defined it will be used in place of the target mode ...@@ -294,9 +298,9 @@ In cases where `as` has been defined it will be used in place of the target mode
```js ```js
class User extends Model {} class User extends Model {}
User.init({/* attributes */}, { sequelize }) User.init({/* attributes */}, { sequelize, modelName: 'user' })
class UserRole extends Model {} class UserRole extends Model {}
UserRole.init({/* attributes */}, { sequelize }); UserRole.init({/* attributes */}, { sequelize, modelName: 'userRole' });
User.belongsTo(UserRole, {as: 'role'}); // Adds roleId to user rather than userRoleId User.belongsTo(UserRole, {as: 'role'}); // Adds roleId to user rather than userRoleId
``` ```
...@@ -306,9 +310,9 @@ When the foreign key option is used, Sequelize will use it as-is: ...@@ -306,9 +310,9 @@ When the foreign key option is used, Sequelize will use it as-is:
```js ```js
class User extends Model {} class User extends Model {}
User.init({/* attributes */}, { sequelize }) User.init({/* attributes */}, { sequelize, modelName: 'user' })
class Company extends Model {} class Company extends Model {}
Company.init({/* attributes */}, { sequelize }); Company.init({/* attributes */}, { sequelize, modelName: 'company' });
User.belongsTo(Company, {foreignKey: 'fk_company'}); // Adds fk_company to User User.belongsTo(Company, {foreignKey: 'fk_company'}); // Adds fk_company to User
``` ```
...@@ -319,9 +323,9 @@ The target key is the column on the target model that the foreign key column on ...@@ -319,9 +323,9 @@ The target key is the column on the target model that the foreign key column on
```js ```js
class User extends Model {} class User extends Model {}
User.init({/* attributes */}, { sequelize }) User.init({/* attributes */}, { sequelize, modelName: 'user' })
class Company extends Model {} class Company extends Model {}
Company.init({/* attributes */}, { sequelize }); Company.init({/* attributes */}, { sequelize, modelName: 'company' });
User.belongsTo(Company, {foreignKey: 'fk_companyname', targetKey: 'name'}); // Adds fk_companyname to User User.belongsTo(Company, {foreignKey: 'fk_companyname', targetKey: 'name'}); // Adds fk_companyname to User
``` ```
...@@ -332,9 +336,9 @@ HasOne associations are associations where the foreign key for the one-to-one re ...@@ -332,9 +336,9 @@ HasOne associations are associations where the foreign key for the one-to-one re
```js ```js
class User extends Model {} class User extends Model {}
User.init({/* ... */}, { sequelize }) User.init({/* ... */}, { sequelize, modelName: 'user' })
class Project extends Model {} class Project extends Model {}
Project.init({/* ... */}, { sequelize }) Project.init({/* ... */}, { sequelize, modelName: 'project' })
// One-way associations // One-way associations
Project.hasOne(User) Project.hasOne(User)
...@@ -363,7 +367,7 @@ Project.hasOne(User, { as: 'Initiator' }) ...@@ -363,7 +367,7 @@ Project.hasOne(User, { as: 'Initiator' })
// Or let's define some self references // Or let's define some self references
class Person extends Model {} class Person extends Model {}
Person.init({ /* ... */}, { sequelize }) Person.init({ /* ... */}, { sequelize, modelName: 'person' })
Person.hasOne(Person, {as: 'Father'}) Person.hasOne(Person, {as: 'Father'})
// this will add the attribute FatherId to Person // this will add the attribute FatherId to Person
...@@ -391,9 +395,9 @@ The source key is the attribute on the source model that the foreign key attribu ...@@ -391,9 +395,9 @@ The source key is the attribute on the source model that the foreign key attribu
```js ```js
class User extends Model {} class User extends Model {}
User.init({/* attributes */}, { sequelize }) User.init({/* attributes */}, { sequelize, modelName: 'user' })
class Company extends Model {} class Company extends Model {}
Company.init({/* attributes */}, { sequelize }); Company.init({/* attributes */}, { sequelize, modelName: 'company' });
// Adds companyName attribute to User // Adds companyName attribute to User
// Use name attribute from Company as source attribute // Use name attribute from Company as source attribute
...@@ -408,9 +412,9 @@ Suppose we have two tables to link **Player** and **Team**. Lets define their mo ...@@ -408,9 +412,9 @@ Suppose we have two tables to link **Player** and **Team**. Lets define their mo
```js ```js
class Player extends Model {} class Player extends Model {}
Player.init({/* attributes */}, { sequelize }) Player.init({/* attributes */}, { sequelize, modelName: 'player' })
class Team extends Model {} class Team extends Model {}
Team.init({/* attributes */}, { sequelize }); Team.init({/* attributes */}, { sequelize, modelName: 'team' });
``` ```
When we link two models in Sequelize we can refer them as pairs of **source** and **target** models. Like this When we link two models in Sequelize we can refer them as pairs of **source** and **target** models. Like this
...@@ -437,11 +441,11 @@ Here is an example demonstrating use cases of BelongsTo and HasOne. ...@@ -437,11 +441,11 @@ Here is an example demonstrating use cases of BelongsTo and HasOne.
```js ```js
class Player extends Model {} class Player extends Model {}
Player.init({/* attributes */}, { sequelize }) Player.init({/* attributes */}, { sequelize, modelName: 'player' })
class Coach extends Model {} class Coach extends Model {}
Coach.init({/* attributes */}, { sequelize }) Coach.init({/* attributes */}, { sequelize, modelName: 'coach' })
class Team extends Model {} class Team extends Model {}
Team.init({/* attributes */}, { sequelize }); Team.init({/* attributes */}, { sequelize, modelName: 'team' });
``` ```
Suppose our `Player` model has information about its team as `teamId` column. Information about each Team's `Coach` is stored in the `Team` model as `coachId` column. These both scenarios requires different kind of 1:1 relation because foreign key relation is present on different models each time. Suppose our `Player` model has information about its team as `teamId` column. Information about each Team's `Coach` is stored in the `Team` model as `coachId` column. These both scenarios requires different kind of 1:1 relation because foreign key relation is present on different models each time.
...@@ -464,9 +468,9 @@ One-To-Many associations are connecting one source with multiple targets. The ta ...@@ -464,9 +468,9 @@ One-To-Many associations are connecting one source with multiple targets. The ta
```js ```js
class User extends Model {} class User extends Model {}
User.init({/* ... */}, { sequelize }) User.init({/* ... */}, { sequelize, modelName: 'user' })
class Project extends Model {} class Project extends Model {}
Project.init({/* ... */}, { sequelize }) Project.init({/* ... */}, { sequelize, modelName: 'project' })
// OK. Now things get more complicated (not really visible to the user :)). // OK. Now things get more complicated (not really visible to the user :)).
// First let's define a hasMany association // First let's define a hasMany association
...@@ -479,9 +483,9 @@ Sometimes you may need to associate records on different columns, you may use `s ...@@ -479,9 +483,9 @@ Sometimes you may need to associate records on different columns, you may use `s
```js ```js
class City extends Model {} class City extends Model {}
City.init({ countryCode: Sequelize.STRING }, { sequelize }); City.init({ countryCode: Sequelize.STRING }, { sequelize, modelName: 'city' });
class Country extends Model {} class Country extends Model {}
Country.init({ isoCode: Sequelize.STRING }, { sequelize }); Country.init({ isoCode: Sequelize.STRING }, { sequelize, modelName: 'country' });
// Here we can connect countries and cities base on country code // Here we can connect countries and cities base on country code
Country.hasMany(City, {foreignKey: 'countryCode', sourceKey: 'isoCode'}); Country.hasMany(City, {foreignKey: 'countryCode', sourceKey: 'isoCode'});
...@@ -531,13 +535,13 @@ If you want additional attributes in your join table, you can define a model for ...@@ -531,13 +535,13 @@ If you want additional attributes in your join table, you can define a model for
```js ```js
class User extends Model {} class User extends Model {}
User.init({}, { sequelize }) User.init({}, { sequelize, modelName: 'user' })
class Project extends Model {} class Project extends Model {}
Project.init({}, { sequelize }) Project.init({}, { sequelize, modelName: 'project' })
class UserProjects extends Model {} class UserProjects extends Model {}
UserProjects.init({ UserProjects.init({
status: DataTypes.STRING status: DataTypes.STRING
}, { sequelize }) }, { sequelize, modelName: 'userProjects' })
User.belongsToMany(Project, { through: UserProjects }) User.belongsToMany(Project, { through: UserProjects })
Project.belongsToMany(User, { through: UserProjects }) Project.belongsToMany(User, { through: UserProjects })
...@@ -560,7 +564,7 @@ UserProjects.init({ ...@@ -560,7 +564,7 @@ UserProjects.init({
autoIncrement: true autoIncrement: true
}, },
status: DataTypes.STRING status: DataTypes.STRING
}, { sequelize }) }, { sequelize, modelName: 'userProjects' })
``` ```
With Belongs-To-Many you can query based on **through** relation and select specific attributes. For example using `findAll` with **through** With Belongs-To-Many you can query based on **through** relation and select specific attributes. For example using `findAll` with **through**
...@@ -604,6 +608,7 @@ Project.init(attributes, { ...@@ -604,6 +608,7 @@ Project.init(attributes, {
plural: 'tasks', plural: 'tasks',
}, },
sequelize, sequelize,
modelName: 'project'
}) })
User.belongsToMany(Project); User.belongsToMany(Project);
...@@ -792,20 +797,20 @@ class Post extends Model {} ...@@ -792,20 +797,20 @@ class Post extends Model {}
Post.init({ Post.init({
title: Sequelize.STRING, title: Sequelize.STRING,
text: Sequelize.STRING text: Sequelize.STRING
}, { sequelize }); }, { sequelize, modelName: 'post' });
class Image extends Model {} class Image extends Model {}
Image.init({ Image.init({
title: Sequelize.STRING, title: Sequelize.STRING,
link: Sequelize.STRING link: Sequelize.STRING
}, { sequelize }); }, { sequelize, modelName: 'image' });
class Comment extends Model {} class Comment extends Model {}
Comment.init({ Comment.init({
title: Sequelize.STRING, title: Sequelize.STRING,
commentable: Sequelize.STRING, commentable: Sequelize.STRING,
commentableId: Sequelize.INTEGER commentableId: Sequelize.INTEGER
}, { sequelize }); }, { sequelize, modelName: 'comment' });
Comment.prototype.getItem = function(options) { Comment.prototype.getItem = function(options) {
return this[ return this[
...@@ -896,13 +901,13 @@ ItemTag.init({ ...@@ -896,13 +901,13 @@ ItemTag.init({
unique: 'item_tag_taggable', unique: 'item_tag_taggable',
references: null references: null
} }
}, { sequelize }); }, { sequelize, modelName: 'item_tag' });
class Tag extends Model {} class Tag extends Model {}
Tag.init({ Tag.init({
name: Sequelize.STRING, name: Sequelize.STRING,
status: Sequelize.STRING status: Sequelize.STRING
}, { sequelize }); }, { sequelize, modelName: 'tag' });
Post.belongsToMany(Tag, { Post.belongsToMany(Tag, {
through: { through: {
...@@ -986,12 +991,12 @@ Consider the following models: ...@@ -986,12 +991,12 @@ Consider the following models:
class Product extends Model {} class Product extends Model {}
Product.init({ Product.init({
title: Sequelize.STRING title: Sequelize.STRING
}, { sequelize }); }, { sequelize, modelName: 'product' });
class User extends Model {} class User extends Model {}
User.init({ User.init({
firstName: Sequelize.STRING, firstName: Sequelize.STRING,
lastName: Sequelize.STRING lastName: Sequelize.STRING
}, { sequelize }); }, { sequelize, modelName: 'user' });
class Address extends Model {} class Address extends Model {}
Address.init({ Address.init({
type: Sequelize.STRING, type: Sequelize.STRING,
...@@ -1000,7 +1005,7 @@ Address.init({ ...@@ -1000,7 +1005,7 @@ Address.init({
city: Sequelize.STRING, city: Sequelize.STRING,
state: Sequelize.STRING, state: Sequelize.STRING,
zip: Sequelize.STRING, zip: Sequelize.STRING,
}, { sequelize }); }, { sequelize, modelName: 'address' });
Product.User = Product.belongsTo(User); Product.User = Product.belongsTo(User);
User.Addresses = User.hasMany(Address); User.Addresses = User.hasMany(Address);
...@@ -1059,7 +1064,7 @@ Let's introduce the ability to associate a product with many tags. Setting up th ...@@ -1059,7 +1064,7 @@ Let's introduce the ability to associate a product with many tags. Setting up th
class Tag extends Model {} class Tag extends Model {}
Tag.init({ Tag.init({
name: Sequelize.STRING name: Sequelize.STRING
}, { sequelize }); }, { sequelize, modelName: 'tag' });
Product.hasMany(Tag); Product.hasMany(Tag);
// Also works for `belongsToMany`. // Also works for `belongsToMany`.
......
...@@ -107,6 +107,7 @@ User.init({ ...@@ -107,6 +107,7 @@ User.init({
} }
}, { }, {
sequelize, sequelize,
modelName: 'user'
// options // options
}); });
``` ```
...@@ -114,7 +115,7 @@ User.init({ ...@@ -114,7 +115,7 @@ User.init({
Alternatively, using `sequelize.define`: Alternatively, using `sequelize.define`:
```js ```js
const User = sequelize.define('User', { const User = sequelize.define('user', {
// attributes // attributes
firstName: { firstName: {
type: Sequelize.STRING, type: Sequelize.STRING,
......
...@@ -37,7 +37,7 @@ class User extends Sequelize.Model {} ...@@ -37,7 +37,7 @@ class User extends Sequelize.Model {}
User.init({ User.init({
username: Sequelize.STRING, username: Sequelize.STRING,
birthday: Sequelize.DATE birthday: Sequelize.DATE
}, { sequelize }); }, { sequelize, modelName: 'user' });
sequelize.sync() sequelize.sync()
.then(() => User.create({ .then(() => User.create({
......
...@@ -25,8 +25,8 @@ class Task extends Model {} ...@@ -25,8 +25,8 @@ class Task extends Model {}
Task.init({ Task.init({
title: Sequelize.STRING, title: Sequelize.STRING,
rating: { type: Sequelize.TINYINT, defaultValue: 3 } rating: { type: Sequelize.TINYINT, defaultValue: 3 }
}, { sequelize }); }, { sequelize, modelName: 'task' });
// now instantiate an object // now instantiate an object
const task = Task.build({title: 'very important task'}) const task = Task.build({title: 'very important task'})
...@@ -242,7 +242,7 @@ Tasks.init({ ...@@ -242,7 +242,7 @@ Tasks.init({
len: [3, 10] len: [3, 10]
} }
} }
}, { sequelize }) }, { sequelize, modelName: 'tasks' })
Tasks.bulkCreate([ Tasks.bulkCreate([
{name: 'foo', code: '123'}, {name: 'foo', code: '123'},
......
...@@ -9,6 +9,7 @@ class User extends Model {} ...@@ -9,6 +9,7 @@ class User extends Model {}
User.init({ User.init({
// ... // ...
}, { }, {
modelName: 'user',
tableName: 'users', tableName: 'users',
sequelize, sequelize,
}); });
......
...@@ -7,14 +7,14 @@ class Project extends Model {} ...@@ -7,14 +7,14 @@ class Project extends Model {}
Project.init({ Project.init({
title: Sequelize.STRING, title: Sequelize.STRING,
description: Sequelize.TEXT description: Sequelize.TEXT
}, { sequelize }); }, { sequelize, modelName: 'project' });
class Task extends Model {} class Task extends Model {}
Task.init({ Task.init({
title: Sequelize.STRING, title: Sequelize.STRING,
description: Sequelize.TEXT, description: Sequelize.TEXT,
deadline: Sequelize.DATE deadline: Sequelize.DATE
}, { sequelize }) }, { sequelize, modelName: 'task' })
``` ```
Apart from [datatypes][1], there are plenty of options that you can set on each column. Apart from [datatypes][1], there are plenty of options that you can set on each column.
...@@ -77,7 +77,10 @@ Foo.init({ ...@@ -77,7 +77,10 @@ Foo.init({
comment: 'This is a column name that has a comment' comment: 'This is a column name that has a comment'
} }
}, { sequelize }); }, {
sequelize,
modelName: 'foo'
});
``` ```
The comment option can also be used on a table, see [model configuration][0]. The comment option can also be used on a table, see [model configuration][0].
...@@ -163,7 +166,7 @@ Employee.init({ ...@@ -163,7 +166,7 @@ Employee.init({
this.setDataValue('title', val.toUpperCase()); this.setDataValue('title', val.toUpperCase());
} }
} }
}, { sequelize }); }, { sequelize, modelName: 'employee' });
Employee Employee
.create({ name: 'John Doe', title: 'senior engineer' }) .create({ name: 'John Doe', title: 'senior engineer' })
...@@ -198,6 +201,7 @@ Foo.init({ ...@@ -198,6 +201,7 @@ Foo.init({
lastname: Sequelize.STRING lastname: Sequelize.STRING
}, { }, {
sequelize, sequelize,
modelName: 'foo'
}); });
// Or with `sequelize.define` // Or with `sequelize.define`
...@@ -449,6 +453,11 @@ You can also influence the way Sequelize handles your column names: ...@@ -449,6 +453,11 @@ You can also influence the way Sequelize handles your column names:
```js ```js
class Bar extends Model {} class Bar extends Model {}
Bar.init({ /* bla */ }, { Bar.init({ /* bla */ }, {
// The name of the model. The model will be stored in `sequelize.models` under this name.
// This defaults to class name i.e. Bar in this case. This will control name of auto-generated
// foreignKey and association naming
modelName: 'bar',
// don't add the timestamp attributes (updatedAt, createdAt) // don't add the timestamp attributes (updatedAt, createdAt)
timestamps: false, timestamps: false,
......
...@@ -414,11 +414,11 @@ When you are retrieving data from the database there is a fair chance that you a ...@@ -414,11 +414,11 @@ When you are retrieving data from the database there is a fair chance that you a
```js ```js
class User extends Model {} class User extends Model {}
User.init({ name: Sequelize.STRING }, { sequelize }) User.init({ name: Sequelize.STRING }, { sequelize, modelName: 'user' })
class Task extends Model {} class Task extends Model {}
Task.init({ name: Sequelize.STRING }, { sequelize }) Task.init({ name: Sequelize.STRING }, { sequelize, modelName: 'task' })
class Tool extends Model {} class Tool extends Model {}
Tool.init({ name: Sequelize.STRING }, { sequelize }) Tool.init({ name: Sequelize.STRING }, { sequelize, modelName: 'tool' })
Task.belongsTo(User) Task.belongsTo(User)
User.hasMany(Task) User.hasMany(Task)
......
...@@ -44,6 +44,7 @@ Project.init({ ...@@ -44,6 +44,7 @@ Project.init({
} }
} }
sequelize, sequelize,
modelName: 'project'
} }
}); });
``` ```
......
...@@ -94,6 +94,7 @@ User.init({ ...@@ -94,6 +94,7 @@ User.init({
} }
}, { }, {
tableName: 'users', tableName: 'users',
modelName: 'user',
sequelize: sequelize, // this bit is important sequelize: sequelize, // this bit is important
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!