Comparing version 3.1.2 to 4.0.0
154
CHANGELOG.md
# Change Log | ||
## node-oracledb v4.0.0 (25 Jul 2019) | ||
- Refactored the node-oracledb implementation to use | ||
[N-API](https://nodejs.org/api/n-api.html) in place of | ||
[NAN](https://github.com/nodejs/nan). | ||
- Node-oracledb 4 requires Node.js 8.16 or Node.js 10.16, or higher. Node.js 8.16, 10.16, 11.12 and 12 contain an important N-API performance fix. | ||
- N-API allows node-oracledb binaries to be portable between Node.js versions on a given operating system, subject to N-API compatibility. Node-oracledb uses N-API version 4. | ||
- Oracle Client libraries are still required at runtime. These can be from Oracle Instant Client, the full Oracle Client, or an Oracle Database installation. | ||
- The string representation of classes has changed to `[object Object]` as a consequence of using N-API. Use `Object.getPrototypeOf()` to get class information. | ||
- The C compiler required for building from source code no longer needs C++11 compatibility. The node-oracledb source code is now pure C. | ||
- Added support for querying and binding [Oracle Database Objects and | ||
Collections](https://oracle.github.io/node-oracledb/doc/api.html#objects). | ||
- Added support for [Oracle Advanced Queuing (AQ)](https://oracle.github.io/node-oracledb/doc/api.html#aq): | ||
- Added support for "RAW" queues, allowing String and Buffer | ||
messages to be used. | ||
- Added support for object queues, allowing Oracle Database object | ||
messages to be used. | ||
- Added support for notifications with `oracledb.SUBSCR_NAMESPACE_AQ`. | ||
- Added support for [Implicit | ||
Results](https://oracle.github.io/node-oracledb/doc/api.html#implicitresults), | ||
allowing query results to be returned from PL/SQL without needing | ||
parameters or bind variables. | ||
- Added asynchronous method | ||
[`lob.getData()`](https://oracle.github.io/node-oracledb/doc/api.html#lobgetdata) | ||
to return all data from a Lob readable stream. | ||
- Added a new `dbTypeName` attribute to [`extendedMetaData` | ||
output](https://oracle.github.io/node-oracledb/doc/api.html#execmetadata). | ||
It contains the name of the type the column has in the database, | ||
such as "VARCHAR2". | ||
- Enhanced BIND_IN of PL/SQL Collection Associative Arrays (Index-by) | ||
so a bind definition object can be omitted (see | ||
[#1039](https://github.com/oracle/node-oracledb/issues/1039)). | ||
- Continuous Query Notification (CQN) Improvements: | ||
- Added support for getting the [registration | ||
id](https://oracle.github.io/node-oracledb/doc/api.html#consubscribecallback) | ||
for CQN subscriptions. | ||
- Added support and message type constants for database startup | ||
and shutdown events. | ||
- Fixed a crash that occurred when unsubscribing from CQN while | ||
notifications were ongoing ([ODPI-C | ||
change](https://github.com/oracle/odpi/commit/b96b11b7fe58f32f011c7f7419555e40268d5bf4)). | ||
- Added | ||
[`connection.currentSchema`](https://oracle.github.io/node-oracledb/doc/api.html#propconncurrentschema) | ||
for setting the schema qualifier to be used when a qualifier is | ||
omitted in SQL statements. This is an efficient alternative to | ||
`ALTER SESSION SET CURRENT_SCHEMA`. | ||
- Renumbered [node-oracledb Type | ||
Constants](https://oracle.github.io/node-oracledb/doc/api.html#oracledbconstantsnodbtype) | ||
and [Oracle Database Type | ||
Constants](https://oracle.github.io/node-oracledb/doc/api.html#oracledbconstantsdbtype) | ||
to allow for future enhancements. | ||
- Introduced [Query `outFormat` | ||
Constants](https://oracle.github.io/node-oracledb/doc/api.html#oracledbconstantsoutformat) | ||
`oracledb.OUT_FORMAT_ARRAY` and `oracledb.OUT_FORMAT_OBJECT`. The | ||
previous constants `oracledb.ARRAY` and `oracledb.OBJECT` are | ||
deprecated but still usable. | ||
- Improved the performance of [`oracledb.outFormat`](#propdboutformat) mode `oracledb.OUT_FORMAT_OBJECT`. | ||
- Improved the fetch performance of LOBs in some cases by reducing the | ||
number of round-trips required between node-oracledb and Oracle | ||
Database ([ODPI-C | ||
change](https://github.com/oracle/odpi/commit/58e6a07ff5bb428a09068456ef5231884fcb77db)). | ||
- Change the | ||
[`events`](https://oracle.github.io/node-oracledb/doc/api.html#propdbevents) | ||
default to *true*. | ||
- Updated the JavaScript syntax in class implementations. | ||
- Class methods are now configurable. For example via | ||
`Object.defineProperty`. | ||
- Error handling changes: | ||
- Corrected the error message returned when invalid types are used for | ||
boolean options. | ||
- Standardized error messages for incorrect function parameters. Now | ||
NJS-005 and NJS-007 are used in place of NJS-006 and NJS-008, | ||
respectively. | ||
- Exceptions from user getters for parameter object attribute access | ||
are now passed through the error callback. | ||
- The NJS-014 error when setting a read-only property was replaced | ||
with a standard JavaScript message. | ||
- When passing 0 or a negative value for the number of iterations to | ||
`connection.executeMany()`, errors now occur through the error callback. | ||
- Some error numbers may have changed due to code refactoring. | ||
Some message text was updated. | ||
- [SODA](https://oracle.github.io/node-oracledb/doc/api.html#sodaoverview) changes: | ||
- Added SODA bulk insert methods | ||
[`sodaCollection.insertMany()`](https://oracle.github.io/node-oracledb/doc/api.html#sodacollinsertmany) | ||
and | ||
[`sodaCollection.insertManyAndGet()`](https://oracle.github.io/node-oracledb/doc/api.html#sodacollinsertmanyandget). | ||
- Document that the general SODA API is out of Preview status when | ||
using Oracle Client 18.5 or Oracle Client 19.3, or later. The | ||
new node-oracledb 4.0 methods `sodaCollection.insertMany()` and | ||
`sodaCollection.insertManyAndGet()` are in Preview status and | ||
should not be used in production. | ||
- Corrected the type of | ||
[`sodaCollection.metaData`](https://oracle.github.io/node-oracledb/doc/api.html#sodacollectionpropmetadata). | ||
It is now an Object, as was documented. | ||
- Corrected processing of the `force` option in SODA [`sodaCollection.dropIndex()`](https://oracle.github.io/node-oracledb/doc/api.html#sodacolldropindex). | ||
- Corrected the error message parameter number for SODA | ||
[`sodaDatabase.getCollectionNames()`](https://oracle.github.io/node-oracledb/doc/api.html#sodadbgetcollectionnames). | ||
- Fixed writing of multi-byte characters to CLOBs when multiple writes | ||
are required. | ||
- Fixed a crash occurring when draining the connection pool ([ODPI-C | ||
change](https://github.com/oracle/odpi/commit/https://github.com/oracle/odpi/commit/7666dc3208087383f7f0f5e49c1ee423cb154997)). | ||
- Corrected `pool.status` to be read-only, as was documented. | ||
- Updated documentation. | ||
- Added new tests. | ||
- Added new examples. Updated existing examples to the Node.js 8 Async/Await style of programming. | ||
## node-oracledb v3.1.2 (22 Feb 2019) | ||
@@ -9,3 +155,3 @@ | ||
- Fixed a CQN race condition to prevent a crash when a multiple | ||
`conn.unsubscribe()` calls are made on the same subscription. | ||
`connection.unsubscribe()` calls are made on the same subscription. | ||
@@ -17,3 +163,3 @@ - Improved validation of `executeMany()` arguments to prevent a crash. | ||
- Correct the DPI-1050 error text displayed when the Oracle Client | ||
- Corrected the DPI-1050 error text displayed when the Oracle Client | ||
libraries are too old ([ODPI-C change](https://github.com/oracle/odpi/commit/d2fea3801286d054e18b0102e60a69907b7faa9a)). | ||
@@ -132,3 +278,3 @@ | ||
- Added new APIs for Simple Oracle Document Access | ||
([SODA](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#sodaoverview)), | ||
([SODA](https://oracle.github.io/node-oracledb/doc/api.html#sodaoverview)), | ||
available when using Oracle Database 18.3 and Oracle client | ||
@@ -138,3 +284,3 @@ libraries version 18.3, or later. | ||
- Added a `drainTime` argument to | ||
[`pool.close()`](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#poolclose), | ||
[`pool.close()`](https://oracle.github.io/node-oracledb/doc/api.html#poolclose), | ||
allowing pools to be force-closed after a specified number of | ||
@@ -141,0 +287,0 @@ seconds. PR #950 (Danilo Silva). |
@@ -1,82 +0,33 @@ | ||
/* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. */ | ||
// Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved | ||
/****************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
'use strict'; | ||
var resultset = require('./resultset.js'); | ||
var QueryStream = require('./querystream.js'); | ||
var nodbUtil = require('./util.js'); | ||
var sodaDatabase = require ('./sodaDatabase.js' ) ; | ||
const BaseDbObject = require('./dbObject.js'); | ||
const EventEmitter = require('events'); | ||
const QueryStream = require('./querystream.js'); | ||
const nodbUtil = require('./util.js'); | ||
var executePromisified; | ||
var executeManyPromisified; | ||
var getStatementInfoPromisified; | ||
var commitPromisified; | ||
var createLobPromisified; | ||
var rollbackPromisified; | ||
var closePromisified; | ||
var breakPromisified; | ||
var changePasswordPromisified; | ||
var pingPromisified; | ||
var subscribePromisified; | ||
var unsubscribePromisified; | ||
// The queryStream function is similar to execute except that it immediately | ||
// returns a QueryStream. | ||
function queryStream(sql, binding, options) { | ||
var self = this; | ||
var stream; | ||
nodbUtil.assert(arguments.length > 0 && arguments.length < 4, 'NJS-009'); | ||
nodbUtil.assert(typeof sql === 'string', 'NJS-006', 1); | ||
if (binding) { | ||
nodbUtil.assert(nodbUtil.isObjectOrArray(binding), 'NJS-006', 2); | ||
} | ||
if (options) { | ||
nodbUtil.assert(nodbUtil.isObject(options), 'NJS-006', 3); | ||
} | ||
binding = binding || []; | ||
options = options || {}; | ||
options.resultSet = true; | ||
stream = new QueryStream(null, self._oracledb); | ||
self._execute(sql, binding, options, function(err, result) { | ||
if (err) { | ||
stream._open(err, null); | ||
} else { | ||
resultset.extend(result.resultSet, self._oracledb, options); | ||
stream._open(null, result.resultSet); | ||
} | ||
}); | ||
return stream; | ||
} | ||
// fetchRowsToReturn is used to materialize the rows for an execute call using | ||
// the resultSet returned from the C layer. | ||
function fetchRowsToReturn(oracledb, executeOpts, result, executeCb) { | ||
var rowsFetched = []; | ||
var fetchArraySize; | ||
var maxRows; | ||
function fetchRowsToReturn(oracledb, executeOpts, resultSet, cb) { | ||
let rowsFetched = []; | ||
let fetchArraySize; | ||
let maxRows; | ||
@@ -93,6 +44,6 @@ fetchArraySize = executeOpts.fetchArraySize; | ||
var fetchRowsCb = function(err, rows) { | ||
const fetchRowsCb = function(err, rows) { | ||
if (err) { | ||
executeCb(err); | ||
cb(err); | ||
return; | ||
@@ -106,15 +57,10 @@ } | ||
if (rowsFetched.length == maxRows || rows.length < fetchArraySize) { | ||
result.rows = rowsFetched; | ||
delete result.resultSet; | ||
executeCb(null, result); | ||
cb(null, rowsFetched); | ||
return; | ||
} | ||
result.resultSet.getRows(fetchArraySize, fetchRowsCb); | ||
resultSet.getRows(fetchArraySize, fetchRowsCb); | ||
}; | ||
result.resultSet.getRows(fetchArraySize, fetchRowsCb); | ||
resultSet.getRows(fetchArraySize, fetchRowsCb); | ||
} | ||
@@ -126,19 +72,19 @@ | ||
function execute(sql, a2, a3, a4) { | ||
var self = this; | ||
var binds = []; | ||
var executeOpts = {}; | ||
var executeCb; | ||
var custExecuteCb; | ||
const self = this; | ||
let binds = []; | ||
let executeOpts = {}; | ||
let executeCb; | ||
let custExecuteCb; | ||
nodbUtil.assert(arguments.length > 1 && arguments.length < 5, 'NJS-009'); | ||
nodbUtil.assert(typeof sql === 'string', 'NJS-006', 1); | ||
nodbUtil.assert(typeof sql === 'string', 'NJS-005', 1); | ||
switch (arguments.length) { | ||
case 2: | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-005', 2); | ||
executeCb = a2; | ||
break; | ||
case 3: | ||
nodbUtil.assert(nodbUtil.isObjectOrArray(a2), 'NJS-006', 2); | ||
nodbUtil.assert(typeof a3 === 'function', 'NJS-006', 3); | ||
nodbUtil.assert(nodbUtil.isObjectOrArray(a2), 'NJS-005', 2); | ||
nodbUtil.assert(typeof a3 === 'function', 'NJS-005', 3); | ||
binds = a2; | ||
@@ -148,5 +94,5 @@ executeCb = a3; | ||
case 4: | ||
nodbUtil.assert(nodbUtil.isObjectOrArray(a2), 'NJS-006', 2); | ||
nodbUtil.assert(nodbUtil.isObject(a3), 'NJS-006', 3); | ||
nodbUtil.assert(typeof a4 === 'function', 'NJS-006', 4); | ||
nodbUtil.assert(nodbUtil.isObjectOrArray(a2), 'NJS-005', 2); | ||
nodbUtil.assert(nodbUtil.isObject(a3), 'NJS-005', 3); | ||
nodbUtil.assert(typeof a4 === 'function', 'NJS-005', 4); | ||
binds = a2; | ||
@@ -159,4 +105,4 @@ executeOpts = a3; | ||
custExecuteCb = function(err, result) { | ||
var outBindsKeys; | ||
var outBindsIdx; | ||
let outBindsKeys; | ||
let outBindsIdx; | ||
@@ -169,9 +115,19 @@ if (err) { | ||
// Need to extend resultsets which may come from either the query results | ||
// or outBinds. | ||
// or outBinds or implicit results | ||
if (result.resultSet) { | ||
result.resultSet._setup(executeOpts); | ||
if (executeOpts.resultSet) { | ||
resultset.extend(result.resultSet, self._oracledb, executeOpts); | ||
executeCb(null, result); | ||
} else { | ||
fetchRowsToReturn(self._oracledb, executeOpts, result, executeCb); | ||
fetchRowsToReturn(self._oracledb, executeOpts, result.resultSet, | ||
function(err, rows) { | ||
if (err) { | ||
executeCb(err); | ||
} else { | ||
result.rows = rows; | ||
delete result.resultSet; | ||
executeCb(null, result); | ||
} | ||
} | ||
); | ||
} | ||
@@ -184,7 +140,33 @@ } else { | ||
if (result.outBinds[outBindsKeys[outBindsIdx]] instanceof self._oracledb.ResultSet) { | ||
resultset.extend(result.outBinds[outBindsKeys[outBindsIdx]], self._oracledb, executeOpts); | ||
result.outBinds[outBindsKeys[outBindsIdx]]._setup(executeOpts); | ||
} | ||
} | ||
} | ||
executeCb(null, result); | ||
if (result.implicitResults && !executeOpts.resultSet) { | ||
const processImplicitResult = function(ix) { | ||
const resultSet = result.implicitResults[ix]; | ||
if (!resultSet) { | ||
executeCb(null, result); | ||
return; | ||
} | ||
fetchRowsToReturn(self._oracledb, executeOpts, resultSet, | ||
function(err, rows) { | ||
if (err) { | ||
executeCb(err); | ||
return; | ||
} | ||
result.implicitResults[ix] = rows; | ||
processImplicitResult(ix + 1); | ||
} | ||
); | ||
}; | ||
processImplicitResult(0); | ||
} else { | ||
if (result.implicitResults) { | ||
for (let i = 0; i < result.implicitResults.length; i++) { | ||
result.implicitResults[i]._setup(executeOpts); | ||
} | ||
} | ||
executeCb(null, result); | ||
} | ||
} | ||
@@ -197,18 +179,18 @@ | ||
executePromisified = nodbUtil.promisify(execute); | ||
// This executeMany function is used to override the executeMany method of | ||
// the Connection class, which is defined in the C layer. | ||
function executeMany(sql, bindsOrNumIters, a3, a4) { | ||
var self = this; | ||
var options = {}; | ||
var executeCb; | ||
const self = this; | ||
let options = {}; | ||
let executeCb; | ||
let okBinds; | ||
nodbUtil.assert(arguments.length > 2 && arguments.length < 5, 'NJS-009'); | ||
nodbUtil.assert(typeof sql === 'string', 'NJS-006', 1); | ||
nodbUtil.assert(typeof sql === 'string', 'NJS-005', 1); | ||
if (typeof bindsOrNumIters === 'number') { | ||
nodbUtil.assert(Number.isInteger(bindsOrNumIters) && bindsOrNumIters > 0, | ||
'NJS-005', 2); | ||
nodbUtil.assert(Number.isInteger(bindsOrNumIters), 'NJS-005', 2); | ||
okBinds = (bindsOrNumIters > 0); | ||
} else { | ||
nodbUtil.assert(Array.isArray(bindsOrNumIters), 'NJS-006', 2); | ||
nodbUtil.assert(Array.isArray(bindsOrNumIters), 'NJS-005', 2); | ||
okBinds = (bindsOrNumIters.length > 0); | ||
} | ||
@@ -218,8 +200,8 @@ | ||
case 3: | ||
nodbUtil.assert(typeof a3 === 'function', 'NJS-006', 3); | ||
nodbUtil.assert(typeof a3 === 'function', 'NJS-005', 3); | ||
executeCb = a3; | ||
break; | ||
case 4: | ||
nodbUtil.assert(nodbUtil.isObject(a3), 'NJS-006', 3); | ||
nodbUtil.assert(typeof a4 === 'function', 'NJS-006', 4); | ||
nodbUtil.assert(nodbUtil.isObject(a3), 'NJS-005', 3); | ||
nodbUtil.assert(typeof a4 === 'function', 'NJS-005', 4); | ||
options = a3; | ||
@@ -229,2 +211,6 @@ executeCb = a4; | ||
} | ||
if (!okBinds) { | ||
executeCb(new Error(nodbUtil.getErrorMessage('NJS-005', 2))); | ||
return; | ||
} | ||
@@ -234,10 +220,28 @@ self._executeMany.call(self, sql, bindsOrNumIters, options, executeCb); | ||
executeManyPromisified = nodbUtil.promisify(executeMany); | ||
// define method for getting a database object class; the cache is searched | ||
// first, but if not found, the database is queried and the result is cached | ||
// using the fully qualified name | ||
function getDbObjectClass(name, cb) { | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(typeof name === 'string', 'NJS-005', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 2); | ||
// check the cache; if the class is found there, nothing further to do | ||
let cls = this._dbObjectClasses[name]; | ||
if (cls) { | ||
cb(null, cls); | ||
return; | ||
} | ||
// otherwise, ask the database for the class; the C method will internally | ||
// call back into JavaScript to store the type found in the cache | ||
this._getDbObjectClass(name, cb); | ||
} | ||
// This getStatementInfo function is just a place holder to allow for easier extension later. | ||
function getStatementInfo(sql, getStatementInfoCb) { | ||
var self = this; | ||
const self = this; | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(typeof getStatementInfoCb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof getStatementInfoCb === 'function', 'NJS-005', 1); | ||
@@ -247,10 +251,8 @@ self._getStatementInfo.apply(self, arguments); | ||
getStatementInfoPromisified = nodbUtil.promisify(getStatementInfo); | ||
// This commit function is just a place holder to allow for easier extension later. | ||
function commit(commitCb) { | ||
var self = this; | ||
const self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof commitCb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof commitCb === 'function', 'NJS-005', 1); | ||
@@ -260,10 +262,8 @@ self._commit.apply(self, arguments); | ||
commitPromisified = nodbUtil.promisify(commit); | ||
// This createLob function is just a place holder to allow for easier extension later. | ||
function createLob(type, createLobCb) { | ||
var self = this; | ||
const self = this; | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(typeof createLobCb === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(typeof createLobCb === 'function', 'NJS-005', 2); | ||
@@ -273,10 +273,8 @@ self._createLob.apply(self, arguments); | ||
createLobPromisified = nodbUtil.promisify(createLob); | ||
// This rollback function is just a place holder to allow for easier extension later. | ||
function rollback(rollbackCb) { | ||
var self = this; | ||
const self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof rollbackCb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof rollbackCb === 'function', 'NJS-005', 1); | ||
@@ -286,10 +284,8 @@ self._rollback.apply(self, arguments); | ||
rollbackPromisified = nodbUtil.promisify(rollback); | ||
// This close function is used to override the close method of the Connection | ||
// class, which is defined in the C layer. | ||
function close(a1, a2) { | ||
var self = this; | ||
var options = {}; | ||
var closeCb; | ||
const self = this; | ||
let options = {}; | ||
let closeCb; | ||
@@ -300,8 +296,8 @@ nodbUtil.assert(arguments.length >= 1 && arguments.length <= 2, 'NJS-009'); | ||
case 1: | ||
nodbUtil.assert(typeof a1 === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof a1 === 'function', 'NJS-005', 1); | ||
closeCb = a1; | ||
break; | ||
case 2: | ||
nodbUtil.assert(nodbUtil.isObject(a1), 'NJS-006', 1); | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(nodbUtil.isObject(a1), 'NJS-005', 1); | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-005', 2); | ||
options = a1; | ||
@@ -321,11 +317,9 @@ closeCb = a2; | ||
closePromisified = nodbUtil.promisify(close); | ||
// This break function is just a place holder to allow for easier extension later. | ||
// It's attached to the module as break is a reserved word. | ||
module.break = function(breakCb) { | ||
var self = this; | ||
const self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof breakCb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof breakCb === 'function', 'NJS-005', 1); | ||
@@ -335,13 +329,11 @@ self._break.apply(self, arguments); | ||
breakPromisified = nodbUtil.promisify(module.break); | ||
// This changePassword function is just a place holder to allow for easier extension later. | ||
function changePassword(user, password, newPassword, changePasswordCb) { | ||
var self = this; | ||
const self = this; | ||
nodbUtil.assert(arguments.length === 4, 'NJS-009'); | ||
nodbUtil.assert(typeof user === 'string', 'NJS-006', 1); | ||
nodbUtil.assert(typeof password === 'string', 'NJS-006', 2); | ||
nodbUtil.assert(typeof newPassword === 'string', 'NJS-006', 3); | ||
nodbUtil.assert(typeof changePasswordCb === 'function', 'NJS-006', 4); | ||
nodbUtil.assert(typeof user === 'string', 'NJS-005', 1); | ||
nodbUtil.assert(typeof password === 'string', 'NJS-005', 2); | ||
nodbUtil.assert(typeof newPassword === 'string', 'NJS-005', 3); | ||
nodbUtil.assert(typeof changePasswordCb === 'function', 'NJS-005', 4); | ||
@@ -351,10 +343,29 @@ self._changePassword.apply(self, arguments); | ||
changePasswordPromisified = nodbUtil.promisify(changePassword); | ||
// Returns an AQ queue | ||
function getQueue(name, a2, a3) { | ||
let options = {}; | ||
let queueCb; | ||
nodbUtil.assert(arguments.length >= 2 && arguments.length <= 3, 'NJS-009'); | ||
nodbUtil.assert(typeof name === 'string', 'NJS-005', 1); | ||
switch (arguments.length) { | ||
case 2: | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-005', 2); | ||
queueCb = a2; | ||
break; | ||
case 3: | ||
nodbUtil.assert(nodbUtil.isObject(a2), 'NJS-005', 2); | ||
nodbUtil.assert(typeof a3 === 'function', 'NJS-005', 3); | ||
options = a2; | ||
queueCb = a3; | ||
break; | ||
} | ||
this._getQueue(name, options, queueCb); | ||
} | ||
// This ping function is just a place holder to allow for easier extension later. | ||
function ping(pingCb) { | ||
var self = this; | ||
const self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof pingCb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof pingCb === 'function', 'NJS-005', 1); | ||
@@ -364,25 +375,21 @@ self._ping.apply(self, arguments); | ||
pingPromisified = nodbUtil.promisify(ping); | ||
// create a subscription which can be used to get notifications of database | ||
// changes | ||
function subscribe(name, options, subscribeCb) { | ||
var self = this; | ||
const self = this; | ||
nodbUtil.assert(arguments.length == 3, 'NJS-009'); | ||
nodbUtil.assert(typeof name === 'string', 'NJS-006', 1); | ||
nodbUtil.assert(nodbUtil.isObject(options), 'NJS-006', 2); | ||
nodbUtil.assert(typeof subscribeCb === 'function', 'NJS-006', 3); | ||
nodbUtil.assert(typeof name === 'string', 'NJS-005', 1); | ||
nodbUtil.assert(nodbUtil.isObject(options), 'NJS-005', 2); | ||
nodbUtil.assert(typeof subscribeCb === 'function', 'NJS-005', 3); | ||
self._subscribe.call(self, name, options, subscribeCb); | ||
} | ||
subscribePromisified = nodbUtil.promisify(subscribe); | ||
// destroy a subscription which was earlier created using subscribe() | ||
function unsubscribe(name, cb) { | ||
var self = this; | ||
const self = this; | ||
nodbUtil.assert(arguments.length == 2, 'NJS-009'); | ||
nodbUtil.assert(typeof name === 'string', 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(typeof name === 'string', 'NJS-005', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 2); | ||
@@ -392,150 +399,104 @@ self._unsubscribe.call(self, name, cb); | ||
unsubscribePromisified = nodbUtil.promisify(unsubscribe); | ||
// define class | ||
class Connection extends EventEmitter { | ||
// To obtain a SodaDatabase object (high-level SODA object associated with | ||
// current connection) | ||
function getSodaDatabase() { | ||
nodbUtil.assert(arguments.length === 0, 'NJS-009'); | ||
let db = this._getSodaDatabase(); | ||
sodaDatabase.extend(db, this); | ||
return db; | ||
} | ||
constructor() { | ||
super(); | ||
this._dbObjectClasses = {}; | ||
} | ||
// extend class with promisified functions | ||
_extend(oracledb) { | ||
this._oracledb = oracledb; | ||
this.break = nodbUtil.promisify(oracledb, module.break); | ||
this.changePassword = nodbUtil.promisify(oracledb, changePassword); | ||
this.close = nodbUtil.promisify(oracledb, close); | ||
this.commit = nodbUtil.promisify(oracledb, commit); | ||
this.createLob = nodbUtil.promisify(oracledb, createLob); | ||
this.execute = nodbUtil.promisify(oracledb, execute); | ||
this.executeMany = nodbUtil.promisify(oracledb, executeMany); | ||
this.getDbObjectClass = nodbUtil.promisify(oracledb, getDbObjectClass); | ||
this.getQueue = nodbUtil.promisify(oracledb, getQueue); | ||
this.getStatementInfo = nodbUtil.promisify(oracledb, getStatementInfo); | ||
this.ping = nodbUtil.promisify(oracledb, ping); | ||
this.release = nodbUtil.promisify(oracledb, close); | ||
this.rollback = nodbUtil.promisify(oracledb, rollback); | ||
this.subscribe = nodbUtil.promisify(oracledb, subscribe); | ||
this.unsubscribe = nodbUtil.promisify(oracledb, unsubscribe); | ||
} | ||
// The extend method is used to extend the Connection instance from the C layer with | ||
// custom properties and method overrides. References to the original methods are | ||
// maintained so they can be invoked by the overriding method at the right time. | ||
function extend(conn, oracledb, pool) { | ||
nodbUtil.makeEventEmitter(conn); | ||
// Using Object.defineProperties to add properties to the Connection instance with | ||
// special properties, such as enumerable but not writable. | ||
Object.defineProperties( | ||
conn, | ||
{ | ||
_oracledb: { // storing a reference to the base instance to avoid circular references with require | ||
value: oracledb | ||
}, | ||
_pool: { // storing a reference to the pool, if any, from which the connection was obtained | ||
value: pool | ||
}, | ||
_execute: { | ||
value: conn.execute | ||
}, | ||
_getStatementInfo: { | ||
value: conn.getStatementInfo | ||
}, | ||
getStatementInfo: { | ||
value: getStatementInfoPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
queryStream: { | ||
value: queryStream, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
execute: { | ||
value: executePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_executeMany: { | ||
value: conn.executeMany | ||
}, | ||
executeMany: { | ||
value: executeManyPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_commit: { | ||
value: conn.commit | ||
}, | ||
commit: { | ||
value: commitPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_createLob: { | ||
value: conn.createLob | ||
}, | ||
createLob: { | ||
value: createLobPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_rollback: { | ||
value: conn.rollback | ||
}, | ||
rollback: { | ||
value: rollbackPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_close: { | ||
value: conn.close | ||
}, | ||
close: { | ||
value: closePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
release: { // alias for close | ||
value: closePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_break: { | ||
value: conn.break | ||
}, | ||
break: { | ||
value: breakPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_changePassword: { | ||
value: conn.changePassword | ||
}, | ||
changePassword: { | ||
value: changePasswordPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_ping: { | ||
value: conn.ping | ||
}, | ||
ping: { | ||
value: pingPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_subscribe: { | ||
value: conn.subscribe | ||
}, | ||
subscribe: { | ||
value: subscribePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_unsubscribe: { | ||
value: conn.unsubscribe | ||
}, | ||
unsubscribe: { | ||
value: unsubscribePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_getSodaDatabase: { | ||
value: conn.getSodaDatabase | ||
}, | ||
getSodaDatabase: { | ||
value: getSodaDatabase, | ||
enumerable: true, | ||
writable: true | ||
_getDbObjectClassJS(schema, name) { | ||
const fqn = `${schema}.${name}`; | ||
let cls = this._dbObjectClasses[fqn]; | ||
if (!cls) { | ||
class DbObject extends BaseDbObject { | ||
get [Symbol.toStringTag]() { | ||
return fqn; | ||
} | ||
} | ||
this._dbObjectClasses[fqn] = cls = DbObject; | ||
cls.prototype.schema = schema; | ||
cls.prototype.name = name; | ||
cls.prototype.fqn = fqn; | ||
cls.toString = function() { | ||
return 'DbObjectClass [' + fqn + ']'; | ||
}; | ||
} | ||
); | ||
return cls; | ||
} | ||
// To obtain a SodaDatabase object (high-level SODA object associated with | ||
// current connection) | ||
getSodaDatabase() { | ||
nodbUtil.assert(arguments.length === 0, 'NJS-009'); | ||
return this._getSodaDatabase(); | ||
} | ||
// The queryStream function is similar to execute except that it immediately | ||
// returns a QueryStream. | ||
queryStream(sql, binding, options) { | ||
const self = this; | ||
let stream; | ||
nodbUtil.assert(arguments.length > 0 && arguments.length < 4, 'NJS-009'); | ||
nodbUtil.assert(typeof sql === 'string', 'NJS-005', 1); | ||
if (binding) { | ||
nodbUtil.assert(nodbUtil.isObjectOrArray(binding), 'NJS-005', 2); | ||
} | ||
if (options) { | ||
nodbUtil.assert(nodbUtil.isObject(options), 'NJS-005', 3); | ||
} | ||
binding = binding || []; | ||
options = options || {}; | ||
options.resultSet = true; | ||
stream = new QueryStream(null); | ||
// calling execute() via nextTick to ensure that handlers are registered | ||
// prior to the events being emitted | ||
process.nextTick(function() { | ||
self._execute(sql, binding, options, function(err, result) { | ||
if (err) { | ||
stream._open(err, null); | ||
} else if (result.resultSet) { | ||
result.resultSet._setup(options); | ||
stream._open(null, result.resultSet); | ||
} else { | ||
stream._open(new Error(nodbUtil.getErrorMessage('NJS-019'))); | ||
} | ||
}); | ||
}); | ||
return stream; | ||
} | ||
} | ||
module.exports.extend = extend; | ||
// module.exports.extend = extend; | ||
module.exports = Connection; |
239
lib/lob.js
@@ -1,153 +0,136 @@ | ||
/* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. */ | ||
// Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved | ||
/****************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
'use strict'; | ||
var Duplex = require('stream').Duplex; | ||
var util = require('util'); | ||
var nodbUtil = require('./util.js'); | ||
var closePromisified; | ||
const Duplex = require('stream').Duplex; | ||
const nodbUtil = require('./util.js'); | ||
const util = require('util'); | ||
util.inherits(Lob, Duplex); | ||
function close(closeCb) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof closeCb === 'function', 'NJS-005', 1); | ||
// the Lob class is used to support the streaming of LOB data to/from the | ||
// database; the iLob refers to the C++ implementation of the Lob class | ||
function Lob(iLob, opt, oracledb) { | ||
Duplex.call(this, opt); | ||
// Return if LOB already closed to support multiple close() calls should be | ||
// no-op | ||
if (!this.valid) { | ||
closeCb(null); | ||
return; | ||
} | ||
this.iLob = iLob; | ||
this._close(function(err) { | ||
if (err) { | ||
this.emit('error', err); | ||
} else { | ||
this.emit('close'); | ||
} | ||
Object.defineProperties( | ||
this, | ||
{ | ||
_oracledb: { // _oracledb property used by promisify () in util.js | ||
value: oracledb | ||
}, | ||
_autoCloseLob: { // Tells whether to close at the end of stream or not | ||
value: iLob.autoCloseLob, | ||
writable: false | ||
}, | ||
chunkSize: { | ||
value: iLob.chunkSize, | ||
writable: false | ||
}, | ||
length: { | ||
get: function() { | ||
return iLob.length; | ||
} | ||
}, | ||
pieceSize: { | ||
get: function() { | ||
return iLob.pieceSize; | ||
}, | ||
set: function(newPieceSize) { | ||
iLob.pieceSize = newPieceSize; | ||
} | ||
}, | ||
type: { | ||
get: function() { | ||
return iLob.type; | ||
} | ||
}, | ||
close: { | ||
value: closePromisified, | ||
enumerable: true, | ||
writable: true | ||
} | ||
}); | ||
closeCb(err); | ||
}); | ||
} | ||
if (this._autoCloseLob) { | ||
function getData(getDataCb) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof getDataCb === 'function', 'NJS-005', 1); | ||
this._getData(getDataCb); | ||
} | ||
class Lob { | ||
constructor() { | ||
Duplex.call(this, {decodeStrings: false}); | ||
this.offset = 1; | ||
this.once('finish', function() { | ||
this.close(function() {}); | ||
if (this._autoCloseLob) { | ||
this.close(function() {}); | ||
} | ||
}); | ||
} | ||
} | ||
// implementation of streaming read; if lob is set to auto-close, the lob is | ||
// automatically closed within the C++ code when an error occurs or when there | ||
// are no more bytes to transfer; all that needs to be done in the JS layer is | ||
// to emit the close and/or error events | ||
Lob.prototype._read = function() { | ||
var self = this; | ||
_extend(oracledb) { | ||
this._oracledb = oracledb; | ||
this.close = nodbUtil.promisify(oracledb, close); | ||
this.getData = nodbUtil.promisify(oracledb, getData); | ||
} | ||
self.iLob.read( | ||
function(err, str) { | ||
if (err) { | ||
self.emit('error', err); | ||
if (self._autoCloseLob) { | ||
self.emit('close'); | ||
// implementation of streaming read; if lob is set to auto-close, the lob is | ||
// automatically closed within the C++ code when an error occurs or when | ||
// there are no more bytes to transfer; all that needs to be done in the JS | ||
// layer is to emit the close and/or error events | ||
_read() { | ||
const self = this; | ||
self.__read(self.offset, | ||
function(err, data) { | ||
if (err) { | ||
self.emit('error', err); | ||
if (self._autoCloseLob) { | ||
self.emit('close'); | ||
} | ||
return; | ||
} | ||
return; | ||
} | ||
self.push(str); | ||
if (data) { | ||
self.offset += data.length; | ||
} | ||
if (self._autoCloseLob && !str) { | ||
process.nextTick(function() { | ||
self.emit('close'); | ||
}); | ||
self.push(data); | ||
if (self._autoCloseLob && !data) { | ||
process.nextTick(function() { | ||
self.emit('close'); | ||
}); | ||
} | ||
} | ||
} | ||
); | ||
}; | ||
); | ||
} | ||
// implementation of streaming write; if lob is set to auto-close, the lob is | ||
// automatically closed in the "finish" event; all that needs to be done here | ||
// is to emit the close event in the event of an error | ||
Lob.prototype._write = function(data, encoding, cb) { | ||
var self = this; | ||
// implementation of streaming write; if lob is set to auto-close, the lob is | ||
// automatically closed in the "finish" event; all that needs to be done here | ||
// is to emit the close event in the event of an error | ||
_write(data, encoding, cb) { | ||
const self = this; | ||
self.iLob.write( | ||
data, | ||
function(err) { | ||
if (err && self._autoCloseLob) { | ||
self.emit('close'); | ||
if (self.type == self._oracledb.BLOB && !Buffer.isBuffer(data)) { | ||
data = Buffer.from(data); | ||
} else if (self.type == self._oracledb.CLOB && Buffer.isBuffer(data)) { | ||
data = data.toString(); | ||
} | ||
self.__write( | ||
self.offset, | ||
data, | ||
function(err) { | ||
if (err && self._autoCloseLob) { | ||
self.emit('close'); | ||
} | ||
if (!err) { | ||
self.offset += data.length; | ||
} | ||
cb(err); | ||
} | ||
cb(err); | ||
} | ||
); | ||
}; | ||
Lob.prototype.close = function(closeCb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof closeCb === 'function', 'NJS-006', 1); | ||
// Return if LOB already closed to support multiple close() calls should be | ||
// no-op | ||
if (!self.iLob.valid) { | ||
closeCb(null); | ||
return; | ||
); | ||
} | ||
self.iLob.close(function(err) { | ||
if (err) { | ||
self.emit('error', err); | ||
} else { | ||
self.emit('close'); | ||
} | ||
} | ||
closeCb(err); | ||
}); | ||
}; | ||
util.inherits(Lob, Duplex); | ||
closePromisified = nodbUtil.promisify(Lob.prototype.close); | ||
module.exports.Lob = Lob; | ||
module.exports = Lob; |
@@ -1,37 +0,59 @@ | ||
/* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. */ | ||
// Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved | ||
/****************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
'use strict'; | ||
var oracledbCLib; | ||
var oracledbInst; | ||
var Lob = require('./lob.js').Lob; | ||
var pool = require('./pool.js'); | ||
var connection = require('./connection.js'); | ||
var nodbUtil = require('./util.js'); | ||
var createPoolPromisified; | ||
var getConnectionPromisified; | ||
var poolCache = {}; | ||
var tempUsedPoolAliases = {}; | ||
var defaultPoolAlias = 'default'; | ||
const nodbUtil = require('./util.js'); | ||
// This version of node-oracledb works with Node.js 8.16, 10.16 or | ||
// later. The test stops hard-to-interpret runtime errors and crashes | ||
// with older Node.js versions. Also Node.js 8.16 and 10.16 (and | ||
// 12.0) contain an important N-API performance regression fix. If | ||
// you're using the obsolete Node.js 9 or 11 versions, you're on your | ||
// own regarding performance and functionality | ||
let vs = process.version.substring(1).split(".").map(Number); | ||
if (vs[0] < 8 || (vs[0] === 8 && vs[1] < 16)) { | ||
throw new Error(nodbUtil.getErrorMessage('NJS-069', nodbUtil.PACKAGE_JSON_VERSION, "8.16")); | ||
} else if ((vs[0] === 10 && vs[1] < 16)) { | ||
throw new Error(nodbUtil.getErrorMessage('NJS-069', nodbUtil.PACKAGE_JSON_VERSION, "10.16")); | ||
} | ||
const AqDeqOptions = require('./aqDeqOptions.js'); | ||
const AqEnqOptions = require('./aqEnqOptions.js'); | ||
const AqMessage = require('./aqMessage.js'); | ||
const AqQueue = require('./aqQueue.js'); | ||
const BaseDbObject = require('./dbObject.js'); | ||
const Connection = require('./connection.js'); | ||
const Lob = require('./lob.js'); | ||
const Pool = require('./pool.js'); | ||
const ResultSet = require('./resultset.js'); | ||
const SodaDatabase = require('./sodaDatabase.js'); | ||
const SodaCollection = require('./sodaCollection.js'); | ||
const SodaDocCursor = require('./sodaDocCursor.js'); | ||
const SodaDocument = require('./sodaDocument.js'); | ||
const SodaOperation = require('./sodaOperation.js'); | ||
let poolCache = {}; | ||
let tempUsedPoolAliases = {}; | ||
const defaultPoolAlias = 'default'; | ||
// Load the Oracledb binary | ||
var binaryLocations = [ | ||
const binaryLocations = [ | ||
'../' + nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE, // pre-built binary | ||
@@ -42,3 +64,4 @@ '../' + nodbUtil.RELEASE_DIR + '/' + 'oracledb.node', // binary built from source | ||
for (var i = 0; i < binaryLocations.length; i++) { | ||
let oracledbCLib; | ||
for (let i = 0; i < binaryLocations.length; i++) { | ||
try { | ||
@@ -49,3 +72,3 @@ oracledbCLib = require(binaryLocations[i]); | ||
if (err.code !== 'MODULE_NOT_FOUND' || i == binaryLocations.length - 1) { | ||
var nodeInfo; | ||
let nodeInfo; | ||
if (err.code === 'MODULE_NOT_FOUND') { | ||
@@ -62,7 +85,44 @@ // none of the three binaries could be found | ||
class OracleDb { | ||
constructor() { | ||
this.queueTimeout = 60000; | ||
this.Promise = global.Promise; | ||
} | ||
// extend class with promisified functions | ||
_extend(oracleDbInst) { | ||
this.getConnection = nodbUtil.promisify(oracleDbInst, getConnection); | ||
this.createPool = nodbUtil.promisify(oracleDbInst, createPool); | ||
} | ||
// retrieves a pool from the pool cache (synchronous method) | ||
getPool(poolAlias) { | ||
let pool; | ||
nodbUtil.assert(arguments.length < 2, 'NJS-009'); | ||
if (poolAlias) { | ||
nodbUtil.assert(typeof poolAlias === 'string' || typeof poolAlias === 'number', 'NJS-005', 1); | ||
} | ||
poolAlias = poolAlias || defaultPoolAlias; | ||
pool = poolCache[poolAlias]; | ||
if (!pool) { | ||
throw new Error(nodbUtil.getErrorMessage('NJS-047', poolAlias)); | ||
} | ||
return pool; | ||
} | ||
} | ||
// Oracledb functions and classes | ||
oracledbCLib.Oracledb.prototype.newLob = function(iLob) { | ||
return new Lob(iLob, null, oracledbInst); | ||
}; | ||
// oracledbCLib.OracleDb.prototype.newLob = function(iLob) { | ||
// return new Lob(iLob, null, oracledbInst); | ||
// }; | ||
@@ -73,5 +133,5 @@ // This createPool function is used the override the createPool method of the | ||
function createPool(poolAttrs, createPoolCb) { | ||
var self = this; | ||
var sessionCallback; | ||
var poolAlias; | ||
const self = this; | ||
let sessionCallback; | ||
let poolAlias; | ||
@@ -81,10 +141,5 @@ // Initial argument count and type checks are done first and throw in the same | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(nodbUtil.isObject(poolAttrs), 'NJS-006', 1); | ||
nodbUtil.assert(typeof createPoolCb === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(nodbUtil.isObject(poolAttrs), 'NJS-005', 1); | ||
nodbUtil.assert(typeof createPoolCb === 'function', 'NJS-005', 2); | ||
// Allow user to use connectionString as an alias for connectString. | ||
if (poolAttrs.connectString === undefined) { | ||
poolAttrs.connectString = poolAttrs.connectionString; | ||
} | ||
// Additional validations should pass errors via the callback. Need to ensure | ||
@@ -153,6 +208,6 @@ // that errors are raised prior to actually creating the pool via _createPool. | ||
poolAttrs.sessionCallback = sessionCallback; | ||
pool.extend(poolInst, poolAttrs, poolAlias, self); | ||
poolInst._setup(poolAttrs, poolAlias, self); | ||
poolInst.on('_after_close', function() { | ||
var pool = this; | ||
const pool = this; | ||
@@ -168,26 +223,2 @@ if (pool.poolAlias) { | ||
createPoolPromisified = nodbUtil.promisify(createPool); | ||
// The getPool function is a synchronous method used to retrieve pools from the | ||
// pool cache. | ||
function getPool(poolAlias) { | ||
var pool; | ||
nodbUtil.assert(arguments.length < 2, 'NJS-009'); | ||
if (poolAlias) { | ||
nodbUtil.assert(typeof poolAlias === 'string' || typeof poolAlias === 'number', 'NJS-006', 1); | ||
} | ||
poolAlias = poolAlias || defaultPoolAlias; | ||
pool = poolCache[poolAlias]; | ||
if (!pool) { | ||
throw new Error(nodbUtil.getErrorMessage('NJS-047', poolAlias)); | ||
} | ||
return pool; | ||
} | ||
// This getConnection function is used the override the getConnection method of the | ||
@@ -197,7 +228,7 @@ // Oracledb class, which is defined in the C layer. The override allows us to do | ||
function getConnection(a1, a2) { | ||
var self = this; | ||
var pool; | ||
var poolAlias; | ||
var connAttrs = {}; | ||
var getConnectionCb; | ||
const self = this; | ||
let pool; | ||
let poolAlias; | ||
let connAttrs = {}; | ||
let getConnectionCb; | ||
@@ -210,3 +241,3 @@ nodbUtil.assert(arguments.length < 3, 'NJS-009'); | ||
case 1: | ||
nodbUtil.assert(typeof a1 === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof a1 === 'function', 'NJS-005', 1); | ||
@@ -218,4 +249,4 @@ poolAlias = defaultPoolAlias; | ||
case 2: | ||
nodbUtil.assert(typeof a1 === 'string' || nodbUtil.isObject(a1), 'NJS-006', 1); | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(typeof a1 === 'string' || nodbUtil.isObject(a1), 'NJS-005', 1); | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-005', 2); | ||
@@ -249,7 +280,2 @@ if (typeof a1 === 'string') { | ||
} else { | ||
// Allow user to use connectionString as an alias for connectString. | ||
if (connAttrs.connectString === undefined) { | ||
connAttrs.connectString = connAttrs.connectionString; | ||
} | ||
self._getConnection(connAttrs, function(err, connInst) { | ||
@@ -264,4 +290,2 @@ if (err) { | ||
connection.extend(connInst, self); | ||
getConnectionCb(null, connInst); | ||
@@ -272,388 +296,26 @@ }); | ||
getConnectionPromisified = nodbUtil.promisify(getConnection); | ||
// create instance which will be exported | ||
let oracleDbInst = new OracleDb(); | ||
// The extend method is used to extend the Oracledb instance from the C layer with | ||
// custom properties and method overrides. References to the original methods are | ||
// maintained so they can be invoked by the overriding method at the right time. | ||
function extend(oracledb) { | ||
// Using Object.defineProperties to add properties to the Oracledb instance with | ||
// special properties, such as enumerable but not writable. A number of constants | ||
// (uppercase names) are added for use in various method calls. | ||
Object.defineProperties( | ||
oracledb, | ||
{ | ||
_oracledb: { // Known to be used in util.js' promisify function. | ||
value: oracledb | ||
}, | ||
DEFAULT: { | ||
value: 0, | ||
enumerable: true | ||
}, | ||
CQN_OPCODE_ALL_OPS: { | ||
value: 0, | ||
enumerable: true | ||
}, | ||
CQN_OPCODE_ALL_ROWS: { | ||
value: 1, | ||
enumerable: true | ||
}, | ||
CQN_OPCODE_ALTER: { | ||
value: 16, | ||
enumerable: true | ||
}, | ||
CQN_OPCODE_DELETE: { | ||
value: 8, | ||
enumerable: true | ||
}, | ||
CQN_OPCODE_DROP: { | ||
value: 32, | ||
enumerable: true | ||
}, | ||
CQN_OPCODE_INSERT: { | ||
value: 2, | ||
enumerable: true | ||
}, | ||
CQN_OPCODE_UPDATE: { | ||
value: 4, | ||
enumerable: true | ||
}, | ||
DB_TYPE_VARCHAR: { | ||
value: 1, | ||
enumerable: true | ||
}, | ||
DB_TYPE_NUMBER: { | ||
value: 2, | ||
enumerable: true | ||
}, | ||
DB_TYPE_LONG: { | ||
value: 8, | ||
enumerable: true | ||
}, | ||
DB_TYPE_DATE: { | ||
value: 12, | ||
enumerable: true | ||
}, | ||
DB_TYPE_RAW: { | ||
value: 23, | ||
enumerable: true | ||
}, | ||
DB_TYPE_LONG_RAW: { | ||
value: 24, | ||
enumerable: true | ||
}, | ||
DB_TYPE_CHAR: { | ||
value: 96, | ||
enumerable: true | ||
}, | ||
DB_TYPE_BINARY_FLOAT: { | ||
value: 100, | ||
enumerable: true | ||
}, | ||
DB_TYPE_BINARY_DOUBLE: { | ||
value: 101, | ||
enumerable: true | ||
}, | ||
DB_TYPE_ROWID: { | ||
value: 104, | ||
enumerable: true | ||
}, | ||
DB_TYPE_CLOB: { | ||
value: 112, | ||
enumerable: true | ||
}, | ||
DB_TYPE_BLOB: { | ||
value: 113, | ||
enumerable: true | ||
}, | ||
DB_TYPE_TIMESTAMP: { | ||
value: 187, | ||
enumerable: true | ||
}, | ||
DB_TYPE_TIMESTAMP_TZ: { | ||
value: 188, | ||
enumerable: true | ||
}, | ||
DB_TYPE_TIMESTAMP_LTZ: { | ||
value: 232, | ||
enumerable: true | ||
}, | ||
DB_TYPE_NVARCHAR: { | ||
value : 1001, | ||
enumerable : true | ||
}, | ||
DB_TYPE_NCHAR: { | ||
value : 1096, | ||
enumerable : true | ||
}, | ||
DB_TYPE_NCLOB: { | ||
value : 1112, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_UNKNOWN: { | ||
value : 0, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_SELECT: { | ||
value : 1, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_UPDATE: { | ||
value : 2, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_DELETE: { | ||
value : 3, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_INSERT: { | ||
value : 4, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_CREATE: { | ||
value : 5, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_DROP: { | ||
value : 6, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_ALTER: { | ||
value : 7, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_BEGIN: { | ||
value : 8, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_DECLARE: { | ||
value : 9, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_CALL: { | ||
value : 10, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_EXPLAIN_PLAN: { | ||
value : 15, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_MERGE: { | ||
value : 16, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_ROLLBACK: { | ||
value : 17, | ||
enumerable : true | ||
}, | ||
STMT_TYPE_COMMIT: { | ||
value : 21, | ||
enumerable : true | ||
}, | ||
STRING: { | ||
value: 2001, | ||
enumerable: true | ||
}, | ||
SUBSCR_EVENT_TYPE_DEREG: { | ||
value: 5, | ||
enumerable: true | ||
}, | ||
SUBSCR_EVENT_TYPE_OBJ_CHANGE: { | ||
value: 6, | ||
enumerable: true | ||
}, | ||
SUBSCR_EVENT_TYPE_QUERY_CHANGE: { | ||
value: 7, | ||
enumerable: true | ||
}, | ||
SUBSCR_EVENT_TYPE_AQ: { | ||
value: 100, | ||
enumerable: true | ||
}, | ||
SUBSCR_GROUPING_CLASS_TIME: { | ||
value: 1, | ||
enumerable: true | ||
}, | ||
SUBSCR_GROUPING_TYPE_SUMMARY: { | ||
value: 1, | ||
enumerable: true | ||
}, | ||
SUBSCR_GROUPING_TYPE_LAST: { | ||
value: 2, | ||
enumerable: true | ||
}, | ||
SUBSCR_NAMESPACE_AQ: { | ||
value: 1, | ||
enumerable: true | ||
}, | ||
SUBSCR_NAMESPACE_DBCHANGE: { | ||
value: 2, | ||
enumerable: true | ||
}, | ||
SUBSCR_QOS_BEST_EFFORT: { | ||
value: 16, | ||
enumerable: true | ||
}, | ||
SUBSCR_QOS_DEREG_NFY: { | ||
value: 2, | ||
enumerable: true | ||
}, | ||
SUBSCR_QOS_QUERY: { | ||
value: 8, | ||
enumerable: true | ||
}, | ||
SUBSCR_QOS_RELIABLE: { | ||
value: 1, | ||
enumerable: true | ||
}, | ||
SUBSCR_QOS_ROWIDS: { | ||
value: 4, | ||
enumerable: true | ||
}, | ||
NUMBER: { | ||
value: 2002, | ||
enumerable: true | ||
}, | ||
DATE: { | ||
value: 2003, | ||
enumerable: true | ||
}, | ||
CURSOR: { | ||
value: 2004, | ||
enumerable: true | ||
}, | ||
BUFFER: { | ||
value: 2005, | ||
enumerable: true | ||
}, | ||
CLOB: { | ||
value: 2006, | ||
enumerable: true | ||
}, | ||
BLOB: { | ||
value: 2007, | ||
enumerable: true | ||
}, | ||
SYSDBA: { | ||
value: 2, | ||
enumerable: true | ||
}, | ||
SYSOPER: { | ||
value: 4, | ||
enumerable: true | ||
}, | ||
SYSASM: { | ||
value: 32768, | ||
enumerable: true | ||
}, | ||
SYSBACKUP: { | ||
value: 131072, | ||
enumerable: true | ||
}, | ||
SYSDG: { | ||
value: 262144, | ||
enumerable: true | ||
}, | ||
SYSKM: { | ||
value: 524288, | ||
enumerable: true | ||
}, | ||
SYSRAC: { | ||
value: 1048576, | ||
enumerable: true | ||
}, | ||
BIND_IN: { | ||
value: 3001, | ||
enumerable: true | ||
}, | ||
BIND_INOUT: { | ||
value: 3002, | ||
enumerable: true | ||
}, | ||
BIND_OUT: { | ||
value: 3003, | ||
enumerable: true | ||
}, | ||
ARRAY: { | ||
value: 4001, | ||
enumerable: true | ||
}, | ||
OBJECT: { | ||
value: 4002, | ||
enumerable: true | ||
}, | ||
SODA_COLL_MAP_MODE: { | ||
value: 5001, | ||
enumerable : true | ||
}, | ||
POOL_STATUS_OPEN: { | ||
value: 6000, | ||
enumerable: true | ||
}, | ||
POOL_STATUS_DRAINING: { | ||
value: 6001, | ||
enumerable: true | ||
}, | ||
POOL_STATUS_CLOSED: { | ||
value: 6002, | ||
enumerable: true | ||
}, | ||
Promise: { | ||
value: global.Promise, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
Oracledb: { | ||
value: oracledbCLib.Oracledb, | ||
enumerable: true | ||
}, | ||
Connection: { | ||
value: oracledbCLib.Connection, | ||
enumerable: true | ||
}, | ||
Lob: { | ||
value: Lob, | ||
enumerable: true | ||
}, | ||
Pool: { | ||
value: oracledbCLib.Pool, | ||
enumerable: true | ||
}, | ||
ResultSet: { | ||
value: oracledbCLib.ResultSet, | ||
enumerable: true | ||
}, | ||
queueTimeout: { | ||
value: 60000, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_createPool: { | ||
value: oracledb.createPool | ||
}, | ||
createPool: { | ||
value: createPoolPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
getPool: { | ||
value: getPool, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_getConnection: { | ||
value: oracledb.getConnection | ||
}, | ||
getConnection: { | ||
value: getConnectionPromisified, | ||
enumerable: true, | ||
writable: true | ||
} | ||
} | ||
); | ||
} | ||
// add classes to prototype | ||
let proto = Object.getPrototypeOf(oracleDbInst); | ||
proto.OracleDb = OracleDb; | ||
proto.AqDeqOptions = AqDeqOptions; | ||
proto.AqEnqOptions = AqEnqOptions; | ||
proto.AqMessage = AqMessage; | ||
proto.AqQueue = AqQueue; | ||
proto.BaseDbObject = BaseDbObject; | ||
proto.Connection = Connection; | ||
proto.Lob = Lob; | ||
proto.Pool = Pool; | ||
proto.ResultSet = ResultSet; | ||
proto.SodaDatabase = SodaDatabase; | ||
proto.SodaCollection = SodaCollection; | ||
proto.SodaDocCursor = SodaDocCursor; | ||
proto.SodaDocument = SodaDocument; | ||
proto.SodaOperation = SodaOperation; | ||
oracledbInst = new oracledbCLib.Oracledb(); | ||
// call C to extend classes | ||
oracledbCLib.init(oracleDbInst); | ||
extend(oracledbInst); | ||
module.exports = oracledbInst; | ||
module.exports = oracleDbInst; |
190
lib/pool.js
@@ -1,26 +0,24 @@ | ||
/* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. */ | ||
// Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved | ||
/****************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
'use strict'; | ||
var connection = require('./connection.js'); | ||
var nodbUtil = require('./util.js'); | ||
var getConnectionPromisified; | ||
var closePromisified; | ||
const EventEmitter = require('events'); | ||
const nodbUtil = require('./util.js'); | ||
@@ -31,3 +29,3 @@ // completeConnectionRequest does the actual work of getting a connection from | ||
function completeConnectionRequest(config, getConnectionCb) { | ||
var self = this; | ||
const self = this; | ||
@@ -57,4 +55,2 @@ // Incrementing _connectionsOut prior to making the async call to get a connection | ||
connection.extend(connInst, self._oracledb, self); | ||
connInst.on('_after_close', function() { | ||
@@ -97,5 +93,5 @@ self._connectionsOut -= 1; | ||
function checkRequestQueue() { | ||
var self = this; | ||
var payload; | ||
var waitTime; | ||
const self = this; | ||
let payload; | ||
let waitTime; | ||
@@ -134,5 +130,5 @@ if (self._connRequestQueue.length === 0 || self._connectionsOut === self.poolMax) { | ||
function onRequestTimeout(timerIdx) { | ||
var self = this; | ||
var payloadToDequeue = self._connRequestTimersMap[timerIdx]; | ||
var requestIndex; | ||
const self = this; | ||
let payloadToDequeue = self._connRequestTimersMap[timerIdx]; | ||
let requestIndex; | ||
@@ -150,3 +146,3 @@ if (payloadToDequeue) { | ||
payloadToDequeue.getConnectionCb(new Error(nodbUtil.getErrorMessage('NJS-040'))); | ||
payloadToDequeue.getConnectionCb(new Error(nodbUtil.getErrorMessage('NJS-040', self.queueTimeout))); | ||
} | ||
@@ -160,9 +156,9 @@ } | ||
function getConnection(a1, a2) { | ||
var self = this; | ||
var payload; | ||
var timeoutHandle; | ||
var timerIdx; | ||
var poolMax; | ||
var getConnectionCb; | ||
var options = {}; | ||
const self = this; | ||
let payload; | ||
let timeoutHandle; | ||
let timerIdx; | ||
let poolMax; | ||
let getConnectionCb; | ||
let options = {}; | ||
@@ -175,3 +171,3 @@ nodbUtil.assert(arguments.length >= 1 && arguments.length <= 2, 'NJS-009'); | ||
case 2: | ||
nodbUtil.assert(nodbUtil.isObject(a1), 'NJS-006', 1); | ||
nodbUtil.assert(nodbUtil.isObject(a1), 'NJS-005', 1); | ||
options = a1; | ||
@@ -181,3 +177,3 @@ getConnectionCb = a2; | ||
} | ||
nodbUtil.assert(typeof getConnectionCb === 'function', 'NJS-006', arguments.length); | ||
nodbUtil.assert(typeof getConnectionCb === 'function', 'NJS-005', arguments.length); | ||
@@ -244,11 +240,10 @@ if (self.status === self._oracledb.POOL_STATUS_DRAINING) { // closing soon | ||
getConnectionPromisified = nodbUtil.promisify(getConnection); | ||
function close(a1, a2) { | ||
const upperLimitTimeout = 2147483647; | ||
var self = this; | ||
var forceClose; | ||
var drainTime; | ||
var timeoutCb; | ||
var closeCb; | ||
const self = this; | ||
let forceClose; | ||
let drainTime; | ||
let timeoutCb; | ||
let closeCb; | ||
@@ -259,3 +254,3 @@ nodbUtil.assert(arguments.length === 1 || arguments.length === 2, 'NJS-009'); | ||
case 1: | ||
nodbUtil.assert(typeof a1 === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof a1 === 'function', 'NJS-005', 1); | ||
closeCb = a1; | ||
@@ -266,4 +261,4 @@ drainTime = 0; | ||
case 2: | ||
nodbUtil.assert(typeof a1 === 'number', 'NJS-006', 1); | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(typeof a1 === 'number', 'NJS-005', 1); | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-005', 2); | ||
closeCb = a2; | ||
@@ -276,3 +271,6 @@ forceClose = true; | ||
// SetTimeout does not accept numbers greater than a 32-bit signed integer. | ||
nodbUtil.assert(drainTime >= 0 && drainTime <= upperLimitTimeout, 'NJS-005', 1); | ||
if (drainTime < 0 || isNaN(drainTime) || drainTime > upperLimitTimeout) { | ||
closeCb(new Error(nodbUtil.getErrorMessage('NJS-005', 1))); | ||
return; | ||
} | ||
break; | ||
@@ -294,3 +292,3 @@ } | ||
if (!err) { | ||
self.status = self._oracledb.POOL_STATUS_CLOSED; | ||
self._status = self._oracledb.POOL_STATUS_CLOSED; | ||
self.emit('_after_close', self); | ||
@@ -306,3 +304,3 @@ } | ||
if (forceClose) { | ||
self.status = self._oracledb.POOL_STATUS_DRAINING; | ||
self._status = self._oracledb.POOL_STATUS_DRAINING; | ||
} | ||
@@ -317,11 +315,10 @@ if (drainTime === 0) { | ||
closePromisified = nodbUtil.promisify(close); | ||
// logStats is used to add a hidden method (_logStats) to each pool instance. This | ||
// provides an easy way to log out the statistics related information that's collected | ||
// when _enableStats is set to true when creating a pool. This functionality may | ||
// be altered or enhanced in the future. | ||
// logStats is used to add a hidden method (_logStats) to each pool instance. | ||
// This provides an easy way to log out the statistics related information | ||
// that's collected when _enableStats is set to true when creating a pool. This | ||
// functionality may be altered or enhanced in the future. | ||
function logStats() { | ||
var self = this; | ||
var averageTimeInQueue; | ||
const self = this; | ||
let averageTimeInQueue; | ||
@@ -375,7 +372,7 @@ if (self.status === self._oracledb.POOL_STATUS_CLOSED) { | ||
// The extend method is used to extend Pool instances from the C layer with custom | ||
// properties, methods, and method overrides. References to the original methods are | ||
// maintained so they can be invoked by the overriding method at the right time. | ||
function extend(pool, poolAttrs, poolAlias, oracledb) { | ||
var queueTimeout; | ||
// sets up the instance with additional attributes used for logging statistics | ||
// and managing the connection queue | ||
function setup(poolAttrs, poolAlias, oracledb) { | ||
const self = this; | ||
let queueTimeout; | ||
@@ -388,12 +385,7 @@ if (typeof poolAttrs.queueTimeout !== 'undefined') { | ||
nodbUtil.makeEventEmitter(pool); | ||
// Using Object.defineProperties to add properties to the Pool instance with special | ||
// properties, such as enumerable but not writable. | ||
// Using Object.defineProperties to add properties to the Pool instance with | ||
// special properties, such as enumerable but not writable. | ||
Object.defineProperties( | ||
pool, | ||
self, | ||
{ | ||
_oracledb: { // storing a reference to the base instance to avoid circular references with require | ||
value: oracledb | ||
}, | ||
queueTimeout: { // milliseconds a connection request can spend in queue before being failed | ||
@@ -403,5 +395,2 @@ enumerable: true, | ||
return queueTimeout; | ||
}, | ||
set: function() { | ||
throw new Error(nodbUtil.getErrorMessage('NJS-014', 'queueTimeout')); | ||
} | ||
@@ -476,4 +465,5 @@ }, | ||
}, | ||
_getConnection: { | ||
value: pool.getConnection | ||
_status: { // open/closing/closed | ||
value: oracledb.POOL_STATUS_OPEN, | ||
writable: true | ||
}, | ||
@@ -484,29 +474,9 @@ poolAlias: { | ||
return poolAlias; | ||
}, | ||
set: function() { | ||
throw new Error(nodbUtil.getErrorMessage('NJS-014', 'poolAlias')); | ||
} | ||
}, | ||
getConnection: { | ||
value: getConnectionPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_close: { | ||
value: pool.close | ||
}, | ||
close: { | ||
value: closePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
terminate: { // alias for close | ||
value: closePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
status: { // open/closing/closed | ||
writable: true, | ||
enumerable: true, | ||
value: oracledb.POOL_STATUS_OPEN | ||
get: function() { | ||
return this._status; | ||
} | ||
}, | ||
@@ -517,6 +487,2 @@ sessionCallback: { // session callback | ||
return poolAttrs.sessionCallback; | ||
}, | ||
set: function() { | ||
throw new Error(nodbUtil.getErrorMessage('NJS-014', | ||
'sessionCallback')); | ||
} | ||
@@ -528,2 +494,16 @@ } | ||
module.exports.extend = extend; | ||
class Pool extends EventEmitter { | ||
_extend(oracledb) { | ||
this._oracledb = oracledb; | ||
this._setup = setup; | ||
this.close = nodbUtil.promisify(oracledb, close); | ||
this.getConnection = nodbUtil.promisify(oracledb, getConnection); | ||
this.terminate = this.close; | ||
} | ||
} | ||
module.exports = Pool; |
@@ -1,28 +0,28 @@ | ||
/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. */ | ||
// Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved | ||
/****************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
'use strict'; | ||
var util = require('util'); | ||
var Readable = require('stream').Readable; | ||
const util = require('util'); | ||
const Readable = require('stream').Readable; | ||
// This class was originally based on https://github.com/sagiegurari/simple-oracledb/blob/master/lib/resultset-read-stream.js | ||
function QueryStream(resultSet, oracledb) { | ||
var self = this; | ||
function QueryStream(resultSet) { | ||
const self = this; | ||
@@ -32,5 +32,2 @@ Object.defineProperties( | ||
{ | ||
_oracledb: { // storing a reference to the base instance to avoid circular references with require | ||
value: oracledb | ||
}, | ||
_resultSet: { | ||
@@ -84,3 +81,3 @@ value: resultSet, | ||
QueryStream.prototype._open = function(err, rs) { | ||
var self = this; | ||
const self = this; | ||
@@ -104,3 +101,3 @@ if (err) { | ||
QueryStream.prototype._read = function() { | ||
var self = this; | ||
const self = this; | ||
@@ -169,3 +166,3 @@ if (!self._resultSet) { | ||
QueryStream.prototype._close = function(callback) { | ||
var self = this; | ||
const self = this; | ||
@@ -220,3 +217,3 @@ if (self._closed) { | ||
QueryStream.prototype._destroy = function(userErr, callback) { | ||
var self = this; | ||
const self = this; | ||
@@ -223,0 +220,0 @@ this._close(function(closeErr) { |
@@ -1,34 +0,31 @@ | ||
/* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. */ | ||
// Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved | ||
/****************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
'use strict'; | ||
var QueryStream = require('./querystream.js'); | ||
var nodbUtil = require('./util.js'); | ||
var closePromisified; | ||
var getRowPromisified; | ||
var getRowsPromisified; | ||
const QueryStream = require('./querystream.js'); | ||
const nodbUtil = require('./util.js'); | ||
// This close function is just a place holder to allow for easier extension later. | ||
// close the result set | ||
function close(closeCb) { | ||
var self = this; | ||
const self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof closeCb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof closeCb === 'function', 'NJS-005', 1); | ||
@@ -48,12 +45,11 @@ if (self._convertedToStream) { | ||
closePromisified = nodbUtil.promisify(close); | ||
// getRow is a JavaScript based wrapper on getRows. It buffers rows in a JavaScript | ||
// array to avoid the trips through the thread pool that would be required if | ||
// implemented in C. | ||
// getRow is a JavaScript based wrapper on getRows. It buffers rows in a | ||
// JavaScript array to avoid the trips through the thread pool that would be | ||
// required if implemented in C. | ||
function getRow(getRowCb) { | ||
var self = this; | ||
const self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof getRowCb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof getRowCb === 'function', 'NJS-005', 1); | ||
@@ -89,15 +85,16 @@ if (self._convertedToStream && !self._allowGetRowCall) { | ||
getRowPromisified = nodbUtil.promisify(getRow); | ||
// The JS getRows will first check to see if any rows are in the JS buffer (which | ||
// could result from interspersed calls to getRow and getRows). If no rows are in the | ||
// buffer, the call is just proxied to the C layer. Otherwise, rows are pulled from | ||
// the buffer and potentially concatenated with rows from a call to getRows. | ||
// The JS getRows will first check to see if any rows are in the JS buffer | ||
// (which could result from interspersed calls to getRow and getRows). If no | ||
// rows are in the buffer, the call is just proxied to the C layer. Otherwise, | ||
// rows are pulled from the buffer and potentially concatenated with rows from | ||
// a call to getRows. | ||
function getRows(numRows, getRowsCb) { | ||
var self = this; | ||
var rowsNeeded; | ||
const self = this; | ||
let rowsNeeded; | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(typeof numRows === 'number', 'NJS-006', 1); | ||
nodbUtil.assert(typeof getRowsCb === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(Number.isInteger(numRows), 'NJS-005', 2); | ||
nodbUtil.assert(numRows > 0, 'NJS-005', 2); | ||
nodbUtil.assert(typeof getRowsCb === 'function', 'NJS-005', 2); | ||
@@ -112,3 +109,3 @@ if (self._convertedToStream) { | ||
if (self._rowCache.length === 0) { | ||
self._getRows.apply(self, arguments); | ||
self._getRows(numRows, getRowsCb); | ||
} else { | ||
@@ -121,3 +118,3 @@ rowsNeeded = numRows - self._rowCache.length; | ||
self._getRows(rowsNeeded, function(err, rows) { | ||
var requestedRows; | ||
let requestedRows; | ||
@@ -139,95 +136,51 @@ if (err) { | ||
getRowsPromisified = nodbUtil.promisify(getRows); | ||
function toQueryStream() { | ||
var self = this; | ||
var stream; | ||
class ResultSet { | ||
nodbUtil.assert(arguments.length === 0, 'NJS-009'); | ||
constructor() { | ||
this._rowCache = []; | ||
this._processingStarted = false; | ||
this._convertedToStream = false; | ||
this._allowGetRowCall = false; | ||
} | ||
if (self._processingStarted) { | ||
throw new Error(nodbUtil.getErrorMessage('NJS-041')); | ||
_extend(oracledb) { | ||
this._oracledb = oracledb; | ||
this.close = nodbUtil.promisify(oracledb, close); | ||
this.getRow = nodbUtil.promisify(oracledb, getRow); | ||
this.getRows = nodbUtil.promisify(oracledb, getRows); | ||
} | ||
if (self._convertedToStream) { | ||
throw new Error(nodbUtil.getErrorMessage('NJS-043')); | ||
_getDbObjectClassJS(schema, name) { | ||
return this._connection._getDbObjectClassJS(schema, name); | ||
} | ||
self._convertedToStream = true; | ||
_setup(executeOpts) { | ||
this._fetchArraySize = this._oracledb.fetchArraySize; | ||
if (executeOpts && executeOpts.fetchArraySize) { | ||
this._fetchArraySize = executeOpts.fetchArraySize; | ||
} | ||
} | ||
stream = new QueryStream(self, self._oracledb); | ||
toQueryStream() { | ||
const self = this; | ||
return stream; | ||
} | ||
nodbUtil.assert(arguments.length === 0, 'NJS-009'); | ||
// The extend method is used to extend the ResultSet instance from the C layer with | ||
// custom properties and method overrides. References to the original methods are | ||
// maintained so they can be invoked by the overriding method at the right time. | ||
function extend(resultSet, oracledb, executeOpts) { | ||
var fetchArraySize = oracledb.fetchArraySize; | ||
if (self._processingStarted) { | ||
throw new Error(nodbUtil.getErrorMessage('NJS-041')); | ||
} | ||
if (executeOpts && executeOpts.fetchArraySize) { | ||
fetchArraySize = executeOpts.fetchArraySize; | ||
if (self._convertedToStream) { | ||
throw new Error(nodbUtil.getErrorMessage('NJS-043')); | ||
} | ||
self._convertedToStream = true; | ||
return new QueryStream(self); | ||
} | ||
// Using Object.defineProperties to add properties to the ResultSet instance with | ||
// special properties, such as enumerable but not writable. | ||
Object.defineProperties( | ||
resultSet, | ||
{ | ||
_oracledb: { // storing a reference to the base instance to avoid circular references with require | ||
value: oracledb | ||
}, | ||
_fetchArraySize: { // stores the value of fetchArraySize that was passed to conn.execute (if any) | ||
value: fetchArraySize | ||
}, | ||
_rowCache: { // used for storing rows when getRow is used | ||
value: [], | ||
writable: true | ||
}, | ||
_processingStarted: { // used to prevent conversion to stream after invoking methods | ||
value: false, | ||
writable: true | ||
}, | ||
_convertedToStream: { // used to prevent invoking methods after conversion to stream | ||
value: false, | ||
writable: true | ||
}, | ||
_allowGetRowCall: { // allows getRow call after conversion to queryStream | ||
value: false, | ||
writable: true | ||
}, | ||
_close: { | ||
value: resultSet.close | ||
}, | ||
close: { | ||
value: closePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_getRow: { | ||
value: resultSet.getRow | ||
}, | ||
getRow: { | ||
value: getRowPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_getRows: { | ||
value: resultSet.getRows | ||
}, | ||
getRows: { | ||
value: getRowsPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
toQueryStream: { | ||
value: toQueryStream, | ||
enumerable: true, | ||
writable: true | ||
} | ||
} | ||
); | ||
} | ||
module.exports.extend = extend; | ||
module.exports = ResultSet; |
@@ -1,19 +0,19 @@ | ||
/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved */ | ||
// Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved | ||
/************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
@@ -23,34 +23,64 @@ 'use strict'; | ||
const nodbUtil = require('./util.js'); | ||
const sodaDocument = require('./sodaDocument.js'); | ||
const sodaOperation = require('./sodaOperation.js'); | ||
var dropCollectionPromisified; | ||
var insertOnePromisified; | ||
var insertOneAndGetPromisified; | ||
var createIndexPromisified; | ||
var dropIndexPromisified; | ||
var getDataGuidePromisified; | ||
// To drop the collection | ||
function drop(cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 1); | ||
self._drop(cb); | ||
this._drop(cb); | ||
} | ||
dropCollectionPromisified = nodbUtil.promisify(drop); | ||
// To insert a given document to the current collection | ||
function insertMany(docs, cb) { | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(Array.isArray(docs), 'NJS-005', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 2); | ||
if (docs.length == 0) { | ||
cb(new Error(nodbUtil.getErrorMessage('NJS-005', 1))); | ||
return; | ||
} | ||
let actualDocs = Array(docs.length); | ||
for (let i = 0; i < docs.length; i++) { | ||
let content = docs[i]; | ||
if (!nodbUtil.isSodaDocument(content)) { | ||
content = Buffer.from(JSON.stringify(content)); | ||
} | ||
actualDocs[i] = content; | ||
} | ||
this._insertMany(actualDocs, cb); | ||
} | ||
// To insert a given document into the current collection and return the | ||
// metadata of the new document (result-document) | ||
function insertManyAndGet(docs, cb) { | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(Array.isArray(docs), 'NJS-005', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 2); | ||
if (docs.length == 0) { | ||
cb(new Error(nodbUtil.getErrorMessage('NJS-005', 1))); | ||
return; | ||
} | ||
let actualDocs = Array(docs.length); | ||
for (let i = 0; i < docs.length; i++) { | ||
let content = docs[i]; | ||
if (!nodbUtil.isSodaDocument(content)) { | ||
content = Buffer.from(JSON.stringify(content)); | ||
} | ||
actualDocs[i] = content; | ||
} | ||
this._insertManyAndGet(actualDocs, cb); | ||
} | ||
// To insert a given document to the current collection | ||
function insertOne(content, cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(nodbUtil.isObject(content) || | ||
nodbUtil.isSodaDocument(content), 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 2); | ||
nodbUtil.isSodaDocument(content), 'NJS-005', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 2); | ||
@@ -61,17 +91,13 @@ if (!nodbUtil.isSodaDocument(content)) { | ||
self._insertOne(content, cb); | ||
this._insertOne(content, cb); | ||
} | ||
insertOnePromisified = nodbUtil.promisify(insertOne); | ||
// To insert a given document into the current collection and return the | ||
// metadata of the new document (result-document) | ||
function insertOneAndGet(content, cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(nodbUtil.isObject(content) || | ||
nodbUtil.isSodaDocument(content), 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 2); | ||
nodbUtil.isSodaDocument(content), 'NJS-005', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 2); | ||
@@ -82,44 +108,32 @@ if (!nodbUtil.isSodaDocument(content)) { | ||
self._insertOneAndGet(content, function(err, doc) { | ||
if (doc) { | ||
sodaDocument.extend(doc); | ||
} | ||
cb(err, doc); | ||
}); | ||
this._insertOneAndGet(content, cb); | ||
} | ||
insertOneAndGetPromisified = nodbUtil.promisify(insertOneAndGet); | ||
// To create an index on documens | ||
function createIndex(spec, cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009', 1); | ||
nodbUtil.assert(nodbUtil.isObject(spec), 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(nodbUtil.isObject(spec), 'NJS-005', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 2); | ||
self._createIndex(JSON.stringify(spec), cb); | ||
this._createIndex(JSON.stringify(spec), cb); | ||
} | ||
createIndexPromisified = nodbUtil.promisify(createIndex); | ||
// To drop an index from document-collection | ||
function dropIndex(indexName, a2, a3) { | ||
var self = this; | ||
var options = {}; | ||
var dropIndexCb; | ||
let options = {}; | ||
let dropIndexCb; | ||
nodbUtil.assert(arguments.length >= 2 && arguments.length <= 3, 'NJS-009'); | ||
nodbUtil.assert(typeof indexName === 'string', 'NJS-006', 1); | ||
nodbUtil.assert(typeof indexName === 'string', 'NJS-005', 1); | ||
switch (arguments.length) { | ||
case 2: | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-005', 2); | ||
dropIndexCb = a2; | ||
break; | ||
case 3: | ||
nodbUtil.assert(typeof a2 === 'object', 'NJS-006', 2); | ||
nodbUtil.assert(typeof a3 === 'function', 'NJS-006', 3); | ||
nodbUtil.assert(typeof a2 === 'object', 'NJS-005', 2); | ||
nodbUtil.assert(typeof a3 === 'function', 'NJS-005', 3); | ||
options = a2; | ||
@@ -130,110 +144,38 @@ dropIndexCb = a3; | ||
self._dropIndex(indexName, options, dropIndexCb); | ||
this._dropIndex(indexName, options, dropIndexCb); | ||
} | ||
dropIndexPromisified = nodbUtil.promisify(dropIndex); | ||
// To obtain the dataGuide of the document collection | ||
function getDataGuide(cb) { | ||
var self = this; | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-009'); | ||
self._getDataGuide(function(err, doc) { | ||
if (doc) { | ||
sodaDocument.extend(doc); | ||
} | ||
cb(err, doc); | ||
}); | ||
this._getDataGuide(cb); | ||
} | ||
getDataGuidePromisified = nodbUtil.promisify(getDataGuide); | ||
class SodaCollection { | ||
// Creates an instance of sodaOperation object which supports | ||
// terminal/non-terminal functions for find operation. | ||
function find() { | ||
var self = this; | ||
_extend(oracledb) { | ||
this.createIndex = nodbUtil.promisify(oracledb, createIndex); | ||
this.drop = nodbUtil.promisify(oracledb, drop); | ||
this.dropIndex = nodbUtil.promisify(oracledb, dropIndex); | ||
this.getDataGuide = nodbUtil.promisify(oracledb, getDataGuide); | ||
this.insertMany = nodbUtil.promisify(oracledb, insertMany); | ||
this.insertManyAndGet = nodbUtil.promisify(oracledb, insertManyAndGet); | ||
this.insertOne = nodbUtil.promisify(oracledb, insertOne); | ||
this.insertOneAndGet = nodbUtil.promisify(oracledb, insertOneAndGet); | ||
} | ||
var op = self._find(); | ||
sodaOperation.extend(op, self._oracledb); | ||
find() { | ||
nodbUtil.assert(arguments.length === 0, 'NJS-009'); | ||
return this._find(); | ||
} | ||
return op; | ||
} | ||
get metaData() { | ||
return JSON.parse(this._metaData); | ||
} | ||
// The extend method is used to extend the collection instance from C Layer | ||
// with custom properties and method overrides. References to the original | ||
// methods are maintained so they can be invoked by the overriding method at | ||
// the right time | ||
function extend(coll, oracledb) { | ||
// Using Object.defineProperties to add properties to the soda instance with | ||
// special properties. | ||
Object.defineProperties ( | ||
coll, | ||
{ | ||
_oracledb: { | ||
value: oracledb | ||
}, | ||
_drop: { | ||
value: coll.drop | ||
}, | ||
drop: { | ||
value: dropCollectionPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_insertOne: { | ||
value: coll.insertOne | ||
}, | ||
insertOne: { | ||
value: insertOnePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_insertOneAndGet: { | ||
value: coll.insertOneAndGet | ||
}, | ||
insertOneAndGet: { | ||
value: insertOneAndGetPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_createIndex: { | ||
value: coll.createIndex | ||
}, | ||
createIndex: { | ||
value: createIndexPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_dropIndex : { | ||
value: coll.dropIndex | ||
}, | ||
dropIndex: { | ||
value: dropIndexPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_getDataGuide: { | ||
value: coll.getDataGuide | ||
}, | ||
getDataGuide: { | ||
value: getDataGuidePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_find: { | ||
value: coll.find | ||
}, | ||
find: { | ||
value: find, | ||
enumerable: true, | ||
writable: true | ||
} | ||
} | ||
); | ||
} | ||
module.exports.extend = extend; | ||
module.exports = SodaCollection; |
@@ -1,19 +0,19 @@ | ||
/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved */ | ||
// Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved | ||
/************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
@@ -23,27 +23,19 @@ 'use strict'; | ||
const nodbUtil = require('./util.js'); | ||
const sodaCollection = require('./sodaCollection.js'); | ||
const sodaDocument = require('./sodaDocument.js'); | ||
var createCollectionPromisified; | ||
var openCollectionPromisified; | ||
var getCollectionNamesPromisified; | ||
// To create a SODA collection object | ||
function createCollection(name, a2, a3) { | ||
var self = this; | ||
var options = {}; | ||
var createCollCb; | ||
let options = {}; | ||
let createCollCb; | ||
nodbUtil.assert(arguments.length >= 2 && arguments.length <= 3, 'NJS-009'); | ||
nodbUtil.assert(typeof name === 'string', 'NJS-006', 1); | ||
nodbUtil.assert(typeof name === 'string', 'NJS-005', 1); | ||
switch (arguments.length) { | ||
case 2: | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-005', 2); | ||
createCollCb = a2; | ||
break; | ||
case 3: | ||
nodbUtil.assert(nodbUtil.isObject(a2), 'NJS-006', 2); | ||
nodbUtil.assert(typeof a3 === 'function', 'NJS-006', 3); | ||
nodbUtil.assert(nodbUtil.isObject(a2), 'NJS-005', 2); | ||
nodbUtil.assert(typeof a3 === 'function', 'NJS-005', 3); | ||
options = a2; | ||
@@ -53,3 +45,3 @@ createCollCb = a3; | ||
if (!nodbUtil.isObject(options.metaData)) { | ||
createCollCb(Error(nodbUtil.getErrorMessage('NJS-006', 2))); | ||
createCollCb(Error(nodbUtil.getErrorMessage('NJS-005', 2))); | ||
return; | ||
@@ -62,40 +54,21 @@ } | ||
self._createCollection.call(self, name, options, function(err, coll) { | ||
if (err) { | ||
createCollCb(err); | ||
return; | ||
} | ||
sodaCollection.extend(coll, self._oracledb); | ||
createCollCb(null, coll); | ||
}); | ||
this._createCollection(name, options, createCollCb); | ||
} | ||
createCollectionPromisified = nodbUtil.promisify(createCollection); | ||
// To open a collection using given name | ||
// if the collection does not exist, undefined is returned | ||
function openCollection(name, openCollCb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(typeof name === 'string', 'NJS-006', 1); | ||
nodbUtil.assert(typeof openCollCb === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(typeof name === 'string', 'NJS-005', 1); | ||
nodbUtil.assert(typeof openCollCb === 'function', 'NJS-005', 2); | ||
self._openCollection.call(self, name, function (err, coll) { | ||
if (coll) { | ||
sodaCollection.extend(coll, self._oracledb); | ||
} | ||
openCollCb(err, coll); | ||
}); | ||
this._openCollection(name, openCollCb); | ||
} | ||
openCollectionPromisified = nodbUtil.promisify(openCollection); | ||
// To obtain a list of collection names. | ||
function getCollectionNames(a1, a2) { | ||
var self = this; | ||
var options = {}; | ||
var getCollNamesCb; | ||
let options = {}; | ||
let getCollNamesCb; | ||
@@ -106,8 +79,8 @@ nodbUtil.assert(arguments.length >= 1 && arguments.length <= 2, 'NJS-009'); | ||
case 1: | ||
nodbUtil.assert(typeof a1 === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof a1 === 'function', 'NJS-005', 1); | ||
getCollNamesCb = a1; | ||
break; | ||
case 2: | ||
nodbUtil.assert(nodbUtil.isObject(a1), 'NJS-006', 1); | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-006', 2); | ||
nodbUtil.assert(nodbUtil.isObject(a1), 'NJS-005', 1); | ||
nodbUtil.assert(typeof a2 === 'function', 'NJS-005', 2); | ||
options = a1; | ||
@@ -118,83 +91,40 @@ getCollNamesCb = a2; | ||
self._getCollectionNames.call(self, options, getCollNamesCb); | ||
this._getCollectionNames(options, getCollNamesCb); | ||
} | ||
getCollectionNamesPromisified = nodbUtil.promisify(getCollectionNames); | ||
// To create a SODA document object based content and (optional) other fields | ||
function createDocument(content, a2) { | ||
var self = this; | ||
var options = {}; | ||
nodbUtil.assert(arguments.length >= 1 && arguments.length <= 2, 'NJS-009'); | ||
nodbUtil.assert(Buffer.isBuffer(content) || typeof content === 'string' || | ||
nodbUtil.isObject(content), 'NJS-006', 1); | ||
if (arguments.length > 1) { | ||
nodbUtil.assert(nodbUtil.isObject(a2), 'NJS-006', 2); | ||
options = a2; | ||
} | ||
class SodaDatabase { | ||
if (typeof content === 'string') { | ||
content = Buffer.from(content); | ||
} else if (nodbUtil.isObject(content)) { | ||
content = Buffer.from(JSON.stringify(content)); | ||
_extend(oracledb) { | ||
this.createCollection = nodbUtil.promisify(oracledb, createCollection); | ||
this.getCollectionNames = nodbUtil.promisify(oracledb, getCollectionNames); | ||
this.openCollection = nodbUtil.promisify(oracledb, openCollection); | ||
} | ||
var doc = self._createDocument(content, options); | ||
sodaDocument.extend(doc); | ||
return doc; | ||
} | ||
// To create a SODA document object based content and (optional) other fields | ||
createDocument(content, a2) { | ||
let options = {}; | ||
nodbUtil.assert(arguments.length >= 1 && arguments.length <= 2, 'NJS-009'); | ||
nodbUtil.assert(Buffer.isBuffer(content) || typeof content === 'string' || | ||
nodbUtil.isObject(content), 'NJS-005', 1); | ||
if (arguments.length > 1) { | ||
nodbUtil.assert(nodbUtil.isObject(a2), 'NJS-005', 2); | ||
options = a2; | ||
} | ||
// The extend method is used to extend the soda instance from C Layer with | ||
// custom properties and method overrides. References to the original methods | ||
// are maintained so they can be invoked by the overriding method at the | ||
// right time | ||
function extend(db, conn) { | ||
// Using Object.defineProperties to add properties to the soda instance with | ||
// special properties. | ||
Object.defineProperties ( | ||
db, | ||
{ | ||
_oracledb: { // storing a reference to the base instance to avoid circular | ||
// references with require | ||
value: conn._oracledb | ||
}, | ||
_createCollection: { | ||
value: db.createCollection | ||
}, | ||
_openCollection: { | ||
value: db.openCollection | ||
}, | ||
_getCollectionNames: { | ||
value: db.getCollectionNames | ||
}, | ||
_createDocument: { | ||
value: db.createDocument | ||
}, | ||
createCollection: { | ||
value: createCollectionPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
openCollection: { | ||
value: openCollectionPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
getCollectionNames: { | ||
value: getCollectionNamesPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
createDocument: { | ||
value: createDocument, | ||
enumerable: true, | ||
writable: true | ||
} | ||
if (typeof content === 'string') { | ||
content = Buffer.from(content); | ||
} else if (nodbUtil.isObject(content)) { | ||
content = Buffer.from(JSON.stringify(content)); | ||
} | ||
); | ||
return this._createDocument(content, options); | ||
} | ||
} | ||
module.exports.extend = extend; | ||
module.exports = SodaDatabase; |
@@ -1,19 +0,19 @@ | ||
/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved */ | ||
// Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved | ||
/************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
@@ -23,8 +23,3 @@ 'use strict'; | ||
const nodbUtil = require('./util.js'); | ||
const sodaDocument = require('./sodaDocument.js'); | ||
var getNextPromisified; | ||
var closePromisified; | ||
//----------------------------------------------------------------------------- | ||
@@ -35,18 +30,9 @@ // getNext | ||
function getNext(cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 1); | ||
self._getNext(function(err, doc) { | ||
if (doc) { | ||
sodaDocument.extend(doc); | ||
} | ||
cb(err, doc); | ||
}); | ||
this._getNext(cb); | ||
} | ||
getNextPromisified = nodbUtil.promisify(getNext); | ||
//----------------------------------------------------------------------------- | ||
@@ -57,5 +43,4 @@ // close | ||
function close(cb) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 1); | ||
@@ -65,38 +50,12 @@ this._close(cb); | ||
closePromisified = nodbUtil.promisify(close); | ||
class SodaDocCursor { | ||
// The extend method is used to extend the SodaDocCursor instance from C Layer | ||
// with custom properties and method overrides. References to the original | ||
// methods are maintained so they can be invoked by the overriding method at | ||
// the right time | ||
function extend(cursor, oracledb) { | ||
// Using Object.defineProperties to add properties to the soda instance with | ||
// special properties | ||
Object.defineProperties ( | ||
cursor, | ||
{ | ||
_oracledb: { | ||
value: oracledb | ||
}, | ||
_getNext: { | ||
value: cursor.getNext | ||
}, | ||
getNext: { | ||
value: getNextPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_close: { | ||
value: cursor.close | ||
}, | ||
close: { | ||
value: closePromisified, | ||
enumerable: true, | ||
writable: true | ||
} | ||
} | ||
); | ||
_extend(oracledb) { | ||
this.close = nodbUtil.promisify(oracledb, close); | ||
this.getNext = nodbUtil.promisify(oracledb, getNext); | ||
} | ||
} | ||
module.exports.extend = extend; | ||
module.exports = SodaDocCursor; |
@@ -1,75 +0,45 @@ | ||
/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved */ | ||
// Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved | ||
/************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
'use strict'; | ||
// returns the document content as a Javascript object | ||
function getContent() { | ||
return JSON.parse(this._getContentAsString()); | ||
} | ||
class SodaDocument { | ||
_extend() { | ||
this._sodaDocumentMarker = true; | ||
} | ||
// returns the document content as a string | ||
function getContentAsString() { | ||
return this._getContentAsString(); | ||
} | ||
// returns the document content as a Javascript object | ||
getContent() { | ||
return JSON.parse(this._getContentAsString()); | ||
} | ||
// returns the document content as a buffer | ||
getContentAsBuffer() { | ||
return this._getContentAsBuffer(); | ||
} | ||
// returns the document content as a buffer | ||
function getContentAsBuffer() { | ||
return this._getContentAsBuffer(); | ||
} | ||
// returns the document content as a string | ||
getContentAsString() { | ||
return this._getContentAsString(); | ||
} | ||
// extends the SodaDocument instance from the C layer with custom properties | ||
// and method overrides; references to the original methods are maintained so | ||
// that they can be invoked by the overriding method at the right time | ||
function extend(doc) { | ||
Object.defineProperties ( | ||
doc, | ||
{ | ||
_sodaDocumentMarker: { | ||
value: true | ||
}, | ||
_getContentAsString: { | ||
value: doc.getContentAsString | ||
}, | ||
_getContentAsBuffer: { | ||
value: doc.getContentAsBuffer | ||
}, | ||
getContent: { | ||
value: getContent, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
getContentAsString: { | ||
value: getContentAsString, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
getContentAsBuffer: { | ||
value: getContentAsBuffer, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
} | ||
); | ||
} | ||
module.exports.extend = extend; | ||
module.exports = SodaDocument; |
@@ -1,19 +0,19 @@ | ||
/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved */ | ||
// Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved | ||
/************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
@@ -23,25 +23,12 @@ 'use strict'; | ||
const nodbUtil = require('./util.js'); | ||
const sodaDocument = require('./sodaDocument.js'); | ||
const sodaDocCursor = require('./sodaDocCursor.js'); | ||
var countPromisified; | ||
var getOnePromisified; | ||
var replaceOnePromisified; | ||
var replaceOneAndGetPromisified; | ||
var removePromisified; | ||
var getCursorPromisified; | ||
var getDocumentsPromisified; | ||
// to obtain count of documents from find() result | ||
// This is a terminal function (no further chaining possible) | ||
function count(cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 1); | ||
self._count(this._options, cb); | ||
this._count(this._options, cb); | ||
} | ||
countPromisified = nodbUtil.promisify(count); | ||
@@ -51,27 +38,17 @@ // To obtain first document object from find() result | ||
function getOne(cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 1); | ||
self._getOne(this._options, function(err, doc) { | ||
if (doc) { | ||
sodaDocument.extend(doc); | ||
} | ||
cb(err, doc); | ||
}); | ||
this._getOne(this._options, cb); | ||
} | ||
getOnePromisified = nodbUtil.promisify(getOne); | ||
// To replace one document by a given document based from find() result | ||
// This is a terminal function (no further chaining possible) | ||
function replaceOne(content, cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(nodbUtil.isObject(content) || | ||
nodbUtil.isSodaDocument(content), 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 2); | ||
nodbUtil.isSodaDocument(content), 'NJS-005', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 2); | ||
@@ -82,17 +59,13 @@ if (!nodbUtil.isSodaDocument(content)) { | ||
self._replaceOne(this._options, content, cb); | ||
this._replaceOne(this._options, content, cb); | ||
} | ||
replaceOnePromisified = nodbUtil.promisify(replaceOne); | ||
// To replace one document by a given document based from find() result | ||
// This is a terminal function (no further chaining possible) | ||
function replaceOneAndGet(content, cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 2, 'NJS-009'); | ||
nodbUtil.assert(nodbUtil.isObject(content) || | ||
nodbUtil.isSodaDocument(content), 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 2); | ||
nodbUtil.isSodaDocument(content), 'NJS-005', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 2); | ||
@@ -103,232 +76,111 @@ if (!nodbUtil.isSodaDocument(content)) { | ||
self._replaceOneAndGet(this._options, content, function(err, doc) { | ||
if (doc) { | ||
sodaDocument.extend(doc); | ||
} | ||
cb(err, doc); | ||
}); | ||
this._replaceOneAndGet(this._options, content, cb); | ||
} | ||
replaceOneAndGetPromisified = nodbUtil.promisify(replaceOneAndGet); | ||
// To remove documents obtained from find() result | ||
// This is a terminal function (no further chaining possible) | ||
function remove(cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 1); | ||
self._remove(this._options, cb); | ||
this._remove(this._options, cb); | ||
} | ||
removePromisified = nodbUtil.promisify(remove); | ||
// To obtain document-cursor object from find() result | ||
// This is a terminal function (no further chaining possible) | ||
function getCursor(cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 1); | ||
self._getCursor(this._options, function(err, cursor) { | ||
if (cursor) { | ||
sodaDocCursor.extend(cursor, self._oracledb); | ||
} | ||
cb(err, cursor); | ||
}); | ||
this._getCursor(this._options, cb); | ||
} | ||
getCursorPromisified = nodbUtil.promisify(getCursor); | ||
// to obtain documents from find() result | ||
// This is a terminal function (no further chaining possible) | ||
function getDocuments(cb) { | ||
var self = this; | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-006', 1); | ||
nodbUtil.assert(typeof cb === 'function', 'NJS-005', 1); | ||
self._getDocuments(this._options, function(err, docs) { | ||
if (err) { | ||
cb(err, null); | ||
return; | ||
} | ||
for (let i = 0; i < docs.length; i++) { | ||
sodaDocument.extend(docs[i]); | ||
} | ||
cb(null, docs); | ||
}); | ||
this._getDocuments(this._options, cb); | ||
} | ||
getDocumentsPromisified = nodbUtil.promisify(getDocuments); | ||
// limit property - a non-terminal function and can chain further | ||
function _limit (n) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof n === 'number', 'NJS-006', 1); | ||
this._options.limit = n; | ||
return this; | ||
} | ||
class SodaOperation { | ||
constructor() { | ||
this._options = {}; | ||
} | ||
// skip property - a non-terminal function and can chain further | ||
function _skip(n) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof n === 'number', 'NJS-006', 1); | ||
this._options.skip = n; | ||
return this; | ||
} | ||
_extend(oracledb) { | ||
this.count = nodbUtil.promisify(oracledb, count); | ||
this.getCursor = nodbUtil.promisify(oracledb, getCursor); | ||
this.getDocuments = nodbUtil.promisify(oracledb, getDocuments); | ||
this.getOne = nodbUtil.promisify(oracledb, getOne); | ||
this.remove = nodbUtil.promisify(oracledb, remove); | ||
this.replaceOne = nodbUtil.promisify(oracledb, replaceOne); | ||
this.replaceOneAndGet = nodbUtil.promisify(oracledb, replaceOneAndGet); | ||
} | ||
// version property - a non-terminal function and can chain further | ||
function _version(v) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof v === 'string', 'NJS-006', 1); | ||
this._options.version = v; | ||
return this; | ||
} | ||
// filter property - a non-terminal function and can chain further | ||
filter(f) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(nodbUtil.isObject(f), 'NJS-005', 1); | ||
this._options.filter = JSON.stringify(f); | ||
return this; | ||
} | ||
// filter property - a non-terminal function and can chain further | ||
function _filter(f) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(nodbUtil.isObject(f), 'NJS-006', 1); | ||
this._options.filter = JSON.stringify(f); | ||
return this; | ||
} | ||
// key - a non-terminal function and can chain further | ||
key(k) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof k === 'string', 'NJS-005', 1); | ||
this._options.key = k; | ||
this._options.keys = undefined; | ||
return this; | ||
} | ||
// key - a non-terminal function and can chain further | ||
function _key(k) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof k === 'string', 'NJS-006', 1); | ||
this._options.key = k; | ||
this._options.keys = undefined; | ||
return this; | ||
} | ||
// keys - a non-terminal function and can chain further | ||
keys(arr) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(Array.isArray(arr), 'NJS-005', 1); | ||
// keys - a non-terminal function and can chain further | ||
function _keys(arr) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(Array.isArray(arr), 'NJS-006', 1); | ||
for (let i = 0; i < arr.length; i++) { | ||
nodbUtil.assert(typeof arr[i] === 'string', 'NJS-005', 1); | ||
} | ||
for (let i = 0; i < arr.length; i++) { | ||
nodbUtil.assert(typeof arr[i] === 'string', 'NJS-006', 1); | ||
this._options.keys = arr; | ||
this._options.key = undefined; | ||
return this; | ||
} | ||
this._options.keys = arr; | ||
this._options.key = undefined; | ||
return this; | ||
} | ||
// limit property - a non-terminal function and can chain further | ||
limit (n) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof n === 'number', 'NJS-005', 1); | ||
this._options.limit = n; | ||
return this; | ||
} | ||
// skip property - a non-terminal function and can chain further | ||
skip(n) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof n === 'number', 'NJS-005', 1); | ||
this._options.skip = n; | ||
return this; | ||
} | ||
// The extend method is used to extend the sodaOperation istance from C Layer | ||
// with custom properties and method overrides. References to the original | ||
// methods are maintained so they can be invoked by the overriding method at | ||
// the right time | ||
function extend(sodaOp, oracledb) { | ||
// Using Object.defineProperties to add properties to the soda instance with | ||
// special properties | ||
Object.defineProperties ( | ||
sodaOp, | ||
{ | ||
_oracledb: { | ||
value: oracledb | ||
}, | ||
limit: { | ||
value: _limit, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
skip: { | ||
value: _skip, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
version: { | ||
value: _version, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
filter: { | ||
value: _filter, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
key: { | ||
value: _key, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
keys: { | ||
value: _keys, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_options: { | ||
value: {} | ||
}, | ||
_count: { | ||
value: sodaOp.count | ||
}, | ||
count: { | ||
value: countPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_getOne: { | ||
value: sodaOp.getOne | ||
}, | ||
getOne: { | ||
value: getOnePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_replaceOne: { | ||
value: sodaOp.replaceOne | ||
}, | ||
replaceOne: { | ||
value: replaceOnePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_replaceOneAndGet: { | ||
value: sodaOp.replaceOneAndGet | ||
}, | ||
replaceOneAndGet: { | ||
value: replaceOneAndGetPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_remove: { | ||
value: sodaOp.remove | ||
}, | ||
remove: { | ||
value: removePromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_getCursor: { | ||
value: sodaOp.getCursor | ||
}, | ||
getCursor: { | ||
value: getCursorPromisified, | ||
enumerable: true, | ||
writable: true | ||
}, | ||
_getDocuments: { | ||
value: sodaOp.getDocuments | ||
}, | ||
getDocuments: { | ||
value: getDocumentsPromisified, | ||
enumerable: true, | ||
writable: true | ||
} | ||
} | ||
); | ||
// version property - a non-terminal function and can chain further | ||
version(v) { | ||
nodbUtil.assert(arguments.length === 1, 'NJS-009'); | ||
nodbUtil.assert(typeof v === 'string', 'NJS-005', 1); | ||
this._options.version = v; | ||
return this; | ||
} | ||
} | ||
module.exports.extend = extend; | ||
module.exports = SodaOperation; |
123
lib/util.js
@@ -1,24 +0,34 @@ | ||
/* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. */ | ||
// Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved | ||
/****************************************************************************** | ||
* | ||
* You may not use the identified files except in compliance with the Apache | ||
* License, Version 2.0 (the "License.") | ||
* | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*****************************************************************************/ | ||
//----------------------------------------------------------------------------- | ||
// | ||
// You may not use the identified files except in compliance with the Apache | ||
// License, Version 2.0 (the "License.") | ||
// | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//----------------------------------------------------------------------------- | ||
'use strict'; | ||
var util = require('util'); | ||
const util = require('util'); | ||
// node-oracledb version number | ||
let packageJSON; | ||
try { | ||
packageJSON = require('../package.json'); | ||
} catch(err) { | ||
throw new Error('package.json is missing'); | ||
} | ||
const PACKAGE_JSON_VERSION = packageJSON.version; | ||
module.exports.PACKAGE_JSON_VERSION = PACKAGE_JSON_VERSION; | ||
// Directory containing the node-oracledb add-on binary | ||
@@ -29,3 +39,3 @@ const RELEASE_DIR = 'build/Release'; | ||
// The default node-oracledb add-on binary filename for this Node.js | ||
const BINARY_FILE = 'oracledb-abi' + process.versions.modules + '-' + process.platform + '-' + process.arch + '.node'; | ||
const BINARY_FILE = 'oracledb-' + PACKAGE_JSON_VERSION + '-' + process.platform + '-' + process.arch + '.node'; | ||
module.exports.BINARY_FILE = BINARY_FILE; | ||
@@ -37,18 +47,10 @@ | ||
var EventEmitter = require('events').EventEmitter; | ||
var eventEmitterKeys = Object.keys(EventEmitter.prototype); | ||
var eventEmitterFuncKeys = eventEmitterKeys.filter(function(key) { | ||
return typeof EventEmitter.prototype[key] === 'function'; | ||
}); | ||
// errorMessages is for NJS error messages used in the JavaScript layer | ||
var errorMessages = { | ||
const errorMessages = { | ||
'NJS-002': 'NJS-002: invalid pool', | ||
'NJS-004': 'NJS-004: invalid value for property %s', | ||
'NJS-005': 'NJS-005: invalid value for parameter %d', | ||
'NJS-006': 'NJS-006: invalid type for parameter %d', | ||
'NJS-009': 'NJS-009: invalid number of parameters', | ||
'NJS-014': 'NJS-014: %s is a read-only property', | ||
'NJS-037': 'NJS-037: incompatible type of value provided', | ||
'NJS-040': 'NJS-040: connection request timeout', | ||
'NJS-040': 'NJS-040: connection request timeout. Request exceeded queueTimeout of %d', | ||
'NJS-041': 'NJS-041: cannot convert ResultSet to QueryStream after invoking methods', | ||
@@ -60,6 +62,6 @@ 'NJS-042': 'NJS-042: cannot invoke ResultSet methods after converting to QueryStream', | ||
'NJS-047': 'NJS-047: poolAlias "%s" not found in the connection pool cache', | ||
'NJS-054': 'NJS-054: binary build/Release/oracledb.node was not installed', | ||
'NJS-064': 'NJS-064: connection pool is closing', | ||
'NJS-065': 'NJS-065: connection pool was closed', | ||
'NJS-067': 'NJS-067: a pre-built node-oracledb binary was not found for Node.js %s' | ||
'NJS-067': 'NJS-067: a pre-built node-oracledb binary was not found for %s', | ||
'NJS-069': 'NJS-069: node-oracledb %s requires Node.js %s or later' | ||
}; | ||
@@ -76,4 +78,4 @@ | ||
function getInstallHelp() { | ||
var arch, url; | ||
var mesg = getInstallURL() + '\n'; | ||
let arch, url; | ||
let mesg = getInstallURL() + '\n'; | ||
if (process.platform === 'linux') { | ||
@@ -132,31 +134,16 @@ if (process.arch === 'x64') { | ||
// makeEventEmitter is used to make class instances inherit from the EventEmitter | ||
// class. This is needed because we extend instances from the C layer and thus | ||
// don't have JavaScript constructor functions we can use for more traditional | ||
// inheritance. | ||
function makeEventEmitter(instance){ | ||
eventEmitterFuncKeys.forEach(function(key) { | ||
instance[key] = EventEmitter.prototype[key]; | ||
}); | ||
EventEmitter.call(instance); | ||
// getErrorMessage is used to get and format error messages to make throwing | ||
// errors a little more convenient. | ||
function getErrorMessage(errorCode) { | ||
let args = Array.prototype.slice.call(arguments); | ||
args[0] = errorMessages[errorCode]; | ||
return util.format.apply(util, args); | ||
} | ||
module.exports.makeEventEmitter = makeEventEmitter; | ||
// getErrorMessage is used to get and format error messages to make throwing errors | ||
// a little more convenient. | ||
function getErrorMessage(errorCode, messageArg1) { | ||
if (messageArg1) { | ||
return util.format(errorMessages[errorCode], messageArg1); | ||
} else { | ||
return util.format(errorMessages[errorCode]); | ||
} | ||
} | ||
module.exports.getErrorMessage = getErrorMessage; | ||
// assert it typically used in the beginning of public functions to assert preconditions | ||
// for the function to execute. Most commonly it's used to validate arguments lenght | ||
// and types and throw an error if they don't match what is expected. | ||
// assert is typically used at the beginning of public functions to assert | ||
// preconditions for the function to execute. Most commonly it is used to | ||
// validate the number of arguments and their types and throw an error if they | ||
// don't match what is expected. | ||
function assert(condition, errorCode, messageArg1) { | ||
@@ -173,12 +160,10 @@ if (!condition) { | ||
// assumed that the callback pattern is being used and the method is invoked as | ||
// usual. Otherwise a promise is returned and later resolved or rejected based on | ||
// the return of the method. | ||
function promisify(func) { | ||
// usual. Otherwise a promise is returned and later resolved or rejected based | ||
// on the return of the method. | ||
function promisify(oracledb, func) { | ||
return function() { | ||
var self = this; | ||
var args; | ||
const self = this; | ||
let args; | ||
// This/self could refer to the base class instance, pool, connection, etc. All | ||
// class instances have a private reference to the base class for convenience. | ||
if (!self._oracledb.Promise || typeof arguments[arguments.length - 1] === 'function') { | ||
if (!oracledb.Promise || typeof arguments[arguments.length - 1] === 'function') { | ||
return func.apply(self, arguments); | ||
@@ -189,4 +174,4 @@ } else { | ||
return new self._oracledb.Promise(function(resolve, reject) { | ||
var errorCode; | ||
return new oracledb.Promise(function(resolve, reject) { | ||
let errorCode; | ||
@@ -208,3 +193,3 @@ try { | ||
// eagerly thrown. | ||
if (errorCode === 'NJS-009' || errorCode === 'NJS-006') { | ||
if (errorCode === 'NJS-009' || errorCode === 'NJS-005') { | ||
// Throwing the error outside of the promise wrapper so that its not | ||
@@ -211,0 +196,0 @@ // swallowed up as a rejection. |
{ | ||
"name": "oracledb", | ||
"version": "3.1.2", | ||
"version": "4.0.0", | ||
"description": "A Node.js module for Oracle Database access", | ||
@@ -36,3 +36,3 @@ "license": "Apache-2.0", | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=8.16" | ||
}, | ||
@@ -39,0 +39,0 @@ "maintainers": [ |
@@ -39,10 +39,2 @@ /* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. */ | ||
let packageJSON; | ||
try { | ||
packageJSON = require('../package.json'); | ||
} catch(err) { | ||
throw new Error('package.json is missing'); | ||
} | ||
const PACKAGE_JSON_VERSION = packageJSON.version; | ||
// Log standard output with an 'oracledb' prefix | ||
@@ -68,3 +60,7 @@ function log(message) { // eslint-disable-line | ||
error(err.message); | ||
error('Try compiling node-oracledb source code using ' + installUrl + '#github'); | ||
if (err.message.match(/^NJS-067/)) { | ||
error('Try compiling node-oracledb source code using ' + installUrl + '#github'); | ||
} else if (err.message.match(/^NJS-069/)) { | ||
error('An older node-oracledb version may work with Node.js ' + process.version); | ||
} | ||
process.exit(87); | ||
@@ -83,3 +79,3 @@ } else { // Successfully installed | ||
log('** Node-oracledb ' + PACKAGE_JSON_VERSION + ' installed for Node.js ' + process.versions.node + ' (' + process.platform + ', ' + process.arch +')'); | ||
log('** Node-oracledb ' + nodbUtil.PACKAGE_JSON_VERSION + ' installed for Node.js ' + process.versions.node + ' (' + process.platform + ', ' + process.arch +')'); | ||
@@ -103,3 +99,3 @@ log('**'); | ||
log('** - An Oracle Instant Client Basic or Basic Light package must be in ~/lib or /usr/local/lib'); | ||
log('** - Oracle Instant Client Basic or Basic Light package libraries must be in ~/lib or /usr/local/lib'); | ||
log('** Download from ' + clientUrl); | ||
@@ -131,11 +127,21 @@ } else if (process.platform === 'win32') { | ||
// Check there is a usable binary file for the node-oracledb module | ||
// Check for a usable binary file for the node-oracledb module. | ||
// Node.js 8.16 and 10.16 (and 12.0) contain an important N-API | ||
// performance regression fix. If you're using the obsolete Node.js 9 | ||
// or 11 versions, install will work but you're on your own regarding | ||
// performance and functionality. | ||
function checkAvailable(cb) { | ||
const binaryFile = nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE; | ||
try { | ||
fs.statSync(binaryFile); | ||
cb(); | ||
} catch (err) { | ||
let m = process.version + ' (NODE_MODULE_VERSION=' + process.versions.modules + ') on ' + process.platform + ' ' + process.arch; | ||
cb(new Error(nodbUtil.getErrorMessage('NJS-067', m))); | ||
let vs = process.version.substring(1).split(".").map(Number); | ||
if (vs[0] < 8 || (vs[0] === 8 && vs[1] < 16)) { | ||
cb(new Error(nodbUtil.getErrorMessage('NJS-069', nodbUtil.PACKAGE_JSON_VERSION, "8.16"))); | ||
} else if (vs[0] === 10 && vs[1] < 16) { | ||
cb(new Error(nodbUtil.getErrorMessage('NJS-069', nodbUtil.PACKAGE_JSON_VERSION, "10.16"))); | ||
} else { | ||
try { | ||
fs.statSync(nodbUtil.RELEASE_DIR + '/' + nodbUtil.BINARY_FILE); | ||
cb(); | ||
} catch (err) { | ||
cb(new Error(nodbUtil.getErrorMessage('NJS-067', process.platform + ' ' + process.arch))); | ||
} | ||
} | ||
@@ -142,0 +148,0 @@ } |
@@ -13,35 +13,34 @@ # Overview | ||
- `npm run buildbinary` calls `buildbinary.js` to create a binary for | ||
the current node-oracledb / Node.js / platform combination. | ||
- `npm run buildbinary` calls `buildbinary.js` to create a | ||
node-oracledb binary for the current operating system. | ||
- `npm run buildpackage` calls `buildpackage.js` to make the | ||
node-oracledb package containing the node-oracledb JavaScript files, | ||
the available binaries, and a package.json that has an "install" | ||
script and a "prune" script. The package will be created in the top | ||
the available binaries, and a package.json that has an `install` | ||
script and a `prune` script. The package will be created in the top | ||
level directory. | ||
Before executing `npm run buildpackage`, all binaries and related | ||
build metadata information files from all node-oracledb / Node.js / | ||
platform combinations should be placed in the `package/Staging` | ||
directory. | ||
Before executing `npm run buildpackage`, all node-oracledb binaries | ||
and related build metadata information files from all operating | ||
systems should be placed in the `package/Staging` directory. | ||
Package installation: | ||
# Package Installation | ||
- As part of an `npm install` that uses the created package, the | ||
`package.json` install script runs `package/install.js` to check a | ||
binary module for the current Node.js and platform is available. | ||
`package.json` install script runs `install.js` to check a binary | ||
module for the current Node.js and operating system is available. | ||
If a suitable binary is not available, installation will fail. | ||
Users must then compile node-oracledb using source code from GitHub, | ||
or choose an alternative Node.js / platform that has a pre-built | ||
binary module. | ||
Users must then compile node-oracledb using source code from GitHub. | ||
Alternatively a different version of node-oracledb, Node.js, or | ||
different operating system may have a suitable pre-built binary | ||
available. | ||
- After install, space conscious users can run `npm run prune` which | ||
removes pre-built binaries for all other Node.js releases and | ||
architectures. | ||
removes pre-built binaries for all other operating systems. | ||
By default the top level `package.json` doesn't have an install script | ||
target. This means that node-gyp will be invoked to compile | ||
By default the top level `package.json` doesn't have an `install` | ||
script target. This means that node-gyp will be invoked to compile | ||
node-oracledb. This allows installation from [source | ||
code](https://oracle.github.io/node-oracledb/INSTALL.html#github) (via | ||
GitHub) when no suitable pre-built binary is available. |
@@ -1,2 +0,2 @@ | ||
# node-oracledb version 3.1 | ||
# node-oracledb version 4.0 | ||
@@ -6,7 +6,7 @@ The node-oracledb add-on for Node.js powers high performance Oracle | ||
Use node-oracledb to connect Node.js 6, 8, 10 and 11 to Oracle Database. | ||
Use node-oracledb 4.0 to connect Node.js 8.16, 10.16, 12, or later, to Oracle Database. | ||
Older versions of node-oracledb may work with older versions of Node.js. | ||
Node-oracledb supports basic and advanced features of Oracle Database | ||
and Oracle Client. See the | ||
[homepage][4] for a list. | ||
and Oracle Client. See the [homepage][4] for a list. | ||
@@ -26,4 +26,3 @@ The node-oracledb module is open source and maintained by Oracle Corp. | ||
See the [examples][30] directory. Start with | ||
[examples/example.js][31]. | ||
See the [examples][30] directory. Start with [examples/example.js][31]. | ||
@@ -49,3 +48,3 @@ ## <a name="help"></a> Help | ||
Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. | ||
Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. | ||
@@ -52,0 +51,0 @@ You may not use the identified files except in compliance with the Apache |
Sorry, the diff of this file is too big to display
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
1
100
4
1946358
31
2596
75