Skip to content

Commit

Permalink
docs: fix sequelize link (#2909)
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse authored Aug 16, 2018
1 parent ae9ec30 commit 72cd808
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions docs/source/en/tutorials/sequelize.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
title: Sequelize
---

[In the previous section] (./mysql.html), we showed how to access the database through the [egg-mysql] plugin in the framework. In some more complex applications, we may need an ORM framework to help us manage the data layer code. In the Node.js community, [sequelize] is a widely used ORM framework that supports multiple data sources such as MySQL, PostgreSQL, SQLite, and MSSQL.
[In the previous section](./mysql.html), we showed how to access the database through the [egg-mysql] plugin in the framework. In some more complex applications, we may need an ORM framework to help us manage the data layer code. In the Node.js community, [sequelize] is a widely used ORM framework that supports multiple data sources such as MySQL, PostgreSQL, SQLite, and MSSQL.

In this chapter, we will walk through the steps of how to use sequelize in an egg project by developing an example of doing CURD on the data in the `users` table in MySQL.

Expand Down Expand Up @@ -408,10 +408,10 @@ A more complete example can be found in [eggjs/examples/sequelize].

We also provide sequelize boilerplate that integrates the modules [egg-sequelize], [sequelize-cli] and [factory-girl] provided in this documentation. You can quickly initialize a new application based on it by `egg-init --type=sequelize`.

[mysql2](https://github.com/sidorares/node-mysql2)
[sequelize](http://docs.sequelizejs.com/)
[sequelize-cli](https://github.com/sequelize/cli)
[egg-sequelize](https://github.com/eggjs/egg-sequelize)
[Migrations](http://docs.sequelizejs.com/manual/tutorial/migrations.html)
[factory-girl](https://github.com/aexmachina/factory-girl)
[eggjs/examples/sequelize](https://github.com/eggjs/examples/tree/master/sequelize)
[mysql2]: https://github.com/sidorares/node-mysql2
[sequelize]: http://docs.sequelizejs.com/
[sequelize-cli]: https://github.com/sequelize/cli
[egg-sequelize]: https://github.com/eggjs/egg-sequelize
[Migrations]: http://docs.sequelizejs.com/manual/tutorial/migrations.html
[factory-girl]: https://github.com/aexmachina/factory-girl
[eggjs/examples/sequelize]: https://github.com/eggjs/examples/tree/master/sequelize
24 changes: 12 additions & 12 deletions docs/source/zh-cn/tutorials/sequelize.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ exports.sequelize = {

## 初始化数据库和 Migrations

接下来我们先暂时离开 egg 项目的代码,设计和初始化一下我们的数据库。首先我们通过 mysql 命令在本地快速创建开发和测试要用到的两个 database:
接下来我们先暂时离开 egg 项目的代码,设计和初始化一下我们的数据库。首先我们通过 mysql 命令在本地快速创建开发和测试要用到的两个 database:

```bash
mysql -u root -e 'CREATE DATABASE IF NOT EXISTS `egg-sequelize-doc-default`;'
Expand Down Expand Up @@ -185,7 +185,7 @@ npx sequelize db:migrate

## 编写代码

现在终于可以开始编写代码实现业务逻辑了,首先我们来在 `app/model/` 目录下编写 user 这个 Model:
现在终于可以开始编写代码实现业务逻辑了,首先我们来在 `app/model/` 目录下编写 user 这个 Model:

```js
'use strict';
Expand All @@ -205,7 +205,7 @@ module.exports = app => {
};
```

这个 Model 就可以在 Controller 和 Service 中通过 `app.model.User` 或者 `ctx.model.User` 访问到了,例如我们编写 `app/controller/users.js`
这个 Model 就可以在 Controller 和 Service 中通过 `app.model.User` 或者 `ctx.model.User` 访问到了,例如我们编写 `app/controller/users.js`

```js
// app/controller/users.js
Expand Down Expand Up @@ -278,7 +278,7 @@ module.exports = app => {
};
```

针对 `users` 表的 CURD 操作的接口就开发完了,为了验证代码逻辑是否正确,我们接下来需要编写单元测试来验证。
针对 `users` 表的 CURD 操作的接口就开发完了,为了验证代码逻辑是否正确,我们接下来需要编写单元测试来验证。

## 单元测试

Expand Down Expand Up @@ -316,7 +316,7 @@ module.exports = app => {
};
```

- 初始化文件 `test/.setup.js`,引入 factory,并确保测试执行完后清理数据,避免被影响
- 初始化文件 `test/.setup.js`,引入 factory,并确保测试执行完后清理数据,避免被影响

```js
const { app } = require('egg-mock/bootstrap');
Expand Down Expand Up @@ -407,10 +407,10 @@ describe('test/app/service/users.test.js', () => {

我们也提供了 sequelize 的脚手架,集成了文档中提供的 [egg-sequelize], [sequelize-cli][factory-girl] 等模块。可以通过 `egg-init --type=sequelize` 来基于它快速初始化一个新的应用。

[mysql2](https://github.com/sidorares/node-mysql2)
[sequelize](http://docs.sequelizejs.com/)
[sequelize-cli](https://github.com/sequelize/cli)
[egg-sequelize](https://github.com/eggjs/egg-sequelize)
[Migrations](http://docs.sequelizejs.com/manual/tutorial/migrations.html)
[factory-girl](https://github.com/aexmachina/factory-girl)
[eggjs/examples/sequelize](https://github.com/eggjs/examples/tree/master/sequelize)
[mysql2]: https://github.com/sidorares/node-mysql2
[sequelize]: http://docs.sequelizejs.com/
[sequelize-cli]: https://github.com/sequelize/cli
[egg-sequelize]: https://github.com/eggjs/egg-sequelize
[Migrations]: http://docs.sequelizejs.com/manual/tutorial/migrations.html
[factory-girl]: https://github.com/aexmachina/factory-girl
[eggjs/examples/sequelize]: https://github.com/eggjs/examples/tree/master/sequelize

0 comments on commit 72cd808

Please sign in to comment.