multi-db-orm 2.0.3 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/engines/oracledb.js +17 -2
- package/package.json +1 -1
- package/test/test.js +3 -1
package/engines/oracledb.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
2
|
const { MultiDbORM } = require("./multidb");
|
|
3
3
|
var fs = require('fs')
|
|
4
|
+
const os = require('os');
|
|
4
5
|
|
|
5
6
|
class OracleDB extends MultiDbORM {
|
|
6
7
|
|
|
@@ -26,11 +27,13 @@ class OracleDB extends MultiDbORM {
|
|
|
26
27
|
password,
|
|
27
28
|
net_service_name,
|
|
28
29
|
wallet_dir,
|
|
29
|
-
connection_pool_name
|
|
30
|
+
connection_pool_name,
|
|
31
|
+
wallet_password }) {
|
|
30
32
|
super()
|
|
31
33
|
const oracledb = require('oracledb')
|
|
32
34
|
const oracleInstantClient = require("oracle-instantclient");
|
|
33
|
-
|
|
35
|
+
if (!wallet_password)
|
|
36
|
+
wallet_password = password
|
|
34
37
|
process.env.LD_LIBRARY_PATH = oracleInstantClient.path
|
|
35
38
|
process.env.TS_ADMIN = wallet_dir
|
|
36
39
|
oracledb.initOracleClient({
|
|
@@ -44,10 +47,22 @@ class OracleDB extends MultiDbORM {
|
|
|
44
47
|
this.connection_pool_name = connection_pool_name || username
|
|
45
48
|
this.db = oracledb
|
|
46
49
|
this.schema = username
|
|
50
|
+
|
|
51
|
+
let sqlnetora = path.join(wallet_dir, 'sqlnet.ora')
|
|
52
|
+
let configString = fs.readFileSync(sqlnetora).toString()
|
|
53
|
+
const regex = /DIRECTORY="([^"]*)"/;
|
|
54
|
+
let walletDirPath = wallet_dir
|
|
55
|
+
if (os.platform() == 'win32')
|
|
56
|
+
walletDirPath = wallet_dir.split("\\").join("\\\\")
|
|
57
|
+
configString = configString.replace(regex, `DIRECTORY="${walletDirPath}"`);
|
|
58
|
+
fs.writeFileSync(sqlnetora, configString)
|
|
59
|
+
|
|
47
60
|
this.pool_creation = oracledb.createPool({
|
|
48
61
|
user: username,
|
|
49
62
|
password: password,
|
|
50
63
|
configDir: wallet_dir,
|
|
64
|
+
walletLocation: wallet_dir,
|
|
65
|
+
walletPassword: wallet_password,
|
|
51
66
|
connectString: net_service_name,
|
|
52
67
|
poolAlias: this.connection_pool_name
|
|
53
68
|
}).then(async (pool) => {
|
package/package.json
CHANGED
package/test/test.js
CHANGED
|
@@ -185,7 +185,9 @@ async function testMongo() {
|
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
async function testOracleDb() {
|
|
188
|
-
|
|
188
|
+
let creds = require('../creds/oracle/creds.json')
|
|
189
|
+
creds.wallet_dir = path.join(__dirname, '../creds/oracle')
|
|
190
|
+
var oracledb = new OracleDB(creds);
|
|
189
191
|
console.log(oracledb.metrics.getStatus())
|
|
190
192
|
var gm = new Game('IndVSPak', Date.now(), 'Dhoni', 67.33, 'paid')
|
|
191
193
|
gm.completed = true
|