### Example Usage of Find Similar Guides
Source: https://orm.drizzle.team/docs/guides/vector-similarity-search
This example shows how to call the `findSimilarGuides` function with a sample description and store the results. Ensure `findSimilarGuides` is defined and `generateEmbedding` is available.
```typescript
const description = 'Guides on using Drizzle ORM with different platforms';
const similarGuides = await findSimilarGuides(description);
```
--------------------------------
### Install @libsql/client package (bun)
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-turso
Install the @libsql/client package using bun.
```bash
bun add @libsql/client
```
--------------------------------
### Install @libsql/client package (yarn)
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-turso
Install the @libsql/client package using yarn.
```bash
yarn add @libsql/client
```
--------------------------------
### Install @libsql/client package (pnpm)
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-turso
Install the @libsql/client package using pnpm.
```bash
pnpm add @libsql/client
```
--------------------------------
### Install drizzle-seed with bun
Source: https://orm.drizzle.team/docs/seed-overview
Install the drizzle-seed library using bun.
```bash
bun add drizzle-seed
```
--------------------------------
### Install PostgreSQL Driver with bun
Source: https://orm.drizzle.team/docs/tutorials/bun-railway-pg
Install the 'pg' package for PostgreSQL connectivity using bun. Also install types for TypeScript support.
```bash
bun add pg
bun add -D @types/pg
```
--------------------------------
### Install Drizzle ORM and Netlify Database Packages (bun)
Source: https://orm.drizzle.team/docs/connect-netlify-db
Install the necessary Drizzle ORM and Netlify Database packages using bun. Also install drizzle-kit for development tooling.
```bash
bun add drizzle-orm @netlify/database
bun add -D drizzle-kit
```
--------------------------------
### Install Drizzle ORM and libSQL Client with bun
Source: https://orm.drizzle.team/docs/connect-turso
Install the Drizzle ORM and the libSQL client for Turso Cloud using bun. Also install drizzle-kit for development.
```bash
bun add drizzle-orm @libsql/client
bun add -D drizzle-kit
```
--------------------------------
### Install ArkType with bun
Source: https://orm.drizzle.team/docs/arktype
Install the arktype package using bun.
```bash
bun add arktype
```
--------------------------------
### Install @vercel/postgres package (bun)
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-vercel
Install the @vercel/postgres package using bun.
```bash
bun add @vercel/postgres
```
--------------------------------
### Install Drizzle ORM and libSQL Client with npm
Source: https://orm.drizzle.team/docs/connect-turso
Install the Drizzle ORM and the libSQL client for Turso Cloud using npm. Also install drizzle-kit for development.
```bash
npm i drizzle-orm @libsql/client
npm i -D drizzle-kit
```
--------------------------------
### Start Development Server
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-vercel-edge-functions
Run the next dev command to start your local development server for testing.
```bash
npx next dev
```
--------------------------------
### Search Similar Guides by Embedding
Source: https://orm.drizzle.team/docs/guides/vector-similarity-search
Example of how to perform a similarity search using Drizzle ORM. It utilizes the cosineDistance function and the sql operator to find guides with embeddings similar to a generated one.
```typescript
import { cosineDistance, desc, gt, sql } from 'drizzle-orm';
import { generateEmbedding } from './embedding';
import { guides } from './schema';
const db = drizzle(...);
```
--------------------------------
### Define PostgreSQL Table with Identity Column
Source: https://orm.drizzle.team/docs/latest-releases/drizzle-orm-v0320
Example of defining a PostgreSQL table with an identity column that starts at a specific value.
```typescript
import { pgTable, integer, text } from 'drizzle-orm/pg-core'
export const ingredients = pgTable("ingredients", {
id: integer("id").primaryKey().generatedAlwaysAsIdentity({ startWith: 1000 }),
name: text("name").notNull(),
description: text("description"),
});
```
--------------------------------
### Initialize New Netlify Project
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-netlify-edge-functions-supabase
Initialize a new Netlify project using the Netlify CLI.
```bash
netlify init
```
--------------------------------
### Sample Output of Similar Guides
Source: https://orm.drizzle.team/docs/guides/vector-similarity-search
This is a sample JSON output representing a list of guides found to be similar to the provided description, including their name, URL, and similarity score.
```json
[
{
"name": "Drizzle with Turso",
"url": "/docs/tutorials/drizzle-with-turso",
"similarity": 0.8642314333984994
},
{
"name": "Drizzle with Supabase Database",
"url": "/docs/tutorials/drizzle-with-supabase",
"similarity": 0.8593631126014918
},
{
"name": "Drizzle with Neon Postgres",
"url": "/docs/tutorials/drizzle-with-neon",
"similarity": 0.8541051184461372
},
{
"name": "Drizzle with Vercel Edge Functions",
"url": "/docs/tutorials/drizzle-with-vercel-edge-functions",
"similarity": 0.8481551084241092
}
]
```
--------------------------------
### Standalone Query Builder for CockroachDB
Source: https://orm.drizzle.team/docs/goodies
Build queries and get generated SQL without a database instance. This example is for CockroachDB.
```typescript
import { QueryBuilder } from 'drizzle-orm/cockroach-core';
const qb = new QueryBuilder();
const query = qb.select().from(users).where(eq(users.name, 'Dan'));
const { sql, params } = query.toSQL();
```
--------------------------------
### Standalone Query Builder for MSSQL
Source: https://orm.drizzle.team/docs/goodies
Build queries and get generated SQL without a database instance. This example is for MSSQL.
```typescript
import { QueryBuilder } from 'drizzle-orm/mssql-core';
const qb = new QueryBuilder();
const query = qb.select().from(users).where(eq(users.name, 'Dan'));
const { sql, params } = query.toSQL();
```
--------------------------------
### Home Page Setup
Source: https://orm.drizzle.team/docs/tutorials/drizzle-nextjs-neon
Sets up the home page to fetch and display to-do items using the Todos component.
```tsx
import { getData } from "@/actions/todoAction";
import Todos from "@/components/todos";
export default async function Home() {
const data = await getData();
return ;
}
```
--------------------------------
### Project Structure Example
Source: https://orm.drizzle.team/docs/get-started/gel-new
Illustrates the basic file structure for a project using Drizzle and Gel.
```tree
📦
├ 📂 drizzle
├ 📂 src
│ └ 📜 index.ts
├ 📜 drizzle.config.ts
├ 📜 package.json
└ 📜 tsconfig.json
```
--------------------------------
### Standalone Query Builder for SingleStore
Source: https://orm.drizzle.team/docs/goodies
Build queries and get generated SQL without a database instance. This example is for SingleStore.
```typescript
import { QueryBuilder } from 'drizzle-orm/singlestore-core';
const qb = new QueryBuilder();
const query = qb.select().from(users).where(eq(users.name, 'Dan'));
const { sql, params } = query.toSQL();
```
--------------------------------
### Standalone Query Builder for SQLite
Source: https://orm.drizzle.team/docs/goodies
Build queries and get generated SQL without a database instance. This example is for SQLite.
```typescript
import { QueryBuilder } from 'drizzle-orm/sqlite-core';
const qb = new QueryBuilder();
const query = qb.select().from(users).where(eq(users.name, 'Dan'));
const { sql, params } = query.toSQL();
```
--------------------------------
### Install @libsql/client package (npm)
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-turso
Install the @libsql/client package using npm.
```bash
npm i @libsql/client
```
--------------------------------
### Standalone Query Builder for MySQL
Source: https://orm.drizzle.team/docs/goodies
Build queries and get generated SQL without a database instance. This example is for MySQL.
```typescript
import { QueryBuilder } from 'drizzle-orm/mysql-core';
const qb = new QueryBuilder();
const query = qb.select().from(users).where(eq(users.name, 'Dan'));
const { sql, params } = query.toSQL();
```
--------------------------------
### Initialize Gel Project (bun)
Source: https://orm.drizzle.team/docs/get-started/gel-new
Command to initialize a new Gel project using bun.
```bash
bunx gel project init
```
--------------------------------
### Standalone Query Builder for PostgreSQL
Source: https://orm.drizzle.team/docs/goodies
Build queries and get generated SQL without a database instance. This example is for PostgreSQL.
```typescript
import { QueryBuilder } from 'drizzle-orm/pg-core';
const qb = new QueryBuilder();
const query = qb.select().from(users).where(eq(users.name, 'Dan'));
const { sql, params } = query.toSQL();
```
--------------------------------
### Install Drizzle ORM and Netlify Database Packages (yarn)
Source: https://orm.drizzle.team/docs/connect-netlify-db
Install the necessary Drizzle ORM and Netlify Database packages using yarn. Also install drizzle-kit for development tooling.
```bash
yarn add drizzle-orm @netlify/database
yarn add -D drizzle-kit
```
--------------------------------
### Run Drizzle Migrate with CLI Options
Source: https://orm.drizzle.team/docs/drizzle-kit-migrate
Example of running `drizzle-kit migrate` using command-line arguments for dialect and database URL.
```bash
npx drizzle-kit migrate --dialect=postgresql --url=postgresql://user:password@host:port/dbname
```
--------------------------------
### OP-SQLite Driver Usage Example
Source: https://orm.drizzle.team/docs/latest-releases/drizzle-orm-v0301
Demonstrates how to integrate and use the OP-SQLite driver with Drizzle ORM. Ensure you have the '@op-engineering/op-sqlite' package installed.
```typescript
import {
open
} from '@op-engineering/op-sqlite';
import { drizzle } from 'drizzle-orm/op-sqlite';
const opsqlite = open({
name: 'myDB',
});
const db = drizzle(opsqlite);
await db.select().from(users);
```
--------------------------------
### Install Drizzle ORM and Netlify Database Packages (pnpm)
Source: https://orm.drizzle.team/docs/connect-netlify-db
Install the necessary Drizzle ORM and Netlify Database packages using pnpm. Also install drizzle-kit for development tooling.
```bash
pnpm add drizzle-orm @netlify/database
pnpm add -D drizzle-kit
```
--------------------------------
### Install Drizzle ORM and Netlify Database Packages (npm)
Source: https://orm.drizzle.team/docs/connect-netlify-db
Install the necessary Drizzle ORM and Netlify Database packages using npm. Also install drizzle-kit for development tooling.
```bash
npm i drizzle-orm @netlify/database
npm i -D drizzle-kit
```
--------------------------------
### Get Typed Columns for CockroachDB Schema
Source: https://orm.drizzle.team/docs/goodies
Retrieve a typed columns map to omit specific columns during selection. This example uses a CockroachDB schema.
```typescript
import { getColumns } from "drizzle-orm";
import { user } from "./schema";
const { password, role, ...rest } = getColumns(user);
await db.select({ ...rest }).from(users);
```
```typescript
import { int4, text, pgTable } from "drizzle-orm/cockroach-core";
export const user = pgTable("user", {
id: int4().primaryKey(),
name: text(),
email: text(),
password: text(),
role: text().$type<"admin" | "customer">(),
});
```
--------------------------------
### Install PlanetScale Database Driver (bun)
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-vercel-edge-functions
Install the PlanetScale database driver using bun.
```bash
bun add @planetscale/database
```
--------------------------------
### Get Typed Columns for MSSQL Schema
Source: https://orm.drizzle.team/docs/goodies
Retrieve a typed columns map to omit specific columns during selection. This example uses an MSSQL schema.
```typescript
import { getColumns } from "drizzle-orm";
import { user } from "./schema";
const { password, role, ...rest } = getColumns(user);
await db.select({ ...rest }).from(users);
```
```typescript
import { int, text, mssqlTable } from "drizzle-orm/mssql-core";
export const user = mssqlTable("user", {
id: int().primaryKey(),
name: text(),
email: text(),
password: text(),
role: text().$type<"admin" | "customer">(),
});
```
--------------------------------
### Initialize Gel Project (npm)
Source: https://orm.drizzle.team/docs/get-started/gel-new
Command to initialize a new Gel project using npm.
```bash
npx gel project init
```
--------------------------------
### Get Typed Columns for SingleStore Schema
Source: https://orm.drizzle.team/docs/goodies
Retrieve a typed columns map to omit specific columns during selection. This example uses a SingleStore schema.
```typescript
import { getColumns } from "drizzle-orm";
import { user } from "./schema";
const { password, role, ...rest } = getColumns(user);
await db.select({ ...rest }).from(users);
```
```typescript
import { int, text, singlestoreTable } from "drizzle-orm/singlestore-core";
export const user = singlestoreTable("user", {
id: int("id").primaryKey().autoincrement(),
name: text("name"),
email: text("email"),
password: text("password"),
role: text("role").$type<"admin" | "customer">(),
});
```
--------------------------------
### Get Typed Columns for SQLite Schema
Source: https://orm.drizzle.team/docs/goodies
Retrieve a typed columns map to omit specific columns during selection. This example uses a SQLite schema.
```typescript
import { getColumns } from "drizzle-orm";
import { user } from "./schema";
const { password, role, ...rest } = getColumns(user);
await db.select({ ...rest }).from(users);
```
```typescript
import { integer, text, sqliteTable } from "drizzle-orm/sqlite-core";
export const user = sqliteTable("user", {
id: integer("id").primaryKey({ autoIncrement: true }),
name: text("name"),
email: text("email"),
password: text("password"),
role: text("role").$type<"admin" | "customer">(),
});
```
--------------------------------
### Bun Start Script Configuration
Source: https://orm.drizzle.team/docs/tutorials/bun-railway-pg
Defines the start script in package.json to run the Bun application using the specified entry point.
```json
{
"scripts": {
"start": "bun src/index.ts"
}
}
```
--------------------------------
### Get Typed Columns for MySQL Schema
Source: https://orm.drizzle.team/docs/goodies
Retrieve a typed columns map to omit specific columns during selection. This example uses a MySQL schema.
```typescript
import { getColumns } from "drizzle-orm";
import { user } from "./schema";
const { password, role, ...rest } = getColumns(user);
await db.select({ ...rest }).from(users);
```
```typescript
import { int, text, mysqlTable } from "drizzle-orm/mysql-core";
export const user = mysqlTable("user", {
id: int("id").primaryKey().autoincrement(),
name: text("name"),
email: text("email"),
password: text("password"),
role: text("role").$type<"admin" | "customer">(),
});
```
--------------------------------
### Get Typed Columns for PostgreSQL Schema
Source: https://orm.drizzle.team/docs/goodies
Retrieve a typed columns map to omit specific columns during selection. This example uses a PostgreSQL schema.
```typescript
import { getColumns } from "drizzle-orm";
import { user } from "./schema";
const { password, role, ...rest } = getColumns(user);
await db.select({ ...rest }).from(users);
```
```typescript
import { serial, text, pgTable } from "drizzle-orm/pg-core";
export const user = pgTable("user", {
id: serial("id").primaryKey(),
name: text("name"),
email: text("email"),
password: text("password"),
role: text("role").$type<"admin" | "customer">(),
});
```
--------------------------------
### Install Drizzle ORM and Drizzle Kit (bun)
Source: https://orm.drizzle.team/docs/column-types/cockroach
Install the beta versions of Drizzle ORM and Drizzle Kit using bun.
```bash
bun add drizzle-orm@beta
bun add drizzle-kit@beta -D
```
--------------------------------
### Count all rows greater than a value
Source: https://orm.drizzle.team/docs/guides/count-rows
Use `count()` to get the total number of rows that satisfy a condition. This example counts products with a price greater than 100.
```typescript
import { gt } from 'drizzle-orm';
import { products } from './schema';
await db.selectCount().from(products).where(gt(products.price, 100));
```
```sql
select count(*) from products where price > 100
```
--------------------------------
### Run Drizzle Studio with Custom Host (npm)
Source: https://orm.drizzle.team/docs/drizzle-kit-studio
Starts the Drizzle Studio server, making it accessible from any network interface using npm.
```bash
npx drizzle-kit studio --host=0.0.0.0
```
--------------------------------
### Run Encore Application
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-encore
Starts your Encore application. Encore automatically applies database migrations on startup.
```bash
encore run
```
--------------------------------
### Apollo Server Setup with Drizzle GraphQL
Source: https://orm.drizzle.team/docs/graphql
Set up an Apollo Server using the schema generated by drizzle-graphql from your Drizzle ORM schema. This example demonstrates basic integration.
```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}`);
```
--------------------------------
### Setup Drizzle Config File
Source: https://orm.drizzle.team/docs/migrate/migrate-from-prisma
Configure Drizzle Kit with database connection details, migration folder, and schema file location. Ensure 'dotenv' is installed for environment variable management.
```typescript
import 'dotenv/config'; // make sure to install dotenv package
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
dialect: 'postgresql',
out: './src/drizzle',
schema: './src/drizzle/schema.ts',
dbCredentials: {
host: process.env.DB_HOST!,
port: Number(process.env.DB_PORT!),
user: process.env.DB_USERNAME!,
password: process.env.DB_PASSWORD!,
database: process.env.DB_NAME!,
},
// Print all statements
verbose: true,
// Always ask for confirmation
strict: true,
});
```
--------------------------------
### Run Drizzle Studio with Custom Host (bun)
Source: https://orm.drizzle.team/docs/drizzle-kit-studio
Starts the Drizzle Studio server, making it accessible from any network interface using bun.
```bash
bunx drizzle-kit studio --host=0.0.0.0
```
--------------------------------
### Drizzle Schema and Basic Edge Function
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-supabase-edge-functions
Copy your Drizzle schema definitions and a basic Deno server setup into your function's `index.ts` file. This example includes schema definition and a simple HTTP endpoint.
```typescript
// Setup type definitions for built-in Supabase Runtime APIs
import "jsr:@supabase/functions-js/edge-runtime.d.ts"
import { pgTable, serial, text, integer } from "drizzle-orm/pg-core";
const usersTable = pgTable('users_table', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
age: integer('age').notNull()
})
Deno.serve(async (req) => {
const { name } = await req.json()
const data = {
message: `Hello ${name}!`,
}
return new Response(
JSON.stringify(data),
{ headers: { "Content-Type": "application/json" } },
)
})
```
--------------------------------
### Initialize Supabase Project
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-supabase-edge-functions
Initialize a new Supabase project in a local folder. This command creates the necessary Supabase configuration files.
```bash
supabase init
```
--------------------------------
### Configure Drizzle Kit with Schema Filters and Extensions
Source: https://orm.drizzle.team/docs/drizzle-kit-pull
Configure Drizzle Kit to manage specific tables and schemas, and to recognize installed database extensions like PostGIS. This example targets the 'public' schema and includes 'postgis' extension.
```typescript
import { defineConfig } from "drizzle-kit";
export default defineConfig({
dialect: "postgresql",
schema: "./src/schema.ts",
dbCredentials: {
url: "postgresql://user:password@host:port/dbname",
},
extensionsFilters: ["postgis"],
schemaFilter: ["public"],
tablesFilter: ["*"],
});
```
--------------------------------
### Install Encore CLI
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-encore
Install the Encore CLI for macOS, Linux, or Windows.
```bash
# macOS
brew install encoredev/tap/encore
# Linux
curl -L https://encore.dev/install.sh | bash
# Windows
iwr https://encore.dev/install.ps1 | iex
```
--------------------------------
### Perform CRUD Operations with Drizzle ORM and GEL
Source: https://orm.drizzle.team/docs/get-started/gel-existing
This snippet shows a complete example of inserting, selecting, updating, and deleting user data using Drizzle ORM with a GEL client. Ensure you have the necessary schema and client setup.
```typescript
import { eq } from "drizzle-orm";
import { drizzle } from "drizzle-orm/gel";
import { createClient } from "gel";
import { users } from "../drizzle/schema";
const gelClient = createClient();
const db = drizzle({ client: gelClient });
async function main() {
const user: typeof users.$inferInsert = {
name: "John",
age: 30,
email: "john@example.com",
};
await db.insert(users).values(user);
console.log("New user created!");
const usersResponse = await db.select().from(users);
console.log("Getting all users from the database: ", usersResponse);
/*
const users: {
id: number;
name: string;
age: number;
email: string;
}[]
*/
await db
.update(users)
.set({
age: 31,
})
.where(eq(users.email, user.email));
console.log("User info updated!");
await db.delete(users).where(eq(users.email, user.email));
console.log("User deleted!");
}
main();
```
--------------------------------
### Start Netlify Development Server
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-netlify-edge-functions-supabase
Run the Netlify dev command to start the local development server and test edge functions.
```bash
netlify dev
```
--------------------------------
### Install Packages with bun
Source: https://orm.drizzle.team/docs/connect-prisma-postgres
Installs Drizzle ORM and the node-postgres driver using bun. Also installs drizzle-kit as a development dependency.
```bash
bun add drizzle-orm pg
bun add -D drizzle-kit
```
--------------------------------
### Install Valibot
Source: https://orm.drizzle.team/docs/valibot
Install the Valibot library using npm, yarn, pnpm, or bun.
```bash
npm i valibot
```
```bash
yarn add valibot
```
```bash
pnpm add valibot
```
```bash
bun add valibot
```
--------------------------------
### Install Packages with pnpm
Source: https://orm.drizzle.team/docs/connect-prisma-postgres
Installs Drizzle ORM and the node-postgres driver using pnpm. Also installs drizzle-kit as a development dependency.
```bash
pnpm add drizzle-orm pg
pnpm add -D drizzle-kit
```
--------------------------------
### Install PlanetScale Database Driver (yarn)
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-vercel-edge-functions
Install the PlanetScale database driver using yarn.
```bash
yarn add @planetscale/database
```
--------------------------------
### Basic Project File Structure
Source: https://orm.drizzle.team/docs/tutorials/bun-railway-pg
Illustrates a typical project layout with 'src' for database files (db.ts, schema.ts), a 'migrations' directory, and configuration files.
```tree
📦
├ 📂 src
│ ├ 📜 db.ts
│ ├ 📜 schema.ts
│ └ 📜 index.ts
├ 📂 migrations
│ ├ 📂 meta
│ │ ├ 📜 _journal.json
│ │ └ 📜 0000_snapshot.json
│ └ 📜 0000_whole_nomad.sql
├ 📜 .env
├ 📜 drizzle.config.ts
├ 📜 package.json
└ 📜 tsconfig.json
```
--------------------------------
### Install Packages with yarn
Source: https://orm.drizzle.team/docs/connect-prisma-postgres
Installs Drizzle ORM and the node-postgres driver using yarn. Also installs drizzle-kit as a development dependency.
```bash
yarn add drizzle-orm pg
yarn add -D drizzle-kit
```
--------------------------------
### Install Packages with npm
Source: https://orm.drizzle.team/docs/connect-prisma-postgres
Installs Drizzle ORM and the node-postgres driver using npm. Also installs drizzle-kit as a development dependency.
```bash
npm i drizzle-orm pg
npm i -D drizzle-kit
```
--------------------------------
### Install @netlify/edge-functions package (bun)
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-netlify-edge-functions-supabase
Install the @netlify/edge-functions package using bun to import types for the Context object used in Netlify Edge Functions.
```bash
bun add @netlify/edge-functions
```
--------------------------------
### Install Packages with bun
Source: https://orm.drizzle.team/docs/connect-pglite
Installs Drizzle ORM and the PGlite driver using bun. Also installs drizzle-kit as a development dependency.
```bash
bun add drizzle-orm @electric-sql/pglite
bun add -D drizzle-kit
```
--------------------------------
### Run Drizzle Studio with Custom Host (pnpm)
Source: https://orm.drizzle.team/docs/drizzle-kit-studio
Starts the Drizzle Studio server, making it accessible from any network interface using pnpm.
```bash
pnpm drizzle-kit studio --host=0.0.0.0
```
--------------------------------
### Install Packages with pnpm
Source: https://orm.drizzle.team/docs/connect-pglite
Installs Drizzle ORM and the PGlite driver using pnpm. Also installs drizzle-kit as a development dependency.
```bash
pnpm add drizzle-orm @electric-sql/pglite
pnpm add -D drizzle-kit
```
--------------------------------
### Install Packages with yarn
Source: https://orm.drizzle.team/docs/connect-pglite
Installs Drizzle ORM and the PGlite driver using yarn. Also installs drizzle-kit as a development dependency.
```bash
yarn add drizzle-orm @electric-sql/pglite
yarn add -D drizzle-kit
```
--------------------------------
### Install Drizzle and Gel Packages (bun)
Source: https://orm.drizzle.team/docs/get-started/gel-existing
Install the necessary Drizzle ORM and Gel packages using bun.
```bash
bun add drizzle-orm gel
bun add -D drizzle-kit tsx
```
--------------------------------
### Install Packages with npm
Source: https://orm.drizzle.team/docs/connect-pglite
Installs Drizzle ORM and the PGlite driver using npm. Also installs drizzle-kit as a development dependency.
```bash
npm i drizzle-orm @electric-sql/pglite
npm i -D drizzle-kit
```
--------------------------------
### Install Drizzle v1 RC with bun
Source: https://orm.drizzle.team/docs/upgrade-v1
Install the beta versions of drizzle-orm and drizzle-kit using bun.
```bash
bun add drizzle-orm@beta
bun add -D drizzle-kit@beta
```
--------------------------------
### Install Drizzle ORM and Drizzle Kit (npm)
Source: https://orm.drizzle.team/docs/column-types/cockroach
Install the beta versions of Drizzle ORM and Drizzle Kit using npm.
```bash
npm i drizzle-orm@beta
npm i drizzle-kit@beta -D
```
--------------------------------
### Install PostgreSQL Driver with pnpm
Source: https://orm.drizzle.team/docs/tutorials/bun-railway-pg
Install the 'pg' package for PostgreSQL connectivity using pnpm. Also install types for TypeScript support.
```bash
pnpm add pg
pnpm add -D @types/pg
```
--------------------------------
### Install postgres package (bun)
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-supabase
Install the postgres package using bun for connecting to a Postgres database.
```bash
bun add postgres
```
--------------------------------
### Install PostgreSQL Driver with yarn
Source: https://orm.drizzle.team/docs/tutorials/bun-railway-pg
Install the 'pg' package for PostgreSQL connectivity using yarn. Also install types for TypeScript support.
```bash
yarn add pg
yarn add -D @types/pg
```
--------------------------------
### Install PostgreSQL Driver with npm
Source: https://orm.drizzle.team/docs/tutorials/bun-railway-pg
Install the 'pg' package for PostgreSQL connectivity using npm. Also install types for TypeScript support.
```bash
npm i pg
npm i -D @types/pg
```
--------------------------------
### Install Drizzle ORM and Drizzle Kit (yarn)
Source: https://orm.drizzle.team/docs/column-types/cockroach
Install the beta versions of Drizzle ORM and Drizzle Kit using yarn.
```bash
yarn add drizzle-orm@beta
yarn add drizzle-kit@beta -D
```
--------------------------------
### Install Packages with bun
Source: https://orm.drizzle.team/docs/connect-vercel-postgres
Installs the Drizzle ORM and the Vercel Postgres driver using bun. Also installs drizzle-kit as a development dependency.
```bash
bun add drizzle-orm @vercel/postgres
bun add -D drizzle-kit
```
--------------------------------
### Example User Data for Next Page
Source: https://orm.drizzle.team/docs/guides/cursor-based-pagination
Sample JSON output representing the data returned for the next page of users.
```json
[
{
"id": 4,
"firstName": "Brian",
"lastName": "Brown",
"createdAt": "2024-03-08T12:34:55.182Z"
},
{
"id": 5,
"firstName": "Beth",
"lastName": "Davis",
"createdAt": "2024-03-08T12:40:55.182Z"
},
{
"id": 6,
"firstName": "Charlie",
"lastName": "Miller",
"createdAt": "2024-03-08T13:04:55.182Z"
}
]
```
--------------------------------
### Initialize Gel Project (yarn)
Source: https://orm.drizzle.team/docs/get-started/gel-new
Command to initialize a new Gel project using yarn.
```bash
yarn gel project init
```
--------------------------------
### Install Packages with pnpm
Source: https://orm.drizzle.team/docs/connect-vercel-postgres
Installs the Drizzle ORM and the Vercel Postgres driver using pnpm. Also installs drizzle-kit as a development dependency.
```bash
pnpm add drizzle-orm @vercel/postgres
pnpm add -D drizzle-kit
```
--------------------------------
### Run Drizzle Studio with Custom Host (yarn)
Source: https://orm.drizzle.team/docs/drizzle-kit-studio
Starts the Drizzle Studio server, making it accessible from any network interface using yarn.
```bash
yarn drizzle-kit studio --host=0.0.0.0
```
--------------------------------
### Install Packages with bun (postgres.js)
Source: https://orm.drizzle.team/docs/connect-prisma-postgres
Installs Drizzle ORM and the postgres.js driver using bun. Also installs drizzle-kit as a development dependency.
```bash
bun add drizzle-orm postres
bun add -D drizzle-kit
```
--------------------------------
### Install Packages with bun
Source: https://orm.drizzle.team/docs/get-started/sqlite-new
Install Drizzle ORM, libsql client, dotenv, and Drizzle Kit for development.
```bash
bun add drizzle-orm @libsql/client dotenv
bun add -D drizzle-kit tsx
```
--------------------------------
### Install Packages with yarn
Source: https://orm.drizzle.team/docs/connect-vercel-postgres
Installs the Drizzle ORM and the Vercel Postgres driver using yarn. Also installs drizzle-kit as a development dependency.
```bash
yarn add drizzle-orm @vercel/postgres
yarn add -D drizzle-kit
```
--------------------------------
### Install PlanetScale Database Driver (pnpm)
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-vercel-edge-functions
Install the PlanetScale database driver using pnpm.
```bash
pnpm add @planetscale/database
```
--------------------------------
### Install Packages with pnpm (postgres.js)
Source: https://orm.drizzle.team/docs/connect-prisma-postgres
Installs Drizzle ORM and the postgres.js driver using pnpm. Also installs drizzle-kit as a development dependency.
```bash
pnpm add drizzle-orm postres
pnpm add -D drizzle-kit
```
--------------------------------
### Install Packages with npm
Source: https://orm.drizzle.team/docs/connect-vercel-postgres
Installs the Drizzle ORM and the Vercel Postgres driver using npm. Also installs drizzle-kit as a development dependency.
```bash
npm i drizzle-orm @vercel/postgres
npm i -D drizzle-kit
```
--------------------------------
### Run Drizzle Studio with Custom Host and Port (bun)
Source: https://orm.drizzle.team/docs/drizzle-kit-studio
Starts the Drizzle Studio server on a specific host and port using bun.
```bash
bunx drizzle-kit studio --host=0.0.0.0 --port=3000
```
--------------------------------
### Install Packages with yarn (postgres.js)
Source: https://orm.drizzle.team/docs/connect-prisma-postgres
Installs Drizzle ORM and the postgres.js driver using yarn. Also installs drizzle-kit as a development dependency.
```bash
yarn add drizzle-orm postres
yarn add -D drizzle-kit
```
--------------------------------
### Install PlanetScale Database Driver (npm)
Source: https://orm.drizzle.team/docs/tutorials/drizzle-with-vercel-edge-functions
Install the PlanetScale database driver using npm.
```bash
npm i @planetscale/database
```