diff --git a/docs/source/en/tutorials/sequelize.md b/docs/source/en/tutorials/sequelize.md index ca626a6c52..4e7d5ff565 100644 --- a/docs/source/en/tutorials/sequelize.md +++ b/docs/source/en/tutorials/sequelize.md @@ -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. @@ -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 diff --git a/docs/source/zh-cn/tutorials/sequelize.md b/docs/source/zh-cn/tutorials/sequelize.md index df192724fc..45f262391e 100644 --- a/docs/source/zh-cn/tutorials/sequelize.md +++ b/docs/source/zh-cn/tutorials/sequelize.md @@ -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`;' @@ -185,7 +185,7 @@ npx sequelize db:migrate ## 编写代码 -现在终于可以开始编写代码实现业务逻辑了,首先我们来在 `app/model/` 目录下编写 user 这个 Model: +现在终于可以开始编写代码实现业务逻辑了,首先我们来在 `app/model/` 目录下编写 user 这个 Model: ```js 'use strict'; @@ -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 @@ -278,7 +278,7 @@ module.exports = app => { }; ``` -针对 `users` 表的 CURD 操作的接口就开发完了,为了验证代码逻辑是否正确,我们接下来需要编写单元测试来验证。 +针对 `users` 表的 CURD 操作的接口就开发完了,为了验证代码逻辑是否正确,我们接下来需要编写单元测试来验证。 ## 单元测试 @@ -316,7 +316,7 @@ module.exports = app => { }; ``` -- 初始化文件 `test/.setup.js`,引入 factory,并确保测试执行完后清理数据,避免被影响 +- 初始化文件 `test/.setup.js`,引入 factory,并确保测试执行完后清理数据,避免被影响 ```js const { app } = require('egg-mock/bootstrap'); @@ -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