idb-pconnector
Advanced tools
Comparing version 1.0.5 to 1.0.6
# idb-pconnector change log | ||
# 1.0.6 | ||
Add implementation of setLibraryList API see PR [#39](https://github.com/IBM/nodejs-idb-pconnector/pull/39) | ||
# 1.0.5 | ||
@@ -3,0 +5,0 @@ Patched `prepareExecute` issue outlined in [#40](https://github.com/IBM/nodejs-idb-pconnector/issues/40) |
@@ -15,2 +15,3 @@ # **API Documentation** | ||
- [**Connection.validStmt(sql)**](#connectionvalidstmtsql) | ||
- [**Connection.setLibraryList(list)**](#connectionsetlibrarylistlist) | ||
- [**Class: Statement**](#class-statement) | ||
@@ -158,3 +159,10 @@ - [**Constructor: Statement(connection)**](#constructor-statementconnection) | ||
## **Connection.setLibraryList(list)** | ||
Change to system naming and set the library list (using `CHGLIBL`) of the connection. | ||
**Parameters**: | ||
- **list**: `Array` of strings where each element in the array is a library. | ||
# **Class: Statement** | ||
@@ -161,0 +169,0 @@ |
@@ -1,2 +0,2 @@ | ||
const { dbconn } = require('idb-connector'); | ||
const { dbconn, SQL_ATTR_DBC_SYS_NAMING, SQL_TRUE } = require('idb-connector'); | ||
const Statement = require('./statement'); | ||
@@ -166,4 +166,18 @@ | ||
} | ||
/** | ||
* Change to system naming and set the library list (using `CHGLIBL`) of the connection. | ||
* @param {Array} list - The library list entries | ||
* @memberof Connection | ||
*/ | ||
async setLibraryList(list) { | ||
const conn = this.dbconn; | ||
await conn.setConnAttr(SQL_ATTR_DBC_SYS_NAMING, SQL_TRUE); | ||
const statement = new Statement(this); | ||
await statement.exec(`CALL QSYS2.QCMDEXC('CHGLIBL LIBL(${list.join(' ')})')`); | ||
await statement.close(); | ||
} | ||
} | ||
module.exports = Connection; |
{ | ||
"name": "idb-pconnector", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Promise based DB2 Connector for IBM i", | ||
@@ -5,0 +5,0 @@ "main": "lib/idb-pconnector.js", |
@@ -21,2 +21,3 @@ # **idb-pconnector - Promise-based DB2 Connector for IBM i** <!-- omit in toc --> | ||
- [runSql](#runsql) | ||
- [setLibraryList](#setlibrarylist) | ||
- [**Documentation**](#documentation) | ||
@@ -185,2 +186,25 @@ - [**License**](#license) | ||
### setLibraryList | ||
Change to system naming and set the library list (using `CHGLIBL`) of the connection. | ||
```javascript | ||
const { Connection } = require('./lib/idb-pconnector.js'); | ||
async function setLibListExample() { | ||
const connection = new Connection({ url: '*LOCAL' }); | ||
await connection.setLibraryList(['QIWS', 'QXMLSERV']); | ||
const statement = connection.getStatement(); | ||
const results = await statement.exec('SELECT * FROM QCUSTCDT'); | ||
console.log(`results:\n ${JSON.stringify(results)}`); | ||
await statement.close(); | ||
} | ||
setLibListExample().catch((error) => { | ||
console.error(error); | ||
}); | ||
``` | ||
# **Documentation** | ||
@@ -187,0 +211,0 @@ |
@@ -146,2 +146,18 @@ /* | ||
}); | ||
describe('setLibraryList', () => { | ||
it('sets the user portion of the library list for the current connection', async () => { | ||
const dbConn = new Connection({ url: '*LOCAL' }); | ||
const statement = dbConn.getStatement(); | ||
await dbConn.setLibraryList(['QIWS', 'QXMLSERV']); | ||
const after = await statement.exec("SELECT * from qsys2.library_list_info WHERE TYPE = 'USER'"); | ||
expect(after).to.be.a('array'); | ||
expect(after.length).to.equal(2); | ||
expect(after[0]).to.be.a('object'); | ||
expect(after[0].SCHEMA_NAME).to.equal('QIWS'); | ||
expect(after[1]).to.be.a('object'); | ||
expect(after[1].SCHEMA_NAME).to.equal('QXMLSERV'); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96803
1818
218