Skip to content

Commit

Permalink
documentation: update documentation path pattern and add all *.md t…
Browse files Browse the repository at this point in the history
…o lint checker (#2049)

* documentation: move to `documentation`

* documentation: update the README documentation links

* documentation: update the zh-cn README documentation links

* documentation: update the Readme documentation links

* documentation: change the README documentation links to local branch

* documentation: change the Promise-Wrapper links to local branch

* documentation: change the zh-cn README documentation links to local branch

* documentation: change the documentation Readme links to local branch

* documentation: update the Promise-Wrapper link

* documentation: update the documentation link to `en`

* fix: eslint markdown rules

* fix: check for README.md in `lint:docs` script
  • Loading branch information
wellwelwel authored Jun 7, 2023
1 parent d3dd182 commit f930f6e
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 46 deletions.
14 changes: 14 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@
"prettier"
],
"plugins": ["@typescript-eslint"]
},
{
"files": ["**/*.md/*js"],
"rules": {
"no-undef": "off",
"no-unused-vars": "off",
"no-console": "off",
"no-unused-labels": "off",
"strict": "off",
"prefer-arrow-callback": "off"
},
"parserOptions": {
"sourceType": "module"
}
}
]
}
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[![Windows Build][appveyor-image]][appveyor-url]
[![License][license-image]][license-url]

English | [简体中文](./documentation_zh-cn/)
English | [简体中文](./documentation/zh-cn/)

> MySQL client for Node.js with focus on performance. Supports prepared statements, non-utf8 encodings, binary log protocol, compression, ssl [much more](https://github.com/sidorares/node-mysql2/tree/master/documentation)
> MySQL client for Node.js with focus on performance. Supports prepared statements, non-utf8 encodings, binary log protocol, compression, ssl [much more](./documentation/en)
__Table of contents__

Expand All @@ -32,14 +32,14 @@ MySQL2 project is a continuation of [MySQL-Native][mysql-native]. Protocol parse
MySQL2 is mostly API compatible with [mysqljs][node-mysql] and supports majority of features. MySQL2 also offers these additional features

- Faster / Better Performance
- [Prepared Statements](https://github.com/sidorares/node-mysql2/tree/master/documentation/Prepared-Statements.md)
- [Prepared Statements](./documentation/en/Prepared-Statements.md)
- MySQL Binary Log Protocol
- [MySQL Server](https://github.com/sidorares/node-mysql2/tree/master/documentation/MySQL-Server.md)
- [MySQL Server](./documentation/en/MySQL-Server.md)
- Extended support for Encoding and Collation
- [Promise Wrapper](https://github.com/sidorares/node-mysql2/tree/master/documentation/Promise-Wrapper.md)
- [Promise Wrapper](./documentation/en/Promise-Wrapper.md)
- Compression
- SSL and [Authentication Switch](https://github.com/sidorares/node-mysql2/tree/master/documentation/Authentication-Switch.md)
- [Custom Streams](https://github.com/sidorares/node-mysql2/tree/master/documentation/Extras.md)
- SSL and [Authentication Switch](./documentation/en/Authentication-Switch.md)
- [Custom Streams](./documentation/en/Extras.md)
- [Pooling](#using-connection-pools)

## Installation
Expand Down Expand Up @@ -145,18 +145,18 @@ You can use the pool in the same way as connections (using `pool.query()` and `p
```js
// For pool initialization, see above
pool.query("SELECT field FROM atable", function(err, rows, fields) {
// Connection is automatically released when query resolves
// Connection is automatically released when query resolves
})
```

Alternatively, there is also the possibility of manually acquiring a connection from the pool and returning it later:
```js
// For pool initialization, see above
pool.getConnection(function(err, conn) {
// Do something with the connection
conn.query(/* ... */);
// Don't forget to release the connection when finished!
pool.releaseConnection(conn);
// Do something with the connection
conn.query(/* ... */);
// Don't forget to release the connection when finished!
pool.releaseConnection(conn);
})
```

Expand Down Expand Up @@ -204,6 +204,7 @@ async function main() {
const promisePool = pool.promise();
// query database using promises
const [rows,fields] = await promisePool.query("SELECT 1");
}
```

MySQL2 exposes a .promise() function on Connections, to "upgrade" an existing non-promise connection to use promise
Expand Down Expand Up @@ -258,7 +259,7 @@ If you find any other incompatibility with [Node MySQL][node-mysql], Please repo

## Documentation

You can find more detailed documentation [here](https://github.com/sidorares/node-mysql2/tree/master/documentation). You should also check various code [examples](https://github.com/sidorares/node-mysql2/tree/master/examples) to understand advanced concepts.
You can find more detailed documentation [here](./documentation/en). You should also check various code [examples](./examples) to understand advanced concepts.

## Acknowledgements

Expand Down
10 changes: 0 additions & 10 deletions documentation/.eslintrc

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ co(function * () {
yield c.end();
});
```
Examples in [/examples/promise-co-await](https://github.com/sidorares/node-mysql2/tree/master/examples/promise-co-await)
Examples in [/examples/promise-co-await](../../examples/promise-co-await)
14 changes: 7 additions & 7 deletions documentation/Readme.md → documentation/en/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

Not only `Node-MySQL2` offers better performance over `node-mysql`, we also support these additional features.

- [Prepared Statements](https://github.com/sidorares/node-mysql2/tree/master/documentation/Prepared-Statements.md)
- [Promise Wrapper](https://github.com/sidorares/node-mysql2/tree/master/documentation/Promise-Wrapper.md)
- [Authentication Switch](https://github.com/sidorares/node-mysql2/tree/master/documentation/Authentication-Switch.md)
- [More Features](https://github.com/sidorares/node-mysql2/tree/master/documentation/Extras.md)
- [MySQL Server](https://github.com/sidorares/node-mysql2/tree/master/documentation/MySQL-Server.md)
- [Prepared Statements](./Prepared-Statements.md)
- [Promise Wrapper](./Promise-Wrapper.md)
- [Authentication Switch](./Authentication-Switch.md)
- [More Features](./Extras.md)
- [MySQL Server](./MySQL-Server.md)
- Pooling
- SSL
- MySQL Compression
- Binary Log Protocol Client

## Examples

Please check these [examples](https://github.com/sidorares/node-mysql2/tree/master/documentation/Examples.md) for `node-mysql2`.
Please check these [examples](./Examples.md) for `node-mysql2`.


## Known incompatibilities with `node-mysql`
Expand Down Expand Up @@ -48,4 +48,4 @@ You need to check corresponding field's zeroFill flag and convert to string manu
- https://gist.github.com/sidorares/ffe9ee9c423f763e3b6b
- `npm run benchmarks`
- [node-mysql-benchmarks](https://github.com/mscdex/node-mysql-benchmarks)
- try to run example [benchmarks](https://github.com/sidorares/node-mysql2/tree/master/benchmarks) on your system
- try to run example [benchmarks](../../benchmarks) on your system
27 changes: 14 additions & 13 deletions documentation_zh-cn/README.md → documentation/zh-cn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[![Windows Build][appveyor-image]][appveyor-url]
[![License][license-image]][license-url]

[English](../README.md) | 简体中文
[English](../..) | 简体中文

> 适用于Node.js的MySQL客户端,专注于性能优化。支持SQL预处理、非UTF-8编码支持、二进制文件编码支持、压缩和SSL等等 [查看更多](https://github.com/sidorares/node-mysql2/tree/master/documentation)
> 适用于Node.js的MySQL客户端,专注于性能优化。支持SQL预处理、非UTF-8编码支持、二进制文件编码支持、压缩和SSL等等 [查看更多](../en)
__目录__

Expand All @@ -32,14 +32,14 @@ MySQL2 项目是 [MySQL-Native][mysql-native] 的延续。 协议解析器代码
MySQL2 大部分 API 与 [mysqljs][node-mysql] 兼容,并支持大部分功能。 MySQL2 还提供了更多的附加功能

- 更快、更好的性能
- [支持预处理](https://github.com/sidorares/node-mysql2/tree/master/documentation/Prepared-Statements.md)
- [支持预处理](../en/documentation/en/Prepared-Statements.md)
- MySQL二进制日志协议
- [MySQL Server](https://github.com/sidorares/node-mysql2/tree/master/documentation/MySQL-Server.md)
- [MySQL Server](../en/documentation/en/MySQL-Server.md)
- 对编码和排序规则有很好的支持
- [Promise封装](https://github.com/sidorares/node-mysql2/tree/master/documentation/Promise-Wrapper.md)
- [Promise封装](../en/documentation/en/Promise-Wrapper.md)
- 支持压缩
- SSL 和 [Authentication Switch](https://github.com/sidorares/node-mysql2/tree/master/documentation/Authentication-Switch.md)
- [自定义流](https://github.com/sidorares/node-mysql2/tree/master/documentation/Extras.md)
- SSL 和 [Authentication Switch](../en/documentation/en/Authentication-Switch.md)
- [自定义流](../en/documentation/en/Extras.md)
- [连接池](#using-connection-pools)

## 安装
Expand Down Expand Up @@ -143,18 +143,18 @@ const pool = mysql.createPool({
```js
// For pool initialization, see above
pool.query("SELECT field FROM atable", function(err, rows, fields) {
// Connection is automatically released when query resolves
// Connection is automatically released when query resolves
})
```

或者,也可以手动从池中获取连接并稍后返回:
```js
// For pool initialization, see above
pool.getConnection(function(err, conn) {
// Do something with the connection
conn.query(/* ... */);
// Don't forget to release the connection when finished!
pool.releaseConnection(conn);
// Do something with the connection
conn.query(/* ... */);
// Don't forget to release the connection when finished!
pool.releaseConnection(conn);
})
```

Expand Down Expand Up @@ -202,6 +202,7 @@ async function main() {
const promisePool = pool.promise();
// query database using promises
const [rows,fields] = await promisePool.query("SELECT 1");
}
```

MySQL2 在 Connections 上公开了一个 .promise*()函数,以“升级”现有的 non-promise 连接以使用 Promise
Expand Down Expand Up @@ -254,7 +255,7 @@ MySQL2大部分的API与 [Node MySQL][node-mysql] 基本上相同,你应该查

## 文档

你可以在[这里](https://github.com/sidorares/node-mysql2/tree/master/documentation)获得更多的详细文档,并且你应该查阅各种代码[示例](https://github.com/sidorares/node-mysql2/tree/master/examples)来获得更高级的概念。
你可以在[这里](../en/documentation/en)获得更多的详细文档,并且你应该查阅各种代码[示例](../en/examples)来获得更高级的概念。

## 鸣谢

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Query extends Command {

then() {
const err =
"You have tried to call .then(), .catch(), or invoked await on the result of query that is not a promise, which is a programming error. Try calling con.promise().query(), or require('mysql2/promise') instead of 'mysql2' for a promise-compatible version of the query interface. To learn how to use async/await or Promises check out documentation at https://www.npmjs.com/package/mysql2#using-promise-wrapper, or the mysql2 documentation at https://github.com/sidorares/node-mysql2/tree/master/documentation/Promise-Wrapper.md";
"You have tried to call .then(), .catch(), or invoked await on the result of query that is not a promise, which is a programming error. Try calling con.promise().query(), or require('mysql2/promise') instead of 'mysql2' for a promise-compatible version of the query interface. To learn how to use async/await or Promises check out documentation at https://www.npmjs.com/package/mysql2#using-promise-wrapper, or the mysql2 documentation at https://github.com/sidorares/node-mysql2/tree/master/documentation/en/Promise-Wrapper.md";
// eslint-disable-next-line
console.log(err);
throw new Error(err);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"lint": "npm run lint:docs && npm run lint:code",
"lint:code": "eslint index.js promise.js \"lib/**/*.js\" \"test/**/*.js\" \"benchmarks/**/*.js\"",
"lint:docs": "eslint Contributing.md \"documentation/**/*.md\" \"examples/*.js\"",
"lint:docs": "eslint Contributing.md README.md \"documentation/**/*.md\" \"examples/*.js\"",
"test": "node ./test/run.js",
"test:tsc-build": "cd \"test/tsc-build\" && npx tsc -p \"tsconfig.json\"",
"coverage-test": "c8 -r cobertura -r lcov -r text node ./test/run.js",
Expand Down

0 comments on commit f930f6e

Please sign in to comment.