Announcing Deno bindings

I’ve recently wrote a binding for the Deno runtime. The binding implementation is really simple and straightforward, and thanks to Deno’s built-in TypeScript support, you can just create a .ts file anywhere on your machine, get full IDE autocomplete support, and easily write and run maintainable scripts for interacting with FoundationDB servers.

Here’s how simple it is to use:

import {
  createDatabase,
  selectAPIVersion,
  startNetwork,
  stopNetwork,
} from "https://deno.land/x/fdb/mod.ts";

selectAPIVersion(710);
startNetwork();

const database = createDatabase();
const transaction = database.createTransaction();

const future = transaction.get("some_key");
future.blockUntilReady();
future.getError();

const value = future.getValue();
if (value) {
  console.log(value.byteLength);
} else {
  console.log("Not found");
}

stopNetwork();

The source code is available here. Note that it is currently pretty much WIP and not stable, and I also plan to add higher level APIs to it in the future.

3 Likes

Neat! Btw there is a more complete typescript binding here, and I think the main thing missing for deno support is someone familiar with the way ffi works in deno to wire it up. It looks like you’ve already done much of that! Might be worth getting in touch with those folks.

There’s also Openland’s bindings (Getting Started · @openland/foundationdb), which included an entity layer, a migration tool, and some abstractions on top.

It doesn’t seem to support Deno, does it?