npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pondoknusa/database-d1

v7.0.0

Published

Cloudflare D1 database driver for Pondoknusa

Readme

@pondoknusa/database-d1

Cloudflare D1 driver for Pondoknusa — serverless SQLite over a Workers binding or the REST API.

A Pondoknusa app runs on SQLite (node:sqlite) by default, so a fresh project pulls in no database SDK at all. This package adds Cloudflare D1 on top: it registers a d1 driver with @pondoknusa/database's DatabaseManager, reachable through a Workers binding or Cloudflare's REST API. D1 speaks the SQLite dialect (SqliteGrammar) and needs no third-party SDK.

@pondoknusa/database is a peer dependency — the driver calls DatabaseManager.extend(), which mutates a module-static registry, so the app must supply exactly one shared copy of the host package.

Part of the Pondoknusa framework — a TypeScript-native full-stack framework built on standard Web APIs. Requires Node.js ≥ 26.

Install

npm install @pondoknusa/database-d1 @pondoknusa/database

No third-party database SDK is required — the driver reaches D1 over the Workers binding or the Cloudflare REST API.

Quick start

Register the service provider before the database provider boots in src/main.ts:

import { Application, DatabaseServiceProvider } from '@pondoknusa/core';
import { D1DatabaseServiceProvider } from '@pondoknusa/database-d1';

const app = new Application(import.meta.dirname);
app.register(D1DatabaseServiceProvider);
app.register(DatabaseServiceProvider);
await app.boot();

Configuration

// config/database.ts
import type { D1ConnectionConfig } from '@pondoknusa/database-d1';
import { env } from '@pondoknusa/config';

export default {
  default: env('DB_CONNECTION', 'd1'),
  connections: {
    d1: {
      driver: 'd1',
      accountId: env('CLOUDFLARE_ACCOUNT_ID'),
      databaseId: env('D1_DATABASE_ID'),
      apiToken: env('CLOUDFLARE_API_TOKEN'),
    } satisfies D1ConnectionConfig,
  },
} as const;

Inside a Worker, point the driver at the D1 binding instead:

d1: {
  driver: 'd1',
  binding: env.DB, // the Workers D1 binding
} satisfies D1ConnectionConfig,

Read-after-write consistency

The driver classifies every statement — SELECT and PRAGMA as reads, everything else as writes — issuing reads with statement.all() and writes with statement.run(), and waits for each write's meta.changes / meta.last_row_id before resolving, so a completed write is visible to the queries that follow. Interactive BEGIN/COMMIT is not available on every D1 backend, so prefer short, single-statement writes when unsure.

Queries go through the same ORM and query builder as every other connection:

import { DB } from '@pondoknusa/core';
import { User } from './models/user.js';

const rows = await DB.connection('d1').query('SELECT * FROM users WHERE active = ?', [1]);
const user = await User.query().where('email', '[email protected]').first();

Related packages

Documentation

MIT © Pondoknusa Contributors