### Install Drizzle and libSQL Client (bun) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/connect-turso Install the necessary Drizzle ORM and libSQL client packages using bun. Also installs drizzle-kit for development. ```bash bun add drizzle-orm @libsql/client bun add -D drizzle-kit ``` -------------------------------- ### Install postgres driver Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-supabase Install the postgres driver for connecting to the database. ```bash npm i postgres ``` ```bash yarn add postgres ``` ```bash pnpm add postgres ``` ```bash bun add postgres ``` -------------------------------- ### Connect to PostgreSQL and Select Users Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/latest-releases/drizzle-orm-v0110 Quick start example to connect to a PostgreSQL database and fetch all users with a typed result. Requires the 'drizzle-orm' package and a valid PostgreSQL connection string. ```typescript import { drizzle, PgTable } from 'drizzle-orm' export class UsersTable extends PgTable { public id = this.serial('id').primaryKey(); public fullName = this.text('full_name'); public phone = this.varchar('phone', { size: 256 }); public tableName(): string { return 'users'; } } export type User = InferType const db = await drizzle.connect("postgres://user:password@host:port/db"); const usersTable = new UsersTable(db); const users: User[] = await usersTable.select().execute(); ``` -------------------------------- ### Install LibSQL Client Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-vercel-edge-functions Installation commands for the LibSQL driver across different package managers. ```bash npm i @libsql/client ``` ```bash yarn add @libsql/client ``` ```bash pnpm add @libsql/client ``` ```bash bun add @libsql/client ``` -------------------------------- ### Install Drizzle and libSQL Client (npm) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/connect-turso Install the necessary Drizzle ORM and libSQL client packages using npm. Also installs drizzle-kit for development. ```bash npm i drizzle-orm @libsql/client npm i -D drizzle-kit ``` -------------------------------- ### Install @libsql/client package (bun) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-turso Install the @libsql/client package using bun, which is required for connecting to Turso. ```bash bun add @libsql/client ``` -------------------------------- ### Install Drizzle and libSQL Client (yarn) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/connect-turso Install the necessary Drizzle ORM and libSQL client packages using yarn. Also installs drizzle-kit for development. ```bash yarn add drizzle-orm @libsql/client yarn add -D drizzle-kit ``` -------------------------------- ### Install Neon Serverless Driver Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-nextjs-neon Install the Neon database driver for serverless environments. ```bash npm i @neondatabase/serverless ``` ```bash yarn add @neondatabase/serverless ``` ```bash pnpm add @neondatabase/serverless ``` ```bash bun add @neondatabase/serverless ``` -------------------------------- ### Install Drizzle and libSQL Client (pnpm) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/connect-turso Install the necessary Drizzle ORM and libSQL client packages using pnpm. Also installs drizzle-kit for development. ```bash pnpm add drizzle-orm @libsql/client pnpm add -D drizzle-kit ``` -------------------------------- ### Install @libsql/client package (npm) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-turso Install the @libsql/client package using npm, which is required for connecting to Turso. ```bash npm i @libsql/client ``` -------------------------------- ### Install @libsql/client package (pnpm) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-turso Install the @libsql/client package using pnpm, which is required for connecting to Turso. ```bash pnpm add @libsql/client ``` -------------------------------- ### Install express package with bun Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-nile Install the express package with bun for building the web framework. ```bash bun add express ``` -------------------------------- ### Install @libsql/client package (yarn) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-turso Install the @libsql/client package using yarn, which is required for connecting to Turso. ```bash yarn add @libsql/client ``` -------------------------------- ### Neon connection string example Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-netlify-edge-functions-neon Example format for a Neon Postgres connection string. ```text postgres://username:password@ep-cool-darkness-123456.us-east-2.aws.neon.tech/neondb?sslmode=require ``` -------------------------------- ### Install Vercel Postgres Driver (bun) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-vercel-edge-functions Install the @vercel/postgres driver using bun. ```bash bun add @vercel/postgres ``` -------------------------------- ### Install Dependencies Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started/singlestore-new Commands to install Drizzle ORM, mysql2, and development tools. ```bash npm i drizzle-orm mysql2 dotenv npm i -D drizzle-kit tsx ``` ```bash yarn add drizzle-orm mysql2 dotenv yarn add -D drizzle-kit tsx ``` ```bash pnpm add drizzle-orm mysql2 dotenv pnpm add -D drizzle-kit tsx ``` ```bash bun add drizzle-orm mysql2 dotenv bun add -D drizzle-kit tsx ``` -------------------------------- ### Install Drizzle ORM and PGlite with bun Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/connect-pglite Install the necessary Drizzle ORM and PGlite packages using bun. Also installs drizzle-kit for development. ```bash bun add drizzle-orm @electric-sql/pglite bun add -D drizzle-kit ``` -------------------------------- ### Install Gel CLI Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started/gel-new Installs the Gel command-line interface. Ensure you are on Linux or macOS. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh ``` -------------------------------- ### Install Dependencies Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started/xata-new Commands to install Drizzle ORM, Xata client, and development tools. ```bash npm i drizzle-orm @xata.io/client dotenv npm i -D drizzle-kit tsx ``` ```bash yarn add drizzle-orm @xata.io/client dotenv yarn add -D drizzle-kit tsx ``` ```bash pnpm add drizzle-orm @xata.io/client dotenv pnpm add -D drizzle-kit tsx ``` ```bash bun add drizzle-orm @xata.io/client dotenv bun add -D drizzle-kit tsx ``` -------------------------------- ### Install Drizzle ORM and Neon Serverless Driver with bun Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/connect-neon Install the necessary Drizzle ORM and Neon serverless driver packages using bun. Also installs drizzle-kit for development. ```bash bun add drizzle-orm @neondatabase/serverless bun add -D drizzle-kit ``` -------------------------------- ### Install @vercel/postgres Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-vercel Install the official Vercel Postgres driver package. ```bash npm i @vercel/postgres ``` ```bash yarn add @vercel/postgres ``` ```bash pnpm add @vercel/postgres ``` ```bash bun add @vercel/postgres ``` -------------------------------- ### MySQL String Seeding Examples Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/seed-versioning Examples of defining string columns and seeding them in MySQL. ```typescript import { binary, char, mysqlTable, varbinary, varchar } from 'drizzle-orm/mysql-core'; import { drizzle } from 'drizzle-orm/mysql2'; import { seed } from "drizzle-seed"; const strings = mysqlTable('strings', { string1: char({ length: 255 }).unique(), string2: char({ length: 255 }), string3: varchar({ length: 255 }).unique(), string4: varchar({ length: 255 }), string5: binary({ length: 255 }).unique(), string6: binary({ length: 255 }), string7: varbinary({ length: 255 }).unique(), string8: varbinary({ length: 255 }), }); async function main() { const db = drizzle(process.env.DATABASE_URL!); await seed(db, { strings }); } main(); ``` ```typescript import { binary, char, mysqlTable, text, varbinary, varchar } from 'drizzle-orm/mysql-core'; import { drizzle } from 'drizzle-orm/mysql2'; import { seed } from "drizzle-seed"; const strings = mysqlTable('strings', { string1: char({ length: 255 }).unique(), string2: char({ length: 255 }), string3: char({ length: 255 }), string4: varchar({ length: 255 }).unique(), string5: varchar({ length: 255 }), string6: varchar({ length: 255 }), string7: binary({ length: 255 }).unique(), string8: binary({ length: 255 }), string9: binary({ length: 255 }), string10: varbinary({ length: 255 }).unique(), string11: varbinary({ length: 255 }), string12: varbinary({ length: 255 }), string13: text(), }); async function main() { const db = drizzle(process.env.DATABASE_URL!); await seed(db, { strings }).refine((f) => ({ strings: { columns: { string1: f.string({ isUnique: true }), string2: f.string({ isUnique: true }), string3: f.string(), string4: f.string({ isUnique: true }), string5: f.string({ isUnique: true }), string6: f.string(), string7: f.string({ isUnique: true }), string8: f.string({ isUnique: true }), string9: f.string(), string10: f.string({ isUnique: true }), string11: f.string({ isUnique: true }), string12: f.string(), string13: f.string({ isUnique: true }), }, }, })); } main(); ``` -------------------------------- ### Install express package with yarn Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-nile Install the express package with yarn for building the web framework. ```bash yarn add express ``` -------------------------------- ### Install Drizzle ORM and MySQL2 Packages Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started-mysql Install the necessary Drizzle ORM and mysql2 packages using npm, yarn, pnpm, or bun. Also install drizzle-kit for development. ```bash npm i drizzle-orm mysql2 npm i -D drizzle-kit ``` ```bash yarn add drizzle-orm mysql2 yarn add -D drizzle-kit ``` ```bash pnpm add drizzle-orm mysql2 pnpm add -D drizzle-kit ``` ```bash bun add drizzle-orm mysql2 bun add -D drizzle-kit ``` -------------------------------- ### Install Drizzle Kit Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/kit-overview Install the Drizzle Kit CLI tool as a dependency in your project. ```bash npm i drizzle-kit ``` ```bash yarn add drizzle-kit ``` ```bash pnpm add drizzle-kit ``` ```bash bun add drizzle-kit ``` -------------------------------- ### Initialize Netlify Project Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-netlify-edge-functions-supabase Set up a new project configuration in the current directory. ```bash netlify init ``` -------------------------------- ### Apollo Server Integration Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/graphql Example setup for an Apollo Server instance using a Drizzle schema. ```typescript import { buildSchema } from 'drizzle-graphql'; import { drizzle } from 'drizzle-orm/...'; import client from './db'; import { ApolloServer } from '@apollo/server'; import { startStandaloneServer } from '@apollo/server/standalone'; import * as dbSchema from './schema'; const db = drizzle({ client, schema: dbSchema }); const { schema } = buildSchema(db); const server = new ApolloServer({ schema }); const { url } = await startStandaloneServer(server); console.log(`🚀 Server ready at ${url}`); ``` ```typescript import { integer, serial, text, pgTable } from 'drizzle-orm/pg-core'; import { relations } from 'drizzle-orm'; export const users = pgTable('users', { id: serial('id').primaryKey(), name: text('name').notNull(), }); export const usersRelations = relations(users, ({ many }) => ({ posts: many(posts), })); export const posts = pgTable('posts', { id: serial('id').primaryKey(), content: text('content').notNull(), authorId: integer('author_id').notNull(), }); export const postsRelations = relations(posts, ({ one }) => ({ author: one(users, { fields: [posts.authorId], references: [users.id] }), })); ``` -------------------------------- ### PostgreSQL String Seeding Examples Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/seed-versioning Examples of defining string columns and seeding them in PostgreSQL. ```typescript import { drizzle } from "drizzle-orm/node-postgres"; import { pgTable, char, varchar, text } from "drizzle-orm/pg-core"; import { seed } from "drizzle-seed"; const strings = pgTable("strings", { string2: char({ length: 256 }).unique(), string3: char({ length: 256 }), string4: varchar().unique(), string5: varchar({ length: 256 }).unique(), string6: varchar({ length: 256 }), string7: text().unique(), }); async function main() { const db = drizzle(process.env.DATABASE_URL!); await seed(db, { strings }); } main(); ``` ```typescript import { drizzle } from "drizzle-orm/node-postgres"; import { pgTable, char, varchar, text } from "drizzle-orm/pg-core"; import { seed } from "drizzle-seed"; const strings = pgTable("strings", { string1: char({ length: 256 }).unique(), string2: char({ length: 256 }), string3: char({ length: 256 }), string4: varchar(), string5: varchar().unique(), string6: varchar({ length: 256 }).unique(), string7: varchar({ length: 256 }), string8: varchar({ length: 256 }), string9: text().unique(), string10: text(), }); async function main() { const db = drizzle(process.env.DATABASE_URL!); await seed(db, { strings }).refine((f) => ({ strings: { columns: { string1: f.string({ isUnique: true }), string2: f.string(), string3: f.string({ isUnique: true }), string4: f.string({ isUnique: true }), string5: f.string({ isUnique: true }), string6: f.string({ isUnique: true }), string7: f.string(), string8: f.string({ isUnique: true }), string9: f.string({ isUnique: true }), string10: f.string({ isUnique: true }), } } })); } main(); ``` -------------------------------- ### Start Local Development Server Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-netlify-edge-functions-supabase Launch the Netlify development environment. ```bash netlify dev ``` -------------------------------- ### GraphQL Yoga Integration Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/graphql Example setup for a GraphQL Yoga server instance using a Drizzle schema. ```typescript import { buildSchema } from 'drizzle-graphql'; import { drizzle } from 'drizzle-orm/...'; import { createYoga } from 'graphql-yoga'; import { createServer } from 'node:http'; import * as dbSchema from './schema'; const db = drizzle({ schema: dbSchema }); const { schema } = buildSchema(db); const yoga = createYoga({ schema }); const server = createServer(yoga); server.listen(4000, () => { console.info('Server is running on http://localhost:4000/graphql'); }); ``` ```typescript import { integer, serial, text, pgTable } from 'drizzle-orm/pg-core'; import { relations } from 'drizzle-orm'; export const users = pgTable('users', { id: serial('id').primaryKey(), name: text('name').notNull(), }); export const usersRelations = relations(users, ({ many }) => ({ posts: many(posts), })); export const posts = pgTable('posts', { id: serial('id').primaryKey(), content: text('content').notNull(), authorId: integer('author_id').notNull(), }); export const postsRelations = relations(posts, ({ one }) => ({ author: one(users, { fields: [posts.authorId], references: [users.id] }), })); ``` -------------------------------- ### Install Vercel Postgres Driver (npm) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-vercel-edge-functions Install the @vercel/postgres driver using npm. ```bash npm i @vercel/postgres ``` -------------------------------- ### Execute synchronous queries with Bun SQLite Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/connect-bun-sqlite Examples of using synchronous query methods like all, get, values, and run. ```typescript import { drizzle } from 'drizzle-orm/bun-sqlite'; import { Database } from 'bun:sqlite'; const sqlite = new Database('sqlite.db'); const db = drizzle({ client: sqlite }); const result = db.select().from(users).all(); const result = db.select().from(users).get(); const result = db.select().from(users).values(); const result = db.select().from(users).run(); ``` -------------------------------- ### Initialize a New Netlify Project Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-netlify-edge-functions-neon Run 'netlify init' to initialize a new Netlify project. Follow the CLI prompts to configure your site. ```bash netlify init ``` -------------------------------- ### Extended Drizzle Kit Configuration Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/drizzle-config-file An extended configuration example demonstrating options for driver, database credentials, introspection settings, and migration preferences. Useful for more complex setups. ```typescript import { defineConfig } from "drizzle-kit"; export default defineConfig({ out: "./drizzle", dialect: "postgresql", schema: "./src/schema.ts", driver: "pglite", dbCredentials: { url: "./database/", }, extensionsFilters: ["postgis"], schemaFilter: "public", tablesFilter: "*", introspect: { casing: "camel", }, migrations: { prefix: "timestamp", table: "__drizzle_migrations__", schema: "public", }, entities: { roles: { provider: '', exclude: [], include: [] } } breakpoints: true, strict: true, verbose: true, }); ``` -------------------------------- ### Start Development Server Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-vercel-edge-functions Run the next dev command to start your local development server for testing. ```bash npx next dev ``` -------------------------------- ### Install Vercel CLI Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-vercel-edge-functions Install the Vercel CLI globally using npm, yarn, pnpm, or bun. ```bash npm i -g vercel ``` ```bash yarn add -g vercel ``` ```bash pnpm add -g vercel ``` ```bash bun add -g vercel ``` -------------------------------- ### Initialize Drizzle with MySQL2 (Pool or Client) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started/mysql-new Initialize Drizzle ORM with a pre-configured `mysql2` connection pool or a single client. This example shows setup using `mysql.createPool` and `mysql.createConnection`. ```typescript import 'dotenv/config'; import { drizzle } from "drizzle-orm/mysql2"; import mysql from "mysql2/promise"; const poolConnection = mysql.createPool({ host: "host", user: "user", database: "database", }); const db = drizzle({ client: poolConnection }); // or if you need client connection async function main() { const connection = await mysql.createConnection({ host: "host", user: "user", database: "database", }); const db = drizzle({ client: connection }); } main(); ``` -------------------------------- ### Install express package with pnpm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-nile Install the express package with pnpm for building the web framework. ```bash pnpm add express ``` -------------------------------- ### Setup Database URL Environment Variable Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started/mysql-new Create a `.env` file in your project root and add your MySQL database connection URL. ```dotenv DATABASE_URL= ``` -------------------------------- ### Install OpenAI Package Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/guides/vector-similarity-search Install the OpenAI package to generate embeddings. Ensure you have drizzle-orm and drizzle-kit installed. ```bash npm i openai ``` ```bash yarn add openai ``` ```bash pnpm add openai ``` ```bash bun add openai ``` -------------------------------- ### Installation Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/typebox Install the drizzle-typebox package using your preferred package manager. Ensure Drizzle ORM and Typebox are installed with compatible versions. ```APIDOC ## Installation This documentation is for `drizzle-typebox@0.2.0` and higher. **Prerequisites:** - Drizzle ORM v0.36.0 or greater - Typebox v0.34.8 or greater ### npm ```bash npm i drizzle-typebox ``` ### yarn ```bash yarn add drizzle-typebox ``` ### pnpm ```bash pnpm add drizzle-typebox ``` ### bun ```bash bun add drizzle-typebox ``` ``` -------------------------------- ### Initialize Gel Project Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started/gel-new Initializes a new Gel project after the CLI is installed. ```bash gel project init ``` -------------------------------- ### Install node-postgres package with bun Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-nile Install the node-postgres package using bun for connecting to a Postgres database. ```bash bun add node-postgres ``` -------------------------------- ### Install Dependencies Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started/vercel-new Commands to install Drizzle ORM, Vercel Postgres driver, and development tools. ```bash npm i drizzle-orm @vercel/postgres dotenv npm i -D drizzle-kit tsx ``` ```bash yarn add drizzle-orm @vercel/postgres dotenv yarn add -D drizzle-kit tsx ``` ```bash pnpm add drizzle-orm @vercel/postgres dotenv pnpm add -D drizzle-kit tsx ``` ```bash bun add drizzle-orm @vercel/postgres dotenv bun add -D drizzle-kit tsx ``` -------------------------------- ### Install express package with npm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-nile Install the express package with npm for building the web framework. ```bash npm i express ``` -------------------------------- ### Install drizzle-zod with bun Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/zod Install the drizzle-zod package using bun. Ensure Drizzle ORM and Zod are also installed and up-to-date. ```bash bun add drizzle-zod ``` -------------------------------- ### Initialize postgres.js with configuration Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started-postgresql Initialization using a configuration object to specify connection options like SSL. ```typescript import { drizzle } from 'drizzle-orm/postgres-js'; // You can specify any property from the postgres-js connection options const db = drizzle({ connection: { url: process.env.DATABASE_URL, ssl: true } }); const result = await db.execute('select 1'); ``` -------------------------------- ### Initialize Supabase Project Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-supabase-edge-functions Initialize a new Supabase project locally. This command creates a `supabase` folder with a `config.toml` file. ```bash supabase init ``` -------------------------------- ### Install drizzle-zod with pnpm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/zod Install the drizzle-zod package using pnpm. Ensure Drizzle ORM and Zod are also installed and up-to-date. ```bash pnpm add drizzle-zod ``` -------------------------------- ### Install drizzle-zod with yarn Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/zod Install the drizzle-zod package using yarn. Ensure Drizzle ORM and Zod are also installed and up-to-date. ```bash yarn add drizzle-zod ``` -------------------------------- ### Install drizzle-zod with npm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/zod Install the drizzle-zod package using npm. Ensure Drizzle ORM and Zod are also installed and up-to-date. ```bash npm i drizzle-zod ``` -------------------------------- ### Install drizzle-arktype with bun Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/arktype Install the drizzle-arktype package using bun. Ensure Drizzle ORM v0.36.0+ and Arktype v2.0.0+ are installed. ```bash bun add drizzle-arktype ``` -------------------------------- ### Configure environment variables Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started/sqlite-new Example of setting the database file path in the .env file. ```text DB_FILE_NAME= ``` ```text DB_FILE_NAME=file:local.db ``` -------------------------------- ### Install drizzle-arktype with pnpm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/arktype Install the drizzle-arktype package using pnpm. Ensure Drizzle ORM v0.36.0+ and Arktype v2.0.0+ are installed. ```bash pnpm add drizzle-arktype ``` -------------------------------- ### Install drizzle-arktype with yarn Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/arktype Install the drizzle-arktype package using yarn. Ensure Drizzle ORM v0.36.0+ and Arktype v2.0.0+ are installed. ```bash yarn add drizzle-arktype ``` -------------------------------- ### Install drizzle-arktype with npm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/arktype Install the drizzle-arktype package using npm. Ensure Drizzle ORM v0.36.0+ and Arktype v2.0.0+ are installed. ```bash npm i drizzle-arktype ``` -------------------------------- ### Turso CLI: Signup Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-turso Command to sign up for a Turso account. ```bash turso auth signup ``` -------------------------------- ### Install drizzle-valibot with bun Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/valibot Install the `drizzle-valibot` package using bun. Ensure Drizzle ORM and Valibot are also installed with compatible versions. ```bash bun add drizzle-valibot ``` -------------------------------- ### Install drizzle-valibot with pnpm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/valibot Install the `drizzle-valibot` package using pnpm. Ensure Drizzle ORM and Valibot are also installed with compatible versions. ```bash pnpm add drizzle-valibot ``` -------------------------------- ### MySQL Union All Examples Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/set-operations Examples for performing UNION ALL in MySQL using import and builder patterns, along with the required schema definition. ```typescript import { unionAll } from 'drizzle-orm/mysql-core' import { onlineSales, inStoreSales } from './schema' const onlineTransactions = db.select({ transaction: onlineSales.transactionId }).from(onlineSales); const inStoreTransactions = db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales); const result = await unionAll(onlineTransactions, inStoreTransactions); ``` ```sql select `transaction_id` from `online_sales` union all select `transaction_id` from `in_store_sales` ``` ```typescript import { onlineSales, inStoreSales } from './schema' const result = await db .select({ transaction: onlineSales.transactionId }) .from(onlineSales) .unionAll( db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales) ); ``` ```sql (select `transaction_id` from `online_sales`) union all (select `transaction_id` from `in_store_sales`) ``` ```typescript import { int, mysqlTable, text, timestamp, varchar } from "drizzle-orm/mysql-core"; const onlineSales = mysqlTable('online_sales', { transactionId: int('transaction_id').primaryKey(), productId: int('product_id').unique(), quantitySold: int('quantity_sold'), saleDate: timestamp('sale_date', { mode: 'date' }), }); const inStoreSales = mysqlTable('in_store_sales', { transactionId: int('transaction_id').primaryKey(), productId: int('product_id').unique(), quantitySold: int('quantity_sold'), saleDate: timestamp('sale_date', { mode: 'date' }), }); ``` -------------------------------- ### Install drizzle-valibot with yarn Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/valibot Install the `drizzle-valibot` package using yarn. Ensure Drizzle ORM and Valibot are also installed with compatible versions. ```bash yarn add drizzle-valibot ``` -------------------------------- ### Install drizzle-valibot with npm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/valibot Install the `drizzle-valibot` package using npm. Ensure Drizzle ORM and Valibot are also installed with compatible versions. ```bash npm i drizzle-valibot ``` -------------------------------- ### Install better-sqlite3 with bun Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started-sqlite Install drizzle-orm and better-sqlite3 packages using bun. Also installs development dependencies for drizzle-kit and better-sqlite3 types. ```bash bun add drizzle-orm better-sqlite3 bun add -D drizzle-kit @types/better-sqlite3 ``` -------------------------------- ### PostgreSQL Read Replicas Setup Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/read-replicas Set up read replicas for PostgreSQL. Ensure primary and replica databases are initialized with Drizzle ORM. ```typescript import { sql } from 'drizzle-orm'; import { drizzle } from 'drizzle-orm/node-postgres'; import { boolean, jsonb, pgTable, serial, text, timestamp, withReplicas } from 'drizzle-orm/pg-core'; const usersTable = pgTable('users', { id: serial('id' as string).primaryKey(), name: text('name').notNull(), verified: boolean('verified').notNull().default(false), jsonb: jsonb('jsonb').$type(), createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), }); const primaryDb = drizzle("postgres://user:password@host:port/primary_db"); const read1 = drizzle("postgres://user:password@host:port/read_replica_1"); const read2 = drizzle("postgres://user:password@host:port/read_replica_2"); const db = withReplicas(primaryDb, [read1, read2]); ``` -------------------------------- ### Install better-sqlite3 with pnpm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started-sqlite Install drizzle-orm and better-sqlite3 packages using pnpm. Also installs development dependencies for drizzle-kit and better-sqlite3 types. ```bash pnpm add drizzle-orm better-sqlite3 pnpm add -D drizzle-kit @types/better-sqlite3 ``` -------------------------------- ### Deploy Project Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-netlify-edge-functions-supabase Commands for deploying the project to Netlify. ```bash netlify deploy ``` ```bash netlify deploy --prod ``` -------------------------------- ### Install better-sqlite3 with yarn Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started-sqlite Install drizzle-orm and better-sqlite3 packages using yarn. Also installs development dependencies for drizzle-kit and better-sqlite3 types. ```bash yarn add drizzle-orm better-sqlite3 yarn add -D drizzle-kit @types/better-sqlite3 ``` -------------------------------- ### Manage Multiple Configuration Files Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/drizzle-kit-pull Use specific configuration files for different environments or databases. ```bash npx drizzle-kit pull --config=drizzle-dev.config.ts npx drizzle-kit pull --config=drizzle-prod.config.ts ``` ```bash yarn drizzle-kit pull --config=drizzle-dev.config.ts yarn drizzle-kit pull --config=drizzle-prod.config.ts ``` ```bash pnpm drizzle-kit pull --config=drizzle-dev.config.ts pnpm drizzle-kit pull --config=drizzle-prod.config.ts ``` ```bash bun drizzle-kit pull --config=drizzle-dev.config.ts bun drizzle-kit pull --config=drizzle-prod.config.ts ``` -------------------------------- ### Install better-sqlite3 with npm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started-sqlite Install drizzle-orm and better-sqlite3 packages using npm. Also installs development dependencies for drizzle-kit and better-sqlite3 types. ```bash npm i drizzle-orm better-sqlite3 npm i -D drizzle-kit @types/better-sqlite3 ``` -------------------------------- ### Install mysql2 and Drizzle Packages (bun) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started/mysql-new Install the `drizzle-orm`, `mysql2`, `dotenv` packages for runtime and `drizzle-kit`, `tsx` for development using bun. ```bash bun add drizzle-orm mysql2 dotenv bun add -D drizzle-kit tsx ``` -------------------------------- ### PostgreSQL Union All Examples Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/set-operations Examples for performing UNION ALL in PostgreSQL using import and builder patterns, along with the required schema definition. ```typescript import { unionAll } from 'drizzle-orm/pg-core' import { onlineSales, inStoreSales } from './schema' const onlineTransactions = db.select({ transaction: onlineSales.transactionId }).from(onlineSales); const inStoreTransactions = db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales); const result = await unionAll(onlineTransactions, inStoreTransactions); ``` ```sql select "transaction_id" from "online_sales" union all select "transaction_id" from "in_store_sales" ``` ```typescript import { onlineSales, inStoreSales } from './schema' const result = await db .select({ transaction: onlineSales.transactionId }) .from(onlineSales) .unionAll( db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales) ); ``` ```sql select "transaction_id" from "online_sales" union all select "transaction_id" from "in_store_sales" ``` ```typescript import { integer, pgTable, text, timestamp, varchar } from "drizzle-orm/pg-core"; const onlineSales = pgTable('online_sales', { transactionId: integer('transaction_id').primaryKey(), productId: integer('product_id').unique(), quantitySold: integer('quantity_sold'), saleDate: timestamp('sale_date', { mode: 'date' }), }); const inStoreSales = pgTable('in_store_sales', { transactionId: integer('transaction_id').primaryKey(), productId: integer('product_id').unique(), quantitySold: integer('quantity_sold'), saleDate: timestamp('sale_date', { mode: 'date' }), }); ``` -------------------------------- ### Start Supabase Local Development Stack Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-supabase-edge-functions Start the local Supabase development environment. Ensure Docker is running before executing this command. ```bash supabase start ``` -------------------------------- ### Install Drizzle ORM and PGlite with pnpm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/connect-pglite Install the necessary Drizzle ORM and PGlite packages using pnpm. Also installs drizzle-kit for development. ```bash pnpm add drizzle-orm @electric-sql/pglite pnpm add -D drizzle-kit ``` -------------------------------- ### Install Drizzle ORM and PGlite with yarn Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/connect-pglite Install the necessary Drizzle ORM and PGlite packages using yarn. Also installs drizzle-kit for development. ```bash yarn add drizzle-orm @electric-sql/pglite yarn add -D drizzle-kit ``` -------------------------------- ### Install Drizzle ORM and PGlite with npm Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/connect-pglite Install the necessary Drizzle ORM and PGlite packages using npm. Also installs drizzle-kit for development. ```bash npm i drizzle-orm @electric-sql/pglite npm i -D drizzle-kit ``` -------------------------------- ### Turso Environment Variables Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-vercel-edge-functions Example configuration for Turso connection details in a .env file. ```bash TURSO_CONNECTION_URL="libsql://[db-name].turso.io" TURSO_AUTH_TOKEN="[auth-token]" ``` -------------------------------- ### Install @netlify/edge-functions package (bun) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-netlify-edge-functions-supabase Install the @netlify/edge-functions package using bun to import types for the Context object, which is used in Netlify Edge Functions. ```bash bun add @netlify/edge-functions ``` -------------------------------- ### Curl Commands for Tenant and Todo Management Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-nile Example `curl` commands to interact with the tenant and todo API endpoints. These demonstrate creating tenants, listing tenants, creating todos, and listing todos for a specific tenant. ```bash # create a tenant curl --location --request POST 'localhost:3001/api/tenants' \ --header 'Content-Type: application/json' \ --data-raw '{"name":"my first customer"}' ``` ```bash # get tenants curl -X GET 'http://localhost:3001/api/tenants' ``` ```bash # create a todo (don't forget to use a real tenant-id in the URL) curl -X POST \ 'http://localhost:3001/api/tenants/108124a5-2e34-418a-9735-b93082e9fbf2/todos' \ --header 'Content-Type: application/json' \ --data-raw '{"title": "feed the cat", "complete": false}' ``` ```bash # list todos for tenant (don't forget to use a real tenant-id in the URL) curl -X GET \ 'http://localhost:3001/api/tenants/108124a5-2e34-418a-9735-b93082e9fbf2/todos' ``` -------------------------------- ### Install Neon Serverless Driver (bun) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-neon Install the Neon serverless driver using bun. This driver is required to connect to Neon databases. ```bash bun add @neondatabase/serverless ``` -------------------------------- ### Install Drizzle ORM with Xata Client (bun) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/latest-releases/drizzle-orm-v0304 Installs the necessary Drizzle ORM and Xata client packages using bun. Also installs drizzle-kit for development. ```bash bun add drizzle-orm @xata.io/client bun add -D drizzle-kit ``` -------------------------------- ### Run drizzle-kit up with CLI options Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/drizzle-kit-up Execute the upgrade command with specific dialect and output directory options. ```bash npx drizzle-kit up --dialect=postgresql npx drizzle-kit up --dialect=postgresql --out=./migrations-folder ``` ```bash yarn drizzle-kit up --dialect=postgresql yarn drizzle-kit up --dialect=postgresql --out=./migrations-folder ``` ```bash pnpm drizzle-kit up --dialect=postgresql pnpm drizzle-kit up --dialect=postgresql --out=./migrations-folder ``` ```bash bun drizzle-kit up --dialect=postgresql bun drizzle-kit up --dialect=postgresql --out=./migrations-folder ``` -------------------------------- ### Install Drizzle ORM with Xata Client (pnpm) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/latest-releases/drizzle-orm-v0304 Installs the necessary Drizzle ORM and Xata client packages using pnpm. Also installs drizzle-kit for development. ```bash pnpm add drizzle-orm @xata.io/client pnpm add -D drizzle-kit ``` -------------------------------- ### Install Drizzle ORM with Xata Client (yarn) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/latest-releases/drizzle-orm-v0304 Installs the necessary Drizzle ORM and Xata client packages using yarn. Also installs drizzle-kit for development. ```bash yarn add drizzle-orm @xata.io/client yarn add -D drizzle-kit ``` -------------------------------- ### Install Netlify Edge Functions types Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-netlify-edge-functions-neon Install types for the Netlify Edge Functions Context object. ```bash npm i @netlify/edge-functions ``` ```bash yarn add @netlify/edge-functions ``` ```bash pnpm add @netlify/edge-functions ``` ```bash bun add @netlify/edge-functions ``` -------------------------------- ### Install Drizzle ORM with Xata Client (npm) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/latest-releases/drizzle-orm-v0304 Installs the necessary Drizzle ORM and Xata client packages using npm. Also installs drizzle-kit for development. ```bash npm i drizzle-orm @xata.io/client npm i -D drizzle-kit ``` -------------------------------- ### Install Drizzle and Gel Packages (bun) Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/get-started/gel-new Installs Drizzle ORM, the Gel package, Drizzle Kit, and tsx using bun. ```bash bun add drizzle-orm gel bun add -D drizzle-kit tsx ``` -------------------------------- ### Configure Netlify for Deno Imports Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-with-netlify-edge-functions-neon Create a netlify.toml file to specify the Deno import map and route requests to edge functions. ```toml [functions] deno_import_map = "./import_map.json" [[edge_functions]] path = "/user" function = "user" ``` -------------------------------- ### Install Dotenv Source: https://rqbv2.drizzle-orm-fe.pages.dev/docs/tutorials/drizzle-nextjs-neon Install the dotenv package to manage environment variables. ```bash npm i dotenv ``` ```bash yarn add dotenv ``` ```bash pnpm add dotenv ``` ```bash bun add dotenv ```