Skip to content

Commit 5ea83ef

Browse files
authored
fix-sequelize-ts: SequelizeDatabaseError: Column 'id' in field list is ambiguous (#116)
1 parent f94710f commit 5ea83ef

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sequelize-ts/app/model/post.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Application } from 'egg';
55
export default function(app: Application) {
66
const { STRING, INTEGER, DATE } = app.Sequelize;
77

8-
const Post = app.model.define('post', {
8+
const Model = app.model.define('post', {
99
id: {
1010
type: INTEGER,
1111
primaryKey: true,
@@ -18,7 +18,7 @@ export default function(app: Application) {
1818
updated_at: DATE(6),
1919
});
2020

21-
return class extends Post {
21+
return class Post extends Model {
2222
static associate() {
2323
app.model.Post.belongsTo(app.model.User, { as: 'user', foreignKey: 'user_id' });
2424
}

sequelize-ts/app/model/user.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Application } from 'egg';
44

55
export default function(app: Application) {
66
const { STRING, INTEGER, DATE } = app.Sequelize;
7-
const User = app.model.define('user', {
7+
const Model = app.model.define('user', {
88
id: {
99
type: INTEGER,
1010
primaryKey: true,
@@ -16,7 +16,7 @@ export default function(app: Application) {
1616
updated_at: DATE(6),
1717
});
1818

19-
return class extends User {
19+
return class User extends Model {
2020
static associate() {
2121
app.model.User.hasMany(app.model.Post, { as: 'posts' });
2222
}

0 commit comments

Comments
 (0)