-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
const addon = require('.'); | ||
var result = addon.Execute('SELECT version()', 'TabSeparated'); | ||
const db = new addon.db('CSV') | ||
var result; | ||
|
||
// Test query | ||
result = db.query("SELECT version()"); | ||
console.log(result) | ||
|
||
// Test session | ||
db.session("CREATE FUNCTION IF NOT EXISTS hello AS () -> 'chDB'"); | ||
result = db.session("SELECT hello()", "TabSeparated"); | ||
console.log(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
//const chdb = require('./build/chdb.node'); | ||
const chdb = require('node-gyp-build')(__dirname) | ||
module.exports = chdb; | ||
|
||
function db(format, path) { | ||
|
||
this.format = format || 'JSONCompact'; | ||
this.path = path || '.'; | ||
|
||
// add properties to this | ||
this.query = function(query, format){ | ||
return chdb.Execute(query, format || this.format); | ||
}.bind(this); | ||
this.session = function(query, format, path) { | ||
return chdb.Session(query, format || this.format, path || this.path); | ||
}.bind(this); | ||
|
||
return this; (implicitly) | ||
} | ||
|
||
module.exports = { chdb, db }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters