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

@seedts/adapters

v0.1.1

Published

Adapter implementations for SeedTS

Readme

@seedts/adapters

Base adapter classes for SeedTS. Contains only framework-agnostic base classes with zero external database dependencies.

Installation

npm install @seedts/adapters
# or
pnpm add @seedts/adapters
# or
yarn add @seedts/adapters

What's Included

This package provides:

  • BaseAdapter - Abstract base class for creating custom adapters
  • MemoryAdapter - In-memory adapter for testing and development

Database-Specific Adapters

Database-specific adapters are separate packages. Install only what you need:

This separation ensures:

  • Zero dependencies - Core package has no database drivers
  • Opt-in - Install only adapters you need
  • Smaller bundles - No unused database libraries
  • Independent versioning - Adapters can version independently

Available Adapters

MemoryAdapter

An in-memory adapter for testing and development. No external dependencies required.

import { MemoryAdapter } from '@seedts/adapters';

const adapter = new MemoryAdapter();

Features:

  • Fast in-memory storage
  • Perfect for testing
  • Transaction support with snapshot/restore
  • No external dependencies
  • Zero configuration

BaseAdapter

Abstract base class for creating custom adapters.

import { BaseAdapter } from '@seedts/adapters';

export class MyCustomAdapter extends BaseAdapter {
  name = 'my-custom-adapter';

  async insert(tableName: string, data: any[]): Promise<any[]> {
    // Your implementation
  }

  async update(tableName: string, data: any[]): Promise<any[]> {
    // Your implementation
  }

  async delete(tableName: string, ids: any[]): Promise<void> {
    // Your implementation
  }

  async query(tableName: string, conditions?: any): Promise<any[]> {
    // Your implementation
  }
}

Creating Custom Adapters

To create a custom adapter, extend the BaseAdapter class and implement the required methods:

import { BaseAdapter } from '@seedts/adapters';
import type { SeedAdapter } from '@seedts/types';

export class PostgresAdapter extends BaseAdapter implements SeedAdapter {
  name = 'postgres';

  constructor(private config: PostgresConfig) {
    super();
  }

  async insert(tableName: string, data: any[]): Promise<any[]> {
    // Insert data into PostgreSQL
    return data;
  }

  async update(tableName: string, data: any[]): Promise<any[]> {
    // Update data in PostgreSQL
    return data;
  }

  async delete(tableName: string, ids: any[]): Promise<void> {
    // Delete data from PostgreSQL
  }

  async query(tableName: string, conditions?: any): Promise<any[]> {
    // Query data from PostgreSQL
    return [];
  }

  async beginTransaction(): Promise<void> {
    await super.beginTransaction();
    // Start PostgreSQL transaction
  }

  async commit(): Promise<void> {
    await super.commit();
    // Commit PostgreSQL transaction
  }

  async rollback(): Promise<void> {
    await super.rollback();
    // Rollback PostgreSQL transaction
  }

  async disconnect(): Promise<void> {
    // Close database connection
  }
}

API Reference

SeedAdapter Interface

All adapters implement the SeedAdapter interface from @seedts/types:

type SeedAdapter<T = any> = {
  name: string;
  insert(tableName: string, data: T[]): Promise<T[]>;
  update(tableName: string, data: T[]): Promise<T[]>;
  delete(tableName: string, ids: any[]): Promise<void>;
  query(tableName: string, conditions?: any): Promise<T[]>;
  beginTransaction(): Promise<void>;
  commit(): Promise<void>;
  rollback(): Promise<void>;
  supportsTransactions(): boolean;
  truncate?(tableName: string): Promise<void>;
  disconnect?(): Promise<void>;
};

BaseAdapter Methods

The BaseAdapter class provides default implementations for transaction management:

  • beginTransaction(): Begin a transaction
  • commit(): Commit the current transaction
  • rollback(): Rollback the current transaction
  • supportsTransactions(): Returns true by default
  • truncate(tableName): Truncate a table (must be implemented by subclass)
  • disconnect(): Close database connection (optional)

Examples

Using MemoryAdapter

import { MemoryAdapter } from '@seedts/adapters';

const adapter = new MemoryAdapter();

// Insert data
const users = await adapter.insert('users', [
  { name: 'Alice', email: '[email protected]' },
  { name: 'Bob', email: '[email protected]' },
]);

// Query data
const allUsers = await adapter.query('users');
const alice = await adapter.query('users', { name: 'Alice' });

// Update data
await adapter.update('users', [
  { id: 1, name: 'Alice Updated', email: '[email protected]' },
]);

// Delete data
await adapter.delete('users', [2]);

// Transactions
await adapter.beginTransaction();
try {
  await adapter.insert('users', [{ name: 'Charlie' }]);
  await adapter.commit();
} catch (error) {
  await adapter.rollback();
}

Using SqliteAdapter

import { SqliteAdapter } from '@seedts/adapters';

const adapter = new SqliteAdapter({
  filename: './data/myapp.db',
});

// Create table
adapter.exec(`
  CREATE TABLE IF NOT EXISTS users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    email TEXT NOT NULL UNIQUE,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP
  )
`);

// Insert data
const users = await adapter.insert('users', [
  { name: 'Alice', email: '[email protected]' },
  { name: 'Bob', email: '[email protected]' },
]);

console.log(users[0].id); // Auto-generated ID

// Transactions
await adapter.beginTransaction();
try {
  await adapter.insert('users', [{ name: 'Charlie', email: '[email protected]' }]);
  await adapter.commit();
} catch (error) {
  await adapter.rollback();
  throw error;
}

// Clean up
await adapter.disconnect();

Testing

All adapters include comprehensive test suites:

pnpm test

License

MIT