Release announcement: A new release of node-oracledb, the Node.js module for accessing Oracle Database, is available from npm.
Top features: Binding of NCHAR and new types; Finer grained control on bind data types; New result.lastRowid support; Client-initiated CQN connections
Significant changes in node-oracledb 4.2 are:
New bind types and improvements.
First, some background: when executing SQL, binding data values to the statement (instead of using string concatenation) is always recommended for scalability and security. A fundamental design feature (for performance) of Oracle binding is that the client doesn't know the database data type prior to (or as part of) the connection.execute() call: node-oracledb simply says to the database "here is some data, please perform the bind as if it is type X", or "here is an empty buffer, please give me back data as type Y". Internally, node-oracledb passes the numeric value of the bind type from your application code down to the Oracle Client libraries, and they do their magic conversion between the client and database data types when the data is transferred.
Now in node-oracledb 4.2 you can optionally specify the bind type using the database type system, for example you can use oracledb.DB_TYPE_TIMESTAMP when binding a Date to a TIMESTAMP column. The new type constants supported are oracledb.DB_TYPE_DATE, oracledb.DB_TYPE_CHAR, oracledb.DB_TYPE_NCHAR, oracledb.DB_TYPE_NVARCHAR, oracledb.DB_TYPE_NCLOB, oracledb.DB_TYPE_BINARY_DOUBLE, oracledb.DB_TYPE_BINARY_FLOAT, oracledb.DB_TYPE_BINARY_INTEGER, oracledb.DB_TYPE_TIMESTAMP, and oracledb.DB_TYPE_TIMESTAMP_TZ. Conveniently while we were adding these, support for binding oracledb.DB_TYPE_BOOLEAN was made via a contribution from Diego Arce. Thanks Diego - that was good timing!
Review the new bind type table in the documentation for more detail. To repeat: if your code's bind type values (e.g. oracledb.NUMBER), or the default values chosen by node-oracledb, have been fine, then you don't need to change anything.
After INSERT, UPDATE, DELETE or MERGE statement, the result object returned by connection.execute() will now contain a lastRowid property containing the ROWID of the row affected by the operation. If the SQL statement affects more than one row, only the last ROWID is returned.
If you are using Oracle Database 19.4 (or later) and node-oracledb is linked with Oracle Client 19.4 (or later) libraries, then you can take advantage of the new Continuous Query Notification (CQN) mode clientInitiated for 'client initiated' connections. In CQN documentation these are referred to as 'secure connections' because the CQN channel gets established without the database needing to be able to initiate connection to node-oracledb.
For users who are streaming LOBs using the node-oracledb Lob object, we updated the best practice recommendations and examples to use the Node.js 8 Stream destroy() method in place of the node-oracledb close() method. The latter is now deprecated. To migrate, change the method calls from lob.close() to lob.destroy(), stop passing a callback, and optionally pass an error. Then review your event handling code.
See the CHANGELOG for all changes and bug fixes. Thanks as always to developers, contributors and users who have worked on this release.
One final note: this will be the last node-oracledb release that we'll test with Node.js 8, which has finished its maintenance period and is EOL. If you haven't already upgraded to Node.js 10 or 12, now is the time to do it.
Let us know how you are using node-oracledb, and what other features you'd like in future releases.
Node-oracledb installation instructions are here.
Node-oracledb documentation is here.
Node-oracledb change log is here.
Finally, contributions to node-oracledb are more than welcome, see CONTRIBUTING.