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/mysql-core

v1.0.14

Published

Shared MySQL functionality for the Drizzle Adapter ecosystem.

Readme

@drizzle-adapter/mysql-core

Shared MySQL functionality for the Drizzle Adapter ecosystem.

Overview

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

Purpose

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

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

Installation

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

For Adapter Developers

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

import { MySQLDrizzleDataTypes } from '@drizzle-adapter/mysql-core';

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

Data Types

The package provides standardized MySQL data type definitions:

const dataTypes = new MySQLDrizzleDataTypes();

const table = dataTypes.dbTable('example', {
  // Numeric types
  id: dataTypes.dbBigInt('id', { mode: 'number' }).primaryKey().autoincrement(),
  count: dataTypes.dbInt('count'),
  price: dataTypes.dbDecimal('price', { precision: 10, scale: 2 }),
  
  // String types
  name: dataTypes.dbVarChar('name', { length: 255 }),
  description: dataTypes.dbText('description'),
  
  // Date/Time types
  createdAt: dataTypes.dbTimestamp('created_at').defaultNow(),
  updatedAt: dataTypes.dbTimestamp('updated_at').onUpdateNow(),
  
  // Other types
  status: dataTypes.dbEnum('status', ['active', 'inactive']),
  metadata: dataTypes.dbJson('metadata'),
  isEnabled: dataTypes.dbBoolean('is_enabled')
});

Error Handling

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

import { handleMySQLError } from '@drizzle-adapter/mysql-core';

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

Query Building

The package includes utilities for building MySQL-specific queries:

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

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

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

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

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

Type Mapping

The package handles MySQL-specific type mapping:

import { mapMySQLType } from '@drizzle-adapter/mysql-core';

// Map JavaScript types to MySQL types
const mysqlType = mapMySQLType(value);

// Map MySQL types to JavaScript types
const jsValue = mapToJavaScript(mysqlValue, mysqlType);

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