Skip to content

Commit

Permalink
fix-sequelize-ts: SequelizeDatabaseError: Column 'id' in field list i…
Browse files Browse the repository at this point in the history
…s ambiguous (#116)
  • Loading branch information
leopoldchen authored Dec 25, 2023
1 parent f94710f commit 5ea83ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sequelize-ts/app/model/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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' });
}
Expand Down
4 changes: 2 additions & 2 deletions sequelize-ts/app/model/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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' });
}
Expand Down

0 comments on commit 5ea83ef

Please sign in to comment.