remove unused conenction option.

add connection option documentation.
add few tests
This commit is contained in:
rusher
2018-03-15 16:10:14 +01:00
parent fd1d66afe9
commit dda1ed3d89
6 changed files with 137 additions and 17 deletions

View File

@ -57,6 +57,53 @@ var conn2 = mariadb.createConnection({socketPath: '/tmp/mysql.sock'});
var conn3 = mariadb.createConnection({host: 'mydb.com', port:9999});
```
### connection options
#### important option
* `user`: string. user
* `host`: string. IP or DNS of database server. default: 'localhost'
* `port`: integer. database server port number. default: 3306
* `database`: string. default database when establishing connection.
* `password`: string. user password
* `socketPath`: string. Permits connecting to the database via Unix domain socket or named pipe, if the server allows it.
* `compress`: boolean. exchanges with database must be gzip. (=> when database is not localhost). default: false
* `connectTimeout`: integer. connection timeout in ms. default: 10 000.
Support for big integer:
Javascript integer use IEEE-754 representation, meaning that integer not in ±9,007,199,254,740,991 range cannot be exactly represented.
MariaDB/MySQL server have data type that permit bigger integer.
For those integer that are not in [safe](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger) range default implementation will return an integer that may be not the exact representation.
2 options permit to have the exact value :
* `bigNumberStrings`: if integer is not in "safe" range, the value will be return as a string.
* `supportBigNumbers`: if integer is not in "safe" range, the value will be return as a [Long](https://www.npmjs.com/package/long) object.
#### ssl
//TODO describe all solutions
* `ssl`: string/object.
#### other option
* `charset`: string. define charset exchange with server. default: UTF8MB4_UNICODE_CI
* `dateStrings`: boolean. indicate if date must be retrived as string (not as date). default: false
* `debug`: boolean. when active, log all exchange wirh servers. default: false
* `foundRows`: boolean. active, update number correspond to update rows. disable indicate real rows changed. default: true.
* `multipleStatements`: boolean. Permit multi-queries like "insert into ab (i) values (1); insert into ab (i) values (2)". this may be **security risk** in case of sql injection. default: false
* `namedPlaceholders`: boolean. Permit using named placeholder, default: false
* `permitLocalInfile`: boolean. permit using LOAD DATA INFILE command.
this (ie: loading a file from the client) may be a security problem :
A "man in the middle" proxy server can change the actual file requested from the server so the client will send a local file to this proxy.
if someone can execute a query from the client, he can have access to any file on the client (according to the rights of the user running the client process).
default: false
* `timezone`: string. force using indicated timezone, not current node.js timezone. possible value are 'Z' (fot UTC), 'local' or '±HH:MM' format
* `nestTables`: boolean/string. resultset are presented by table to avoid results with colliding fields. default: false
* `rowsAsArray`: boolean. default rows are defined as a JSON object. when active row is an array. default false
## Query
`connection.query(sql[, values][,callback])`