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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@drizzle-adapter/sqlite-core

v1.0.15

Published

Shared SQLite functionality for the Drizzle Adapter ecosystem.

Readme

@drizzle-adapter/sqlite-core

Shared SQLite functionality for the Drizzle Adapter ecosystem.

Overview

The @drizzle-adapter/sqlite-core package provides shared SQLite functionality used by SQLite-compatible adapters in the Drizzle Adapter ecosystem. This package is an internal dependency used by:

Purpose

This package standardizes SQLite-specific functionality across different SQLite-compatible adapters:

  • Common SQLite data type definitions
  • Shared SQLite query building logic
  • Unified SQLite error handling
  • Common SQLite utility functions

Installation

# This package is typically not installed directly but as a dependency of SQLite adapters
pnpm install @drizzle-adapter/sqlite-core

For Adapter Developers

If you're developing a new SQLite-compatible adapter for the Drizzle Adapter ecosystem, you should use this package to ensure consistency with other SQLite adapters:

import { SQLiteDrizzleDataTypes } from '@drizzle-adapter/sqlite-core';

export class YourSQLiteAdapter implements DrizzleAdapterInterface {
  public getDataTypes(): SQLiteDrizzleDataTypes {
    return new SQLiteDrizzleDataTypes();
  }
  
  // ... rest of your adapter implementation
}

Data Types

The package provides standardized SQLite data type definitions:

const dataTypes = new SQLiteDrizzleDataTypes();

const table = dataTypes.dbTable('example', {
  // Numeric types
  id: dataTypes.dbInteger('id').primaryKey().autoincrement(),
  count: dataTypes.dbInteger('count'),
  amount: dataTypes.dbReal('amount'),
  
  // String types
  name: dataTypes.dbText('name'),
  description: dataTypes.dbText('description'),
  
  // Date/Time types (stored as INTEGER or TEXT)
  createdAt: dataTypes.dbInteger('created_at')
    .default(sql`(strftime('%s', 'now'))`),
  updatedAt: dataTypes.dbText('updated_at')
    .default(sql`CURRENT_TIMESTAMP`),
  
  // SQLite-specific handling
  json: dataTypes.dbText('json'), // JSON stored as TEXT
  isActive: dataTypes.dbInteger('is_active'), // Boolean as INTEGER
  blob: dataTypes.dbBlob('data') // Binary data
});

Error Handling

The package provides unified error handling for SQLite-specific errors:

import { handleSQLiteError } from '@drizzle-adapter/sqlite-core';

try {
  // Your database operation
} catch (error) {
  throw handleSQLiteError(error);
}

Query Building

The package includes utilities for building SQLite-specific queries:

import { 
  buildInsertQuery,
  buildUpdateQuery,
  buildDeleteQuery,
  buildSelectQuery,
  buildFTSQuery
} from '@drizzle-adapter/sqlite-core';

// Build INSERT query
const insertQuery = buildInsertQuery(table, data);

// Build UPDATE query with JSON operations
const updateQuery = buildUpdateQuery(table, {
  json: sql`json_set(json, '$.key', 'value')`
});

// Build DELETE query with conditions
const deleteQuery = buildDeleteQuery(table, conditions);

// Build SELECT query with joins
const selectQuery = buildSelectQuery({
  table,
  joins: [...],
  conditions: [...],
  orderBy: [...]
});

// Build full-text search query
const searchQuery = buildFTSQuery({
  table: 'posts_fts',
  searchTerm: 'search term',
  columns: ['title', 'content']
});

Type Mapping

The package handles SQLite-specific type mapping:

import { mapSQLiteType } from '@drizzle-adapter/sqlite-core';

// Map JavaScript types to SQLite types
const sqliteType = mapSQLiteType(value);

// Map SQLite types to JavaScript types
const jsValue = mapToJavaScript(sqliteValue, sqliteType);

// Handle JSON serialization
const jsonText = serializeJSON(value);
const jsonValue = deserializeJSON(text);

// Handle date/time
const timestamp = dateToUnixTimestamp(date);
const date = unixTimestampToDate(timestamp);

SQLite-Specific Features

import { 
  createFTSTable,
  createFTSIndex,
  handleJSONOperations,
  handleDateTimeOperations
} from '@drizzle-adapter/sqlite-core';

// Create FTS table
const ftsSQL = createFTSTable('posts_fts', ['title', 'content']);

// Create FTS index
const indexSQL = createFTSIndex('posts_fts_idx', 'posts', ['title', 'content']);

// Handle JSON operations
const jsonCondition = handleJSONOperations(column, path, value);

// Handle date/time operations
const dateCondition = handleDateTimeOperations(column, operator, value);

Date/Time Utilities

import { 
  getCurrentTimestamp,
  formatDateTime,
  parseDateTime,
  addInterval
} from '@drizzle-adapter/sqlite-core';

// Get current timestamp
const now = getCurrentTimestamp();

// Format date/time
const formatted = formatDateTime(date, format);

// Parse date/time
const date = parseDateTime(text, format);

// Add interval
const future = addInterval(date, { days: 7, hours: 12 });

Contributing

This package is maintained as part of the Drizzle Adapter ecosystem. If you'd like to contribute:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Related Packages