Node.js Firebird Drivers

Posted on in firebird, nodejs, javascript, typescript

I'm pleased to announce the initial release of my Firebird drivers projects for Node.js.

  • You said projects?
  • Yes!

The work is split in three projects, as described below.


Firebird high-level native client for Node.js / TypeScript (github / npm)

This is the more interesting project for now. It allows to use Firebird (via Firebird v3+ client library) with a good high-level API.

Example usage:

import { createNativeClient, getDefaultLibraryFilename } from 'node-firebird-driver-native';

async function test() {
    const client = createNativeClient(getDefaultLibraryFilename());

    // Without 'server:', it will use Firebird embedded.
    const attachment = await client.createDatabase('server:/tmp/new-db.fdb', {
        username: 'sysdba',
        password: 'masterkey'
    const transaction = await attachment.startTransaction();

    await attachment.execute(transaction,
        'create table t1 (n integer, d date)');
    await transaction.commitRetaining();

    const statement1 = await attachment.prepare(transaction,
        'insert into t1 values (?, ?)');
    await statement1.execute(transaction, [1, new Date()]);
    await statement1.execute(transaction, [2, new Date()]);
    await statement1.execute(transaction, [3, new Date()]);
    await statement1.dispose();

    const resultSet = await attachment.executeQuery(transaction,
        'select n, d from t1 where n <= ?', [2]);
    const rows = await resultSet.fetch();

    for (const columns of rows)
        console.log('n: ' + columns[0] + ', d: ' + columns[1]);

    await resultSet.close();

    await transaction.commit();
    await attachment.dropDatabase();

    await client.dispose();

test().then(() => console.log('Finish...'));

More examples can be found here.


Firebird client interfaces for Node.js / TypeScript (github / npm)

This project currently has only TypeScript interfaces for a Firebird client. In the future it may have common code for any Firebird client, like connection pools and utility functions.

node-firebird-driver-native implements the interfaces from this project. In the future, we may have another socket-based project also implementing these interfaces, so all drivers will be type-compatible.


Firebird low-level API for Node.js / TypeScript (github / npm)

This project converts Firebird cloop interfaces to TypeScript and NAN bindings to access the native fbclient code. It's a dependency project for node-firebird-driver-native.

It's currently not complete and you should use it directly only if you know what are you doing.


All the projects are currently in ALPHA version, so changes are expected without caring about semver breaks.