Skip to content

Commit a80e892

Browse files
iyuqdead-horse
authored andcommitted
deps: update to use egg-sequelize 3.x (#33)
1 parent 34792ce commit a80e892

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

sequelize-example/app/model/post.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module.exports = app => {
44
const { STRING, INTEGER, DATE } = app.Sequelize;
55

6-
return app.model.define('post', {
6+
const Post = app.model.define('post', {
77
id: {
88
type: INTEGER,
99
primaryKey: true,
@@ -14,11 +14,11 @@ module.exports = app => {
1414
user_id: INTEGER,
1515
created_at: DATE,
1616
updated_at: DATE,
17-
}, {
18-
classMethods: {
19-
associate() {
20-
app.model.Post.belongsTo(app.model.User, { as: 'user', foreignKey: 'user_id' });
21-
},
22-
},
2317
});
18+
19+
Post.associate = function() {
20+
app.model.Post.belongsTo(app.model.User, { as: 'user', foreignKey: 'user_id' });
21+
};
22+
23+
return Post;
2424
};

sequelize-example/app/model/user.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module.exports = app => {
44
const { STRING, INTEGER, DATE } = app.Sequelize;
55

6-
return app.model.define('user', {
6+
const User = app.model.define('user', {
77
id: {
88
type: INTEGER,
99
primaryKey: true,
@@ -13,11 +13,11 @@ module.exports = app => {
1313
age: INTEGER,
1414
created_at: DATE,
1515
updated_at: DATE,
16-
}, {
17-
classMethods: {
18-
associate() {
19-
app.model.User.hasMany(app.model.Post, { as: 'posts', foreignKey: 'user_id' });
20-
},
21-
},
2216
});
17+
18+
User.prototype.associate = function() {
19+
app.model.User.hasMany(app.model.Post, { as: 'posts', foreignKey: 'user_id' });
20+
};
21+
22+
return User;
2323
};

sequelize-example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"private": true,
66
"dependencies": {
77
"egg": "^1.4.0",
8-
"egg-sequelize": "^2.1.4",
8+
"egg-sequelize": "^3.0.1",
99
"pg": "^6.2.4",
1010
"pg-hstore": "^2.3.2"
1111
},

0 commit comments

Comments
 (0)