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

@squirrel-scheduler/drizzle-adapter

v1.0.7

Published

Drizzle ORM adapter for SquirrelScheduler

Readme

@squirrel-scheduler/drizzle-adapter

Official Drizzle ORM adapter for SquirrelScheduler. This package provides a ready-to-use database adapter for SQLite databases using Drizzle ORM.

Features

  • SQLite Support: Works with any SQLite-compatible database (Turso, libSQL, better-sqlite3)
  • Type Safety: Fully typed with TypeScript
  • Schema Management: Includes Drizzle schema definitions for task tables
  • Migrations: Ready-to-use migration files for setting up your database

Installation

npm install @squirrel-scheduler/drizzle-adapter

Or with pnpm:

pnpm add @squirrel-scheduler/drizzle-adapter

Usage

1. Set Up Database Schema

First, import and use the provided schema in your Drizzle configuration:

import { defineTables } from "@squirrel-scheduler/drizzle-adapter/lib/sqlite";

export const {
    tasksTable,
    syncHistoryTable,
    taskResultsTable
} = defineTables();

2. Run Migrations

The adapter provides migration files to set up the required tables:

drizzle-kit generate && drizzle-kit migrate

3. Create and Use the Adapter

import { SScheduler } from "@squirrel-scheduler/core";
import { SQLiteDrizzleAdapter } from "@squirrel-scheduler/drizzle-adapter";
import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";

// Initialize your database client
const client = createClient({
  url: process.env.DATABASE_URL,
  authToken: process.env.DATABASE_AUTH_TOKEN
});
const db = drizzle(client);

// Create the adapter
const dbAdapter = SQLiteDrizzleAdapter(db);

// Use it with SquirrelScheduler
const scheduler = new SScheduler(dbAdapter);

// Now you can use the scheduler as normal
scheduler
  .add({
    payload: { type: "sendEmail", to: "[email protected]" },
    scheduledAt: new Date(Date.now() + 10_000),
  })
  .add({
    payload: { type: "generateReport", reportId: "abc123" },
    scheduledAt: new Date(Date.now() + 30_000),
  });

await scheduler.schedule();

Schema Details

The adapter creates the following tables:

  • squirrel_tasks: Stores the scheduled tasks
  • squirrel_sync: Tracks synchronization metadata
// Task table structure
interface Task {
  id: string;
  status: "pending" | "in_progress" | "completed" | "failed";
  payload: JSONObject;
  scheduledAt: Date;
  retryCount: number;
  maxRetries: number;
  nextAttemptAt?: Date;
  createdAt: Date;
  updatedAt: Date;
}

Examples

With Turso (SQLite)

import { createClient } from "@libsql/client";
import { drizzle } from "drizzle-orm/libsql";
import { SQLiteDrizzleAdapter } from "@squirrel-scheduler/drizzle-adapter";

const client = createClient({
  url: process.env.TURSO_DB_URL,
  authToken: process.env.TURSO_DB_TOKEN
});

const db = drizzle(client);
const adapter = SQLiteDrizzleAdapter(db);

With better-sqlite3

import Database from "better-sqlite3";
import { drizzle } from "drizzle-orm/better-sqlite3";
import { SQLiteDrizzleAdapter } from "@squirrel-scheduler/drizzle-adapter";

const sqlite = new Database("path/to/database.db");
const db = drizzle(sqlite);
const adapter = SQLiteDrizzleAdapter(db);

Configuration

The adapter accepts optional configuration:

const adapter = SQLiteDrizzleAdapter(db, {
  tableName: "custom_tasks_table", // Default: "squirrel_tasks"
  syncTableName: "custom_sync_table", // Default: "squirrel_sync"
  schema: customSchema // Optional: provide custom schema
});

Migrations

To customize the migration process:

import { migrate } from "@squirrel-scheduler/drizzle-adapter/migrations";

await migrate(db, {
  customTables: true, // If you're using custom table names
  force: false, // Set to true to force migration regardless of current state
});

Contributing

We welcome contributions! Please feel free to submit a Pull Request.

License

MIT

Happy scheduling! If you encounter any issues or have questions, please open an issue on GitHub.