Skip to content

Commit b5cd244

Browse files
authored
Merge pull request #14 from sudomonikers/convert-dates-to-strings
add ability to not auto cast returns to their javascript type, and al…
2 parents c80f0a3 + 9263531 commit b5cd244

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Wrapper utility to easily manage multiple data sources and pooled connections.
44

55
## Error Returns
66

7-
By default, all errors occurring during a query are returned. If you want to be extra-safe in a production environment, you can set `HIDE_DB_ERRORS` value on the root `config` passed to the connector on initialization. When you do this, all errors will be logged, but none returned when a query error occurs.
7+
By default, all errors occurring during a query are returned. If you want to be extra-safe in a production environment, you can set `HIDE_DB_ERRORS` value on the root `config` passed to the connector on initialization. When you do this, all errors will be logged, but none returned when a query error occurs.
88

99
## SSL Settings
1010

@@ -24,4 +24,10 @@ By default, when specifying an SSL object, the mysql connector will reject unaut
2424
SSL: {
2525
REJECT_UNAUTHORIZED: false // not recommended
2626
}
27-
```
27+
```
28+
29+
#Data Typing Options
30+
31+
This connector gives you a few options for configuring how data is returned from the connector. 'typeCast' defaults to true, and converts
32+
data from the database to its javascript equivalent. For example, it will convert DATETIME SQL objects to a DATE javascript type.
33+
You can also set 'dateStrings' which defaults to false. If you set it to true it will override typeCast and force date returns to be a string instead of a DATE type.

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ exports.createPool = async (poolName) => {
2626
port: srcCfg.PORT,
2727
multipleStatements: srcCfg.ALLOW_MULTI_STATEMENTS || false,
2828
timezone: srcCfg.TIMEZONE || 'local',
29+
typeCast: srcCfg.TYPE_CAST || true,
30+
dateStrings: srcCfg.DATE_STRINGS || false
2931
};
3032

3133
if (srcCfg.SSL) {

0 commit comments

Comments
 (0)