Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@soinlabs/sybase

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@soinlabs/sybase - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

JavaSybaseLink/dist/lib/HikariCP-4.0.3.jar

2

package.json
{
"name": "@soinlabs/sybase",
"version": "1.0.0",
"version": "1.0.1",
"description": "This library provides a Node.js bridge to connect to a Sybase database. It uses a Java bridge to facilitate the connection and query execution.",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -16,3 +16,3 @@ # Sybase Node.js Bridge

* java 1.5+
* java 1.8+

@@ -19,0 +19,0 @@ ## Usage

@@ -13,2 +13,9 @@ const spawn = require("child_process").spawn;

password,
minConnections = 1,
maxConnections = 1,
connectionTimeout = 30000,
idleTimeout = 60000,
keepaliveTime = 0,
maxLifetime = 1800000,
transactionConnections = 5,
logTiming,

@@ -25,2 +32,10 @@ pathToJavaBridge,

this.password = password;
this.minConnections = minConnections;
this.maxConnections = maxConnections;
this.connectionTimeout = connectionTimeout;
this.idleTimeout = idleTimeout;
this.keepaliveTime = keepaliveTime;
this.maxLifetime = maxLifetime;
this.transactionConnections = transactionConnections;
this.transactionConnections
this.logTiming = logTiming === true;

@@ -43,2 +58,3 @@ this.encoding = encoding;

this.queryCount = 0;
this.transactionCount = 0;
this.currentMessages = {}; // look up msgId to message sent and call back details.

@@ -136,2 +152,9 @@

this.password,
this.minConnections,
this.maxConnections,
this.connectionTimeout,
this.idleTimeout,
this.keepaliveTime,
this.maxLifetime,
this.transactionConnections
]);

@@ -191,3 +214,11 @@

const prepareQuery = function (sql, callback) {
/**
* Prepares a SQL query to be executed asynchronously.
* @param {string} sql - The SQL query to execute.
* @param {number} transactionId - The transaction ID to use, defaults to -1 (no transaction).
* @param {boolean} finishTransaction - Whether to finish the transaction after the query is done. Defaults to false.
* @param {function} callback - The callback function to execute once the query is done.
* Returns a stringified message to be sent to the Java process.
*/
const prepareQuery = function (sql, transactionId, finishTransaction = false, callback) {
if (!this.isConnected()) {

@@ -204,2 +235,4 @@ if (callback) callback(new Error("Database isn't connected."));

msgId: this.queryCount,
transId: transactionId,
finishTrans: finishTransaction,
sql: sql,

@@ -214,3 +247,3 @@ sentTime: new Date().getTime(),

this.log(
`this: ${this} currentMessages: ${this.currentMessages} this.queryCount: ${this.queryCount}`
`prepareQuery: msgId: ${msg.msgId} currentMessages: ${Object.keys(this.currentMessages).length} this.queryCount: ${this.queryCount}`
);

@@ -240,3 +273,3 @@

this.query = function (sql, callback) {
const strMsg = prepareQuery(sql, callback);
const strMsg = prepareQuery(sql, -1, false, callback);
if (strMsg === null) return;

@@ -252,2 +285,4 @@

* @param {string} sql - The SQL query to execute.
* @param {number} transactionId - The transaction ID to use, defaults to -1 (no transaction).
* @param {boolean} finishTransaction - Whether to finish the transaction after the query is done. Defaults to false.
* @returns {Object} The result of the query.

@@ -264,5 +299,5 @@ *

*/
this.querySync = function (sql) {
this.querySync = function (sql, transactionId = -1, finishTransaction = false) {
return new Promise((resolve, reject) => {
const strMsg = prepareQuery(sql, null);
const strMsg = prepareQuery(sql, transactionId, finishTransaction, null);

@@ -303,5 +338,5 @@ if (strMsg === null) {

* try {
* const result = await sybase.transaction(async (connection) => {
* const user = await connection.querySync('SELECT * FROM users WHERE id = 1');
* await connection.querySync(`UPDATE users SET name = 'John' WHERE id = 1`);
* const result = await sybase.transaction(async (connection, transactionId) => {
* const user = await connection.querySync('SELECT * FROM users WHERE id = 1', transactionId);
* await connection.querySync(`UPDATE users SET name = 'John' WHERE id = 1`, transactionId);
* return user;

@@ -321,11 +356,12 @@ * });

const transactionId = this.transactionCount++;
try {
await this.querySync("BEGIN TRANSACTION");
await this.querySync("BEGIN TRANSACTION", transactionId);
result = await queriesFunction(this);
await this.querySync("COMMIT TRANSACTION");
await this.querySync("COMMIT TRANSACTION", transactionId, true);
} catch (err) {
error = err;
await this.querySync("ROLLBACK TRANSACTION");
await this.querySync("ROLLBACK TRANSACTION", transactionId, true);
}

@@ -332,0 +368,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc