Skip to content

Commit 6ea946f

Browse files
committed
update doc
1 parent 2b747ba commit 6ea946f

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

README.md

+43-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,50 @@
11
# think-session-mysql
22
Use Mysql to store session for ThinkJS
33

4-
## Create Database
54

5+
## Install
6+
7+
```
8+
npm install think-session-mysql
9+
```
10+
11+
## How to use
12+
13+
config file `src/config/adapter.js`, add options:
14+
15+
```js
16+
const mysqlSession = require('think-session-mysql');
17+
exports.session = {
18+
type: 'mysql',
19+
common: {
20+
cookie: {
21+
name: 'thinkjs',
22+
//maxAge: '',
23+
//expires: '',
24+
path: '/', //a string indicating the path of the cookie
25+
//domain: '',
26+
//secure: false,
27+
//keys: [],
28+
httpOnly: true,
29+
sameSite: false,
30+
signed: false,
31+
overwrite: false
32+
}
33+
},
34+
mysql:{
35+
handle:mysqlSession,
36+
database:'think_test',
37+
prefix:'think_',
38+
host:'127.0.0.1',
39+
port:'3306',
40+
user:'root',
41+
password:''
42+
}
43+
}
44+
```
45+
46+
## Create Database
47+
`think_` is the prefix in `adapter.js`
648
```
749
DROP TABLE IF EXISTS `think_session`;
850
CREATE TABLE `think_session` (
@@ -15,5 +57,3 @@ Use Mysql to store session for ThinkJS
1557
KEY `expire` (`expire`)
1658
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1759
```
18-
19-
`think_` is the prefix in `db.config`

0 commit comments

Comments
 (0)