Skip to content

Commit

Permalink
Fix @auxten comments from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrenonville committed Jan 30, 2025
1 parent 0fa03d7 commit cb6bcca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
22 changes: 7 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@ function query(query, format = "CSV") {
return chdbNode.Query(query, format);
}

// Standalone exported query function
function queryBuffer(query, format = "CSV") {
if (!query) {
return "";
}
return chdbNode.QueryBuffer(query, format);
}

class LocalChDB {
class Connect {
constructor(path = ":memory:") {
let args = []
if (path === ":memory:") {
Expand Down Expand Up @@ -56,6 +48,11 @@ class LocalChDB {
return res;
}

insert_into(query, values, format = "CSV") {
let q = Buffer.concat([Buffer.from(query), values])
return this.query(q, format)
}

cleanup() {
console.log("cleanup: ", this.isTemp, this.in_memory);

Expand Down Expand Up @@ -87,11 +84,6 @@ class Session {
return chdbNode.QuerySession(query, format, this.path);
}

queryBuffer(query, format = "CSV") {
if (!query) return "";
return chdbNode.QuerySessionBuffer(query, format, this.path);
}

// Cleanup method to delete the temporary directory
cleanup() {
if (this.isTemp) {
Expand All @@ -100,4 +92,4 @@ class Session {
}
}

module.exports = { query, queryBuffer, Session, LocalChDB };
module.exports = { query, Session, Connect };
6 changes: 3 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { expect } = require('chai');
const { query, Session, LocalChDB } = require(".");
const { query, Session, Connect } = require(".");

describe('chDB Queries', function () {

Expand Down Expand Up @@ -58,12 +58,12 @@ describe('chDB Queries', function () {
});


describe('LocalChDB Queries in memory', function () {
describe('Connect Queries in memory', function () {
let session;

before(function () {
// Create a new session instance before running the tests
session = new LocalChDB();
session = new Connect();
});

after(function () {
Expand Down

0 comments on commit cb6bcca

Please sign in to comment.