Skip to content

Commit

Permalink
feat: upgrade sequelize version (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
whxaxes committed Jun 18, 2019
1 parent 0730b76 commit 1fd7cd5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sequelize-ts/package.json
Expand Up @@ -15,7 +15,7 @@
"egg-mock": "^3.19.2",
"factory-girl": "^5.0.2",
"lodash": "^4.17.10",
"sequelize-cli": "^4.0.0"
"sequelize-cli": "^5.0.0"
},
"engines": {
"node": ">=8.9.0"
Expand Down
2 changes: 1 addition & 1 deletion sequelize/app/service/post.js
Expand Up @@ -19,7 +19,7 @@ class Post extends Service {
}

async find(id) {
const post = await this.ctx.model.Post.findById(id, {
const post = await this.ctx.model.Post.findByPk(id, {
include: [{
model: this.ctx.model.User,
as: 'user',
Expand Down
6 changes: 3 additions & 3 deletions sequelize/app/service/user.js
Expand Up @@ -12,7 +12,7 @@ class User extends Service {
}

async find(id) {
const user = await this.ctx.model.User.findById(id);
const user = await this.ctx.model.User.findByPk(id);
if (!user) {
this.ctx.throw(404, 'user not found');
}
Expand All @@ -24,15 +24,15 @@ class User extends Service {
}

async update({ id, updates }) {
const user = await this.ctx.model.User.findById(id);
const user = await this.ctx.model.User.findByPk(id);
if (!user) {
this.ctx.throw(404, 'user not found');
}
return user.update(updates);
}

async del(id) {
const user = await this.ctx.model.User.findById(id);
const user = await this.ctx.model.User.findByPk(id);
if (!user) {
this.ctx.throw(404, 'user not found');
}
Expand Down
4 changes: 2 additions & 2 deletions sequelize/package.json
Expand Up @@ -5,7 +5,7 @@
"private": true,
"dependencies": {
"egg": "^2.10.0",
"egg-sequelize": "^4.0.1",
"egg-sequelize": "^5.0.1",
"mysql2": "^1.6.1"
},
"devDependencies": {
Expand All @@ -14,7 +14,7 @@
"egg-mock": "^3.19.2",
"factory-girl": "^5.0.2",
"lodash": "^4.17.10",
"sequelize-cli": "^4.0.0"
"sequelize-cli": "^5.0.0"
},
"engines": {
"node": ">=8.9.0"
Expand Down
2 changes: 1 addition & 1 deletion sequelize/test/app/service/post.test.js
Expand Up @@ -144,7 +144,7 @@ describe('test/app/service/post.test.js', () => {

it('should throw 404 when id not found', async () => {
try {
await ctx.service.post.destroy({ id: 1 });
await ctx.service.post.destroy({ id: 1, user_id: 1 });
throw new Error('should not execute');
} catch (error) {
assert(error.status === 404);
Expand Down

0 comments on commit 1fd7cd5

Please sign in to comment.