Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

drizzle-ormDrizzle ORM

Agent Skill

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

总安装

225

周安装

9

GitHub Stars

公开资料未说明

下载量

73
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:drizzle-orm(Drizzle ORM)
来源仓库:https://github.com/perdolique/workflow
仓库路径:skills/drizzle-orm
安装命令:
npx skills add https://github.com/perdolique/workflow --skill drizzle-orm
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/perdolique/workflow --skill drizzle-orm

简介

用于辅助数据库表结构、查询语句和迁移脚本分析。drizzle-orm 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

  • 适合编写 SQL、排查查询问题或生成迁移建议。
  • 使用时需明确数据库类型和环境,区分只读分析与写入操作。
  • 涉及删除、更新或批量导入时应优先 dry-run 或事务保护。
  • 归类为研究检索类,符合其数据库辅助工具的定位。

SKILL.md

Drizzle ORM patterns

These patterns assume modern Drizzle projects using relational queries v2 (db.query.*) alongside the SQL builder. If the codebase is still on older relational query APIs, verify the installed Drizzle version before applying the examples below.

For formatting of relational queries and SQL builder chains, especially when a query mixes columns, where, and with or builder helpers like .select() and .where(), read references/formatting.md. Use that layout consistently in generated examples and code review suggestions because deep Drizzle configs get hard to scan when everything is packed onto a few lines.

Driver caveats

Drizzle query advice depends not only on query shape, but also on the database driver in use. Before suggesting transactions or multi-step write fixes, check which client the code is actually using.

Neon HTTP vs WebSocket

If the code uses drizzle-orm/neon-http, do not suggest a normal db.transaction(async (tx) =>...) fix. The Neon HTTP driver does not support Drizzle transaction callbacks, so advice that assumes transactional writes is incorrect for that client.

If the code uses drizzle-orm/neon-serverless with a WebSocket or Pool client, transactions are supported and db.transaction(...) is a valid option.

Review guidance for multi-step writes

When a handler performs multiple writes that must succeed or fail together, first identify the client:

  • If it is an HTTP Neon client, call out the atomicity issue, but do not recommend db.transaction(...) on that same client without verifying a supported transactional path.
  • If it is a WebSocket/serverless client with transaction support, recommending a transaction is appropriate.

This is especially important during code review: avoid suggesting fixes that the current driver cannot execute.

Relational API vs SQL builder

Drizzle has two distinct query APIs. Choosing the wrong one causes TypeScript errors.

Use the relational API (db.query.table.findFirst/findMany) when:

  • Fetching a single record or a simple list
  • Loading nested relations in one query
  • The filter conditions are known at compile time

Use the SQL builder (db.select().from().where()) when:

  • Building WHERE conditions dynamically at runtime
  • Running aggregations (count(), sum(), etc.)
  • The query has joins that depend on runtime input

Relational API

In relational queries v2, where takes an object

// ✅ Correct — object matching column names to values
const item = await db.query.items.findFirst({
  where: {
    id
  }
})

const category = await db.query.categories.findFirst({
  where: {
    slug
  }
})

const approved = await db.query.items.findMany({
  where: {
    status: 'approved'
  }
})

// ❌ Wrong in relational queries v2 — this causes a query-shape type mismatch
const item = await db.query.items.findFirst({
  where: eq(items.id, id)
})

Use eq() and similar helpers in SQL builder queries. In relational queries v2, where is an object that maps column names to expected values.

Select only needed columns

const brand = await db.query.brands.findFirst({
  columns: {
    id: true,
    name: true,
    slug: true
  }, // exclude updatedAt, createdAt, etc.

  where: {
    slug
  }
})

Load nested relations with with

const category = await db.query.categories.findFirst({
  columns: {
    id: true,
    name: true,
    slug: true
  },

  where: {
    slug
  },

  with: {
    properties: {
      columns: {
        id: true,
        name: true,
        dataType: true,
        unit: true
      },

      with: {
        enumOptions: {
          columns: {
            id: true,
            name: true,
            slug: true
          }
        }
      }
    }
  }
})

Filter nested relations inside with

const brand = await db.query.brands.findFirst({
  columns: {
    id: true,
    name: true,
    slug: true
  },

  where: {
    slug
  },

  with: {
    items: {
      columns: {
        id: true,
        name: true
      },

      where: {
        status: 'approved'
      }, // filter applied to the nested relation

      with: {
        category: {
          columns: {
            name: true,
            slug: true
          }
        }
      }
    }
  }
})

SQL builder

Dynamic WHERE conditions

Build conditions into an array, then spread into and():

import { and, eq, ilike } from 'drizzle-orm'

const conditions = [
  eq(items.status, 'approved')
]

if (categoryId) {
  conditions.push(eq(items.categoryId, categoryId))
}

if (search) {
  const escaped = search
    .replaceAll('%', String.raw`\%`)
    .replaceAll('_', String.raw`\_`)

  conditions.push(
    ilike(items.name, `%${escaped}%`)
  )
}

const results = await db
  .select({
    id: items.id,
    name: items.name
  })
  .from(items)
  .where(and(...conditions))
  .limit(limit)
  .offset((page - 1) * limit)

Always escape user input before passing to ilike()% and _ are wildcards in SQL LIKE patterns.

Count query (aggregation)

count() returns exactly one row at runtime, but with noUncheckedIndexedAccess TypeScript still treats indexed access as possibly undefined. Avoid array destructuring here and read the first row safely.

import { count } from 'drizzle-orm'

const countRows = await db
  .select({ total: count() })
  .from(items)
  .where(
    and(...conditions)
  )

const total = countRows[0]?.total ?? 0

Parallel data + count queries

Run independent queries with Promise.all to avoid sequential round-trips.

Note: count() always returns exactly one row but TypeScript (with noUncheckedIndexedAccess) sees array element access as T | undefined. Use [0]?.total?? 0 to stay type-safe.
const [rows, countRows] = await Promise.all([
  db
    .select()
    .from(items)
    .where(
      and(...conditions)
    )
    .limit(limit)
    .offset(offset),

  db
    .select({ total: count() })
    .from(items)
    .where(
      and(...conditions)
    )
])

const total = countRows[0]?.total ?? 0

return {
  items: rows,
  total,
  page,
  limit
}

Joins in the SQL builder

import { eq } from 'drizzle-orm'

const results = await db
  .select({
    brandName: brands.name,
    id: items.id,
    name: items.name
  })
  .from(items)
  .innerJoin(brands, eq(items.brandId, brands.id))
  .where(
    eq(items.status, 'approved')
  )

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.95%
按下载量换算26

Claude

31.02%
按下载量换算23

Cursor

21.33%
按下载量换算16

Gemini CLI

9.73%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills