@machbase/ts-client
v1.0.1
Published
Pure TypeScript Machbase client implementing the CMI protocol version 4.0
Downloads
267
Maintainers
Readme
@machbase/ts-client
Pure TypeScript Machbase client for Node.js.
@machbase/ts-client implements the Machbase CMI protocol without native
bindings. It supports direct SQL execution, prepared statements, result-set
fetching, LOG append batches, and stream append workflows from Node.js 18+.
Install
npm install @machbase/ts-clientRequirements:
- Node.js 18 or newer
- A reachable Machbase standard edition server
Quick Start
const { createConnection } = require('@machbase/ts-client');
async function main() {
const conn = createConnection({
host: '127.0.0.1',
port: 5656,
user: 'SYS',
password: 'MANAGER',
});
await conn.connect();
const [rows] = await conn.query(
'SELECT NAME FROM V$TABLES ORDER BY NAME LIMIT ?',
[5],
);
console.table(rows);
await conn.end();
}
main().catch((err) => {
console.error(err);
process.exit(1);
});Features
- Promise and callback-style connection facade
query()andexecute()with placeholder binding- Prepared statement reuse with
prepare() appendBatch()for LOG tablesappendOpen()streaming append workflow- TypeScript declarations shipped in the package
Append Example
const { createConnection } = require('@machbase/ts-client');
async function run() {
const conn = createConnection({
host: '127.0.0.1',
port: 5656,
user: 'SYS',
password: 'MANAGER',
});
await conn.connect();
await conn.execute(
'CREATE LOG TABLE SAMPLE_LOG (ID INTEGER, NAME VARCHAR(20), VALUE DOUBLE)',
);
await conn.appendBatch(
'SAMPLE_LOG',
[
{ name: 'ID', type: 'int32' },
{ name: 'NAME', type: 'varchar' },
{ name: 'VALUE', type: 'float64' },
],
[
[1, 'alpha', 0.5],
[2, 'beta', 1.5],
],
);
const [rows] = await conn.query('SELECT * FROM SAMPLE_LOG ORDER BY ID');
console.table(rows);
await conn.end();
}Notes
- This package targets Node.js. It is not a browser client.
- Machbase SQL transactions are not supported.
BEGIN,COMMIT, andROLLBACKreturn errors. - LOG and TAG tables support
SELECT,INSERT, andDELETE, but notUPDATE. - Default credentials shown in examples are for local testing only.
Examples and Documentation
- CommonJS examples:
src/example-js - Product manual:
doc/machbase-npm-client.md - Repository: https://github.com/machbase/dbms-nfx/tree/main/ux/src/npm/machbase-client
- Issues: https://github.com/machbase/dbms-nfx/issues
