@machbase/ts-client
v1.1.0
Published
Pure TypeScript Machbase client with Machbase 8.7 ARRAY, sparse APPEND and prepared statement support
Downloads
35
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/[email protected]Requirements:
- 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
Machbase 8.7 release (1.1.0)
- ARRAY bind/fetch and sparse input through
SparseArray. - Projected ARRAY APPEND targets with 0-based public positions.
- Named parameter binding, nullable/primary-key metadata and database selection.
- Generated row IDs are exposed as
OkPacket.rowId(bigint);insertIdremains the compatibility placeholder0. - Named parameters require protocol 4.0.3 or newer; ARRAY operations require protocol 4.0.4 or newer.
- The SDK version is independent of the DBMS version. See CHANGELOG.md.
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.
- The facade methods
beginTransaction(),commit(), androllback()reject calls withERR_MACHBASE_NO_TX. This is a limitation of those SDK methods; Machbase also provides transaction tables. - LOG tables do not support
UPDATE. Standard edition TAG tables support limited TAG DATA and TAG METADATA updates; consult the SQL reference for supported forms. - Default credentials shown in examples are for local testing only.
Examples and Documentation
- CommonJS examples:
src/example-js - Product manual: https://docs.machbase.com/dbms/sdk-integration/
- Repository manual:
doc/machbase-npm-client.md(available in the source repository) - Repository: https://github.com/machbase/dbms-nfx/tree/main/ux/src/npm/machbase-client
- Issues: https://github.com/machbase/dbms-nfx/issues
