Skip to content

Commit df6d78d

Browse files
committed
update libsql docs, getstarted and fix deprecated drizzle instantiations all around docs
1 parent 34b634b commit df6d78d

30 files changed

+159
-142
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| | |
2+
| :----------------------- | :---------------------------------------------------------------------------------------------------------------------------------------- |
3+
| `@libsql/client` | defaults to `node` import, automatically changes to `web` if `target` or `platofrm` is set for bundler, e.g. `esbuild --platform=browser` |
4+
| `@libsql/client/node` | `node` compatible module, supports `:memory:`, `file`, `wss`, `http` and `turso` conneciton protocols |
5+
| `@libsql/client/web` | module for fullstack web frameworks like `next`, `nuxt`, `astro`, etc. |
6+
| `@libsql/client/http` | module for `http` and `https` connection protocols |
7+
| `@libsql/client/ws` | module for `ws` and `wss` conneciton protocols |
8+
| `@libsql/client/sqlite3` | module for `:memory:` and `file` conneciton protocols |
9+
| `@libsql/client-wasm` | Separate experimental package for WASM |
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import CodeTabs from "@mdx/CodeTabs.astro";
2+
3+
<CodeTabs items={["default", "node", "web", "http", "web sockets", "wasm"]}>
4+
```typescript copy
5+
import { drizzle } from 'drizzle-orm/libsql';
6+
7+
const db = drizzle({ connection: {
8+
url: process.env.DATABASE_URL,
9+
authToken: process.env.DATABASE_AUTH_TOKEN
10+
}});
11+
```
12+
```typescript copy
13+
import { drizzle } from 'drizzle-orm/libsql/node';
14+
15+
const db = drizzle({ connection: {
16+
url: process.env.DATABASE_URL,
17+
authToken: process.env.DATABASE_AUTH_TOKEN
18+
}});
19+
```
20+
```typescript copy
21+
import { drizzle } from 'drizzle-orm/libsql/web';
22+
23+
const db = drizzle({ connection: {
24+
url: process.env.DATABASE_URL,
25+
authToken: process.env.DATABASE_AUTH_TOKEN
26+
}});
27+
```
28+
```typescript copy
29+
import { drizzle } from 'drizzle-orm/libsql/http';
30+
31+
const db = drizzle({ connection: {
32+
url: process.env.DATABASE_URL,
33+
authToken: process.env.DATABASE_AUTH_TOKEN
34+
}});
35+
```
36+
```typescript copy
37+
import { drizzle } from 'drizzle-orm/libsql/ws';
38+
39+
const db = drizzle({ connection: {
40+
url: process.env.DATABASE_URL,
41+
authToken: process.env.DATABASE_AUTH_TOKEN
42+
}});
43+
```
44+
```typescript copy
45+
import { drizzle } from 'drizzle-orm/libsql/wasm';
46+
47+
const db = drizzle({ connection: {
48+
url: process.env.DATABASE_URL,
49+
authToken: process.env.DATABASE_AUTH_TOKEN
50+
}});
51+
```
52+
</CodeTabs>

src/components/markdown/get-started/postgresql/ConnectPostgreSQL.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ import { Pool } from "pg";
3030
const pool = new Pool({
3131
connectionString: process.env.DATABASE_URL!,
3232
});
33-
const db = drizzle(pool);
33+
const db = drizzle({ client: pool });
3434
```
3535
</CodeTabs>

src/components/markdown/get-started/postgresql/ConnectSupabase.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import postgres from 'postgres'
2020

2121
async function main() {
2222
const client = postgres(process.env.DATABASE_URL)
23-
const db = drizzle(client);
23+
const db = drizzle({ client });
2424
}
2525

2626
main();
@@ -36,7 +36,7 @@ import postgres from 'postgres'
3636
async function main() {
3737
// Disable prefetch as it is not supported for "Transaction" pool mode
3838
const client = postgres(process.env.DATABASE_URL, { prepare: false })
39-
const db = drizzle(client);
39+
const db = drizzle({ client });
4040
}
4141

4242
main();

src/content/documentation/docs/connect-overview.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import { Pool } from "pg";
7070
const pool = new Pool({
7171
connectionString: process.env.DATABASE_URL,
7272
});
73-
const db = drizzle(pool); // <--- sync
73+
const db = drizzle({ client: pool });
7474
```
7575
</Section>
7676

@@ -109,7 +109,7 @@ And yes, we do support runtime specific drivers like [Bun SQLite](/docs/connect-
109109
```ts
110110
import { drizzle } from "drizzle-orm/bun:sqlite"
111111

112-
const db = drizzle(); // <--- will create inmemory db
112+
const db = drizzle(); // <--- will create an in-memory db
113113
const db = drizzle("./sqlite.db");
114114
```
115115
```ts

src/content/documentation/docs/connect-turso.mdx

Lines changed: 25 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import Steps from '@components/markdown/Steps.astro';
55
import WhatsNextPostgres from "@mdx/WhatsNextPostgres.astro";
66
import Prerequisites from "@mdx/Prerequisites.astro";
77
import CodeTabs from "@mdx/CodeTabs.astro";
8+
import LibsqlTable from "@mdx/LibsqlTable.mdx";
9+
import LibsqlTabs from "@mdx/LibsqlTabs.mdx";
810

911
# Drizzle \<\> Turso
1012

@@ -27,83 +29,15 @@ drizzle-orm @libsql/client
2729
-D drizzle-kit
2830
</Npm>
2931

30-
#### Step 2 - Initialize the driver and make a query
32+
#### Step 2 - Initialize the driver
3133
Drizzle has native support for all `@libsql/client` driver variations:
3234

33-
| | |
34-
| :----------------------- | :---------------------------------------------------------------------------------------------------------------------------------------- |
35-
| `@libsql/client` | defaults to `node` import, automatically changes to `web` if `target` or `platofrm` is set for bundler, e.g. `esbuild --platform=browser` |
36-
| `@libsql/client/node` | `node` compatible module, supports `:memory:`, `file`, `wss`, `http` and `turso` conneciton protocols |
37-
| `@libsql/client/web` | module for fullstack web frameworks like `next`, `nuxt`, `astro`, etc. |
38-
| `@libsql/client/http` | module for `http` and `https` connection protocols |
39-
| `@libsql/client/ws` | module for `ws` and `wss` conneciton protocols |
40-
| `@libsql/client/sqlite3` | module for `:memory:` and `file` conneciton protocols |
41-
| `@libsql/client-wasm` | Separate experimental package for WASM |
35+
<LibsqlTable />
4236

43-
<br/>
37+
<br />
4438

45-
<CodeTabs items={["default", "node", "web", "http", "web sockets", "wasm"]}>
46-
```typescript copy
47-
import { drizzle } from 'drizzle-orm/libsql';
48-
49-
const db = drizzle({ connection: {
50-
url: process.env.DATABASE_URL,
51-
authToken: process.env.DATABASE_AUTH_TOKEN
52-
}});
53-
54-
const result = await db.select().from(...)
55-
```
56-
```typescript copy
57-
import { drizzle } from 'drizzle-orm/libsql/node';
58-
59-
const db = drizzle({ connection: {
60-
url: process.env.DATABASE_URL,
61-
authToken: process.env.DATABASE_AUTH_TOKEN
62-
}});
39+
<LibsqlTabs />
6340

64-
const result = await db.select().from(...)
65-
```
66-
```typescript copy
67-
import { drizzle } from 'drizzle-orm/libsql/web';
68-
69-
const db = drizzle({ connection: {
70-
url: process.env.DATABASE_URL,
71-
authToken: process.env.DATABASE_AUTH_TOKEN
72-
}});
73-
74-
const result = await db.select().from(...)
75-
```
76-
```typescript copy
77-
import { drizzle } from 'drizzle-orm/libsql/http';
78-
79-
const db = drizzle({ connection: {
80-
url: process.env.DATABASE_URL,
81-
authToken: process.env.DATABASE_AUTH_TOKEN
82-
}});
83-
84-
const result = await db.select().from(...)
85-
```
86-
```typescript copy
87-
import { drizzle } from 'drizzle-orm/libsql/ws';
88-
89-
const db = drizzle({ connection: {
90-
url: process.env.DATABASE_URL,
91-
authToken: process.env.DATABASE_AUTH_TOKEN
92-
}});
93-
94-
const result = await db.select().from(...)
95-
```
96-
```typescript copy
97-
import { drizzle } from 'drizzle-orm/libsql/wasm';
98-
99-
const db = drizzle({ connection: {
100-
url: process.env.DATABASE_URL,
101-
authToken: process.env.DATABASE_AUTH_TOKEN
102-
}});
103-
104-
const result = await db.select().from(...)
105-
```
106-
</CodeTabs>
10741

10842
If you need to provide your existing driver:
10943

@@ -136,6 +70,25 @@ const result = await db.select().from(users).all()
13670
```
13771
</CodeTabs>
13872

73+
#### Step 3 - make a query
74+
75+
```ts
76+
import { drizzle } from 'drizzle-orm/libsql';
77+
import * as s from 'drizzle-orm/sqlite-core';
78+
79+
const db = drizzle({ connection: {
80+
url: process.env.DATABASE_URL,
81+
authToken: process.env.DATABASE_AUTH_TOKEN
82+
}});
83+
84+
const users = s.sqliteTable("users", {
85+
id: s.integer(),
86+
name: s.text(),
87+
})
88+
89+
const result = await db.select().from(users);
90+
```
91+
13992
#### What's next?
14093

14194
<WhatsNextPostgres/>

src/content/documentation/docs/connect-vercel-postgres.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ If you need to provide your existing driver:
5252
import { sql } from '@vercel/postgres';
5353
import { drizzle } from 'drizzle-orm/vercel-postgres';
5454

55-
const db = drizzle(sql)
55+
const db = drizzle({ client: sql })
5656

5757
const result = await db.execute('select 1');
5858
```

src/content/documentation/docs/get-started-sqlite.mdx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import Steps from '@components/markdown/Steps.astro';
55
import Prerequisites from "@mdx/Prerequisites.astro";
66
import CodeTabs from "@mdx/CodeTabs.astro";
77
import WhatsNextPostgres from "@mdx/WhatsNextPostgres.astro";
8+
import LibsqlTable from '@mdx/LibsqlTable.mdx';
9+
import LibsqlTabs from '@mdx/LibsqlTabs.mdx';
810

911
# Drizzle \<\> SQLite
1012

@@ -25,7 +27,14 @@ drizzle-orm @libsql/client
2527
-D drizzle-kit
2628
</Npm>
2729

28-
#### Step 2 - Initialize the driver and make a query
30+
#### Step 2 - Initialize the driver
31+
Drizzle has native support for all @libsql/client driver variations:
32+
33+
<LibsqlTable />
34+
<br/>
35+
<LibsqlTabs />
36+
37+
#### Step 4 - make a query
2938
<CodeTabs items={["libsql", "libsql with config"]}>
3039
```typescript copy
3140
import { drizzle } from 'drizzle-orm/libsql';
@@ -69,7 +78,7 @@ drizzle-orm better-sqlite3
6978
```typescript copy
7079
import { drizzle } from 'drizzle-orm/better-sqlite3';
7180

72-
const db = drizzle( process.env.DATABASE_URL);
81+
const db = drizzle(process.env.DATABASE_URL);
7382

7483
const result = await db.execute('select 1');
7584
```

src/content/documentation/docs/get-started/turso-existing.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import ConnectLibsql from '@mdx/get-started/sqlite/ConnectLibsql.mdx';
1919
import UpdateSchema from '@mdx/get-started/sqlite/UpdateSchema.mdx';
2020
import QueryTurso from '@mdx/get-started/sqlite/QueryTurso.mdx';
2121
import QueryTursoUpdated from '@mdx/get-started/sqlite/QueryTursoUpdated.mdx';
22+
import LibsqlTable from '@mdx/LibsqlTable.mdx';
23+
import LibsqlTabs from '@mdx/LibsqlTabs.mdx';
2224

2325
<Breadcrumbs/>
2426

@@ -81,6 +83,11 @@ export default defineConfig({
8183
<TransferCode/>
8284

8385
#### Step 6 - Connect Drizzle ORM to the database
86+
Drizzle has native support for all @libsql/client driver variations:
87+
88+
<LibsqlTable />
89+
<br/>
90+
<LibsqlTabs />
8491

8592
Create a `index.ts` file in the `src` directory and initialize the connection:
8693

src/content/documentation/docs/get-started/turso-new.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import ApplyChanges from '@mdx/get-started/ApplyChanges.mdx';
1616
import SetupEnv from '@mdx/get-started/SetupEnv.mdx';
1717
import CreateTable from '@mdx/get-started/sqlite/CreateTable.mdx';
1818
import ConnectLibsql from '@mdx/get-started/sqlite/ConnectLibsql.mdx';
19+
import LibsqlTable from '@mdx/LibsqlTable.mdx';
20+
import LibsqlTabs from '@mdx/LibsqlTabs.mdx';
1921

2022
<Breadcrumbs/>
2123

@@ -48,6 +50,11 @@ Check it out [here](https://docs.turso.tech/sdk/ts/quickstart), then return with
4850
</Callout>
4951

5052
#### Step 3 - Connect Drizzle ORM to the database
53+
Drizzle has native support for all @libsql/client driver variations:
54+
55+
<LibsqlTable />
56+
<br/>
57+
<LibsqlTabs />
5158

5259
Create a `index.ts` file in the `src` directory and initialize the connection:
5360

@@ -74,7 +81,7 @@ const client = createClient({
7481
url: process.env.TURSO_DATABASE_URL!,
7582
authToken: process.env.TURSO_AUTH_TOKEN!
7683
});
77-
const db = drizzle(client);
84+
const db = drizzle({ client });
7885
```
7986

8087
#### Step 4 - Create a table

0 commit comments

Comments
 (0)