Skip to content

Commit

Permalink
docs(sequelize): replace findById with findByPk (#3700)
Browse files Browse the repository at this point in the history
findById method was replaced by findByPk in Sequelize v5.
  • Loading branch information
zuoqi705 authored and dead-horse committed May 15, 2019
1 parent 3fccb4f commit 9c23232
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/source/en/tutorials/sequelize.md
Expand Up @@ -227,7 +227,7 @@ class UserController extends Controller {

async show() {
const ctx = this.ctx;
ctx.body = await ctx.model.User.findById(toInt(ctx.params.id));
ctx.body = await ctx.model.User.findByPk(toInt(ctx.params.id));
}

async create() {
Expand All @@ -241,7 +241,7 @@ class UserController extends Controller {
async update() {
const ctx = this.ctx;
const id = toInt(ctx.params.id);
const user = await ctx.model.User.findById(id);
const user = await ctx.model.User.findByPk(id);
if (!user) {
ctx.status = 404;
return;
Expand All @@ -255,7 +255,7 @@ class UserController extends Controller {
async destroy() {
const ctx = this.ctx;
const id = toInt(ctx.params.id);
const user = await ctx.model.User.findById(id);
const user = await ctx.model.User.findByPk(id);
if (!user) {
ctx.status = 404;
return;
Expand Down
6 changes: 3 additions & 3 deletions docs/source/zh-cn/tutorials/sequelize.md
Expand Up @@ -226,7 +226,7 @@ class UserController extends Controller {

async show() {
const ctx = this.ctx;
ctx.body = await ctx.model.User.findById(toInt(ctx.params.id));
ctx.body = await ctx.model.User.findByPk(toInt(ctx.params.id));
}

async create() {
Expand All @@ -240,7 +240,7 @@ class UserController extends Controller {
async update() {
const ctx = this.ctx;
const id = toInt(ctx.params.id);
const user = await ctx.model.User.findById(id);
const user = await ctx.model.User.findByPk(id);
if (!user) {
ctx.status = 404;
return;
Expand All @@ -254,7 +254,7 @@ class UserController extends Controller {
async destroy() {
const ctx = this.ctx;
const id = toInt(ctx.params.id);
const user = await ctx.model.User.findById(id);
const user = await ctx.model.User.findByPk(id);
if (!user) {
ctx.status = 404;
return;
Expand Down

0 comments on commit 9c23232

Please sign in to comment.