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

@cepseudo/database

v1.0.1

Published

Database abstraction layer for Digital Twin framework (Kysely/Knex, PostgreSQL/SQLite)

Readme

@cepseudo/database

npm version TypeScript License: MIT

Database abstraction layer for the Digital Twin Framework. Provides a unified DatabaseAdapter interface with two concrete implementations (Knex and Kysely) supporting PostgreSQL and SQLite.

Installation

pnpm add @cepseudo/database

You must also install one query builder and its database driver:

# Option A: Kysely (recommended for new projects)
pnpm add kysely better-sqlite3        # SQLite
pnpm add kysely pg                    # PostgreSQL

# Option B: Knex (legacy, stable)
pnpm add knex better-sqlite3          # SQLite
pnpm add knex pg                      # PostgreSQL

Adapters

| | KyselyDatabaseAdapter | KnexDatabaseAdapter | |---|---|---| | Query builder | Kysely >= 0.27.0 | Knex >= 3.0.0 | | PostgreSQL | Yes (pg) | Yes (pg) | | SQLite | Yes (better-sqlite3) | Yes (better-sqlite3 or sqlite3) | | Factory methods | async (returns Promise) | Synchronous | | Status | Recommended | Legacy, stable |

Both adapters implement the same abstract DatabaseAdapter class. Switching between them requires no changes to component code.

Usage

Kysely with PostgreSQL

import { KyselyDatabaseAdapter } from '@cepseudo/database'

const database = await KyselyDatabaseAdapter.forPostgreSQL(
    {
        host: 'localhost',
        port: 5432,
        user: 'admin',
        password: 'secret',
        database: 'digitaltwin',
        maxConnections: 15,
    },
    dataResolver
)

Knex with SQLite (development)

import { KnexDatabaseAdapter } from '@cepseudo/database'

const database = KnexDatabaseAdapter.forSQLite(
    {
        filename: './data/digitaltwin.db',
        client: 'better-sqlite3',
        enableForeignKeys: true,
    },
    dataResolver
)

Using the abstract interface in components

Components depend on DatabaseAdapter, not on a specific implementation. The engine injects the concrete adapter at runtime.

import type { DatabaseAdapter } from '@cepseudo/database'

class WeatherCollector {
    #database: DatabaseAdapter

    setDependencies(database: DatabaseAdapter) {
        this.#database = database
    }

    async collect() {
        // Save collected data
        const record = await this.#database.save({
            name: 'weather-collector',
            type: 'application/json',
            url: 'storage://weather-collector/2026-03-06.json',
            date: new Date(),
        })

        // Query latest record
        const latest = await this.#database.getLatestByName('weather-collector')
    }
}

Peer Dependencies

This package requires at least one of the following query builders. Both are marked as optional peer dependencies -- install only the one you use.

| Peer dependency | Version | Required when | |---|---|---| | knex | >= 3.0.0 | Using KnexDatabaseAdapter | | kysely | >= 0.27.0 | Using KyselyDatabaseAdapter |

Each adapter also requires a database driver (pg for PostgreSQL, better-sqlite3 or sqlite3 for SQLite).

License

MIT