Skip to main content

drizzle

Drizzle ORM 是一个 TypeScript ORM,提供关系型和类 SQL 查询 API,并且在设计上支持无服务器架构。

¥Drizzle ORM is a TypeScript ORM offering both relational and SQL-like query APIs, and which is serverless-ready by design.

用法(Usage)

¥Usage

npx sv add drizzle

你将获得什么(What you get)

¥What you get

  • 一个将数据库访问保留在 SvelteKit 服务器文件中的设置

    ¥a setup that keeps your database access in SvelteKit’s server files

  • 一个 .env 文件,用于存储你的凭证

    ¥an .env file to store your credentials

  • 与 Lucia 身份验证插件的兼容性

    ¥compatibility with the Lucia auth add-on

  • 可选的 Docker 配置,用于帮助运行本地数据库

    ¥an optional Docker configuration to help with running a local database

选项(Options)

¥Options

database

要使用哪种数据库变体:

¥Which database variant to use:

  • postgresql — 最流行的开源数据库

    ¥postgresql — the most popular open source database

  • mysql — 另一个流行的开源数据库

    ¥mysql — another popular open source database

  • sqlite — 基于文件的数据库,不需要数据库服务器

    ¥sqlite — file-based database not requiring a database server

npx sv add --drizzle=postgresql

client

要使用的 SQL 客户端取决于 database

¥The SQL client to use, depends on database:

  • 对于 postgresqlpostgres.js, neon,

    ¥For postgresql: postgres.js, neon,

  • 对于 mysqlmysql2, planetscale

    ¥For mysql: mysql2, planetscale

  • 对于 sqlitebetter-sqlite3, libsql, turso

    ¥For sqlite: better-sqlite3, libsql, turso

npx sv add --drizzle=postgresql,postgres.js

Drizzle 与十几种数据库驱动程序兼容。为了简单起见,我们仅提供一些最常用的适配器,但如果你想使用其他适配器,你可以选择一个作为占位符,并在设置后通过从 Drizzle 的完整兼容驱动程序列表 中选择将其替换为另一个。

¥Drizzle is compatible with well over a dozen database drivers. We just offer a few of the most common ones here for simplicity, but if you’d like to use another one you can choose one as a placeholder and swap it out for another after setup by choosing from Drizzle’s full list of compatible drivers.

docker

是否添加 Docker Compose 配置。仅适用于 databasepostgresqlmysql

¥Whether to add Docker Compose configuration. Only available for database postgresql or mysql

  • docker - 生成 docker-compose.yml

    ¥docker - generates docker-compose.yml

  • no-docker - 不生成 Docker 配置

    ¥no-docker - does not generate docker config

npx sv add --drizzle=postgresql,postgres.js,docker
上一页 下一页