diff --git a/sequelize-ts/app/model/post.ts b/sequelize-ts/app/model/post.ts index 4a1e9620..0b8fb663 100644 --- a/sequelize-ts/app/model/post.ts +++ b/sequelize-ts/app/model/post.ts @@ -5,7 +5,7 @@ import { Application } from 'egg'; export default function(app: Application) { const { STRING, INTEGER, DATE } = app.Sequelize; - const Post = app.model.define('post', { + const Model = app.model.define('post', { id: { type: INTEGER, primaryKey: true, @@ -18,7 +18,7 @@ export default function(app: Application) { updated_at: DATE(6), }); - return class extends Post { + return class Post extends Model { static associate() { app.model.Post.belongsTo(app.model.User, { as: 'user', foreignKey: 'user_id' }); } diff --git a/sequelize-ts/app/model/user.ts b/sequelize-ts/app/model/user.ts index 6f25412d..cee907ce 100644 --- a/sequelize-ts/app/model/user.ts +++ b/sequelize-ts/app/model/user.ts @@ -4,7 +4,7 @@ import { Application } from 'egg'; export default function(app: Application) { const { STRING, INTEGER, DATE } = app.Sequelize; - const User = app.model.define('user', { + const Model = app.model.define('user', { id: { type: INTEGER, primaryKey: true, @@ -16,7 +16,7 @@ export default function(app: Application) { updated_at: DATE(6), }); - return class extends User { + return class User extends Model { static associate() { app.model.User.hasMany(app.model.Post, { as: 'posts' }); }