Node.js Firebird API

I started a personal (*) project to create a Node.js Firebird driver based on the FB 3 OO API.

(*) A personal project because Firebird admins is not interested in this technology. So bad!

Why another driver if there are others? Althrough it’s a manual work for now as I understand the technology, the idea is to generate the driver based in the cloop interface file and always have a up-to-date driver. As a personal project, it will probably take some time having to conciliate two jobs.

The API will be based in promises instead of callback. A nice thing I already see is the capability to use the asynchronous functions as synchronous ones using TypeScript (and future JavaScript) async/await functions.

Here is a test demonstrating multi-threaded use of two databases. It’s so simple to write multi-threaded code that I think it would be much better to write tools (a multi-threaded gbak?) than currently is with C++.

it("test()", async function() {
    async function f(filename: string): Promise<void>
    {
        let status = master.getStatus();
        try
        {
            const stmt1 = "create table t1 (n1 integer)";
            const stmt2 = "insert into t1 values (1)";

            let attachment = await dispatcher.createDatabase(status, filename);
            try
            {
                let transaction = await attachment.startTransaction(status);
                try
                {
                    await attachment.execute(status, transaction, 0, stmt1, 3);
                    await transaction.commitRetaining(status);

                    for (let i = 0; i < 10000; ++i)
                        await attachment.execute(status, transaction, 0, stmt2, 3);
                }
                finally
                {
                    await transaction.commit(status);
                }
            }
            finally
            {
                await attachment.detach(status);
            }
        }
        finally
        {
            status.dispose();
        }
    }

    //await f("/tmp/f1.fdb");
    //await f("/tmp/f2.fdb");
    return Promise.all([f("/tmp/f1.fdb"), f("/tmp/f2.fdb")]);
});

It also would be much simpler to write tests than it’s with currently used tools (C++ and Python). The Firebird Python test suite is a monster with lots of manual dependencies that I never managed to install.