Code Monkey home page Code Monkey logo

duckdb-async's Introduction

duckdb-async

TypeScript wrappers using Promises for the duckdb Node.JS API

Overview and Basic Usage

This repository provides an API that wraps the DuckDb NodeJS API using Promises instead of callbacks. The library is implemented in TypeScript to provide static type checking for TypeScript developers. It includes the existing duckdb NPM module as a dependency, so it should be possible to write applications in TypeScript using only duckdb-async as a direct dependency.

Basic usage is straightforward. For example:

import { Database } from "duckdb-async";

async function simpleTest() {
  const db = await Database.create(":memory:");
  const rows = await db.all("select * from range(1,10)");
  console.log(rows);
}

simpleTest();

Note that the static method Database.create(...) is used in place of new Database(...) in the DuckDb NodeJS API because the underlying NodeJS API uses a callback in the constructor, and it's not possible to have constructors return promises.

The API should be relatively complete -- there are wrappers for all of the Connection, Database and Statement classes from the underlying NodeJS API, with methods that return promises instead of taking callbacks. A notable exception is the each methods on these classes. The each method invokes a callback multiple times, once for each row of the result set. Since promises can only be resolved once, it doesn't make sense to convert this method to a promise-based API, so the each method still provides the same callback-based interface as the original Node.JS API.

duckdb-async's People

Contributors

antonycourtney avatar y-- avatar dependabot[bot] avatar archiewood avatar elefeint avatar nsmith7979 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.