Skip to content

Commit

Permalink
Merge pull request #1918 from kuzudb/node-threads-fix
Browse files Browse the repository at this point in the history
Fix number of threads for Node.js API
  • Loading branch information
mewim committed Aug 11, 2023
2 parents fc32db0 + 218bc97 commit 4a518f7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/nodejs_api/src_js/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ class Connection {
* function on the returned object.
*
* @param {kuzu.Database} database the database object to connect to.
* @param {Number} numThreads the maximum number of threads to use for query execution.
*/
constructor(database) {
constructor(database, numThreads = null) {
if (
typeof database !== "object" ||
database.constructor.name !== "Database"
Expand All @@ -29,6 +30,10 @@ class Connection {
this._connection = null;
this._isInitialized = false;
this._initPromise = null;
numThreads = parseInt(numThreads);
if (numThreads && numThreads > 0) {
this._numThreads = numThreads;
}
}

/**
Expand All @@ -50,7 +55,6 @@ class Connection {
this._isInitialized = true;
if (this._numThreads) {
this._connection.setMaxNumThreadForExec(this._numThreads);
delete this._numThreads;
}
resolve();
}
Expand Down

0 comments on commit 4a518f7

Please sign in to comment.