Skip to content

Commit d953f91

Browse files
committed
Add warning for bun sql
1 parent a6bc943 commit d953f91

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

src/content/docs/_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
["connect-xata", "Xata"],
2626
["connect-pglite", "PGLite"],
2727
["connect-nile", "Nile"],
28+
["connect-bun-sql", "Bun SQL"],
2829
"---",
2930
["connect-planetscale", "PlanetScale"],
3031
["connect-tidb" , "TiDB"],

src/content/docs/connect-bun-sql.mdx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import Npm from "@mdx/Npm.astro";
2+
import Callout from '@mdx/Callout.astro';
3+
import AnchorCards from '@mdx/AnchorCards.astro';
4+
import Steps from '@mdx/Steps.astro';
5+
import WhatsNextPostgres from "@mdx/WhatsNextPostgres.astro";
6+
import Prerequisites from "@mdx/Prerequisites.astro";
7+
import CodeTabs from "@mdx/CodeTabs.astro";
8+
9+
# Drizzle \<\> Bun SQL
10+
11+
<Prerequisites>
12+
- Database [connection basics](/docs/connect-overview) with Drizzle
13+
- Bun - [website](https://bun.sh/docs)
14+
- Bun SQL - native bindings for working with PostgreSQL databases - [read here](https://bun.sh/docs/api/sql)
15+
</Prerequisites>
16+
17+
According to the **[official website](https://bun.sh/)**, Bun is a fast all-in-one JavaScript runtime.
18+
19+
Drizzle ORM natively supports **[`bun sql`](https://bun.sh/docs/api/sql)** module and it's crazy fast 🚀
20+
21+
<Callout type='error'>
22+
In version `1.2.0`, Bun has issues with executing concurrent statements, which may lead to errors if you try to run several queries simultaneously.
23+
We've created a [github issue](https://github.com/oven-sh/bun/issues/16774) that you can track. Once it's fixed, you should no longer encounter any such errors on Bun's SQL side
24+
</Callout>
25+
26+
#### Step 1 - Install packages
27+
<Npm>
28+
drizzle-orm
29+
-D drizzle-kit
30+
</Npm>
31+
32+
#### Step 2 - Initialize the driver and make a query
33+
```typescript copy
34+
import 'dotenv/config';
35+
import { drizzle } from 'drizzle-orm/bun-sql';
36+
37+
const db = drizzle(process.env.DATABASE_URL);
38+
39+
const result = await db.select().from(...);
40+
```
41+
42+
If you need to provide your existing driver:
43+
```typescript copy
44+
import 'dotenv/config';
45+
import { drizzle } from 'drizzle-orm/bun-sql';
46+
import { SQL } from 'bun';
47+
48+
const client = new SQL(process.env.DATABASE_URL!);
49+
const db = drizzle({ client });
50+
```
51+
52+
#### What's next?
53+
54+
<WhatsNextPostgres/>

src/content/docs/get-started/bun-sql-existing.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ import UpdateSchema from '@mdx/get-started/postgresql/UpdateSchema.mdx';
2828
- **Bun SQL** - native bindings for working with PostgreSQL databases - [read here](https://bun.sh/docs/api/sql)
2929
</Prerequisites>
3030

31+
<Callout type='error'>
32+
In version `1.2.0`, Bun has issues with executing concurrent statements, which may lead to errors if you try to run several queries simultaneously.
33+
We've created a [github issue](https://github.com/oven-sh/bun/issues/16774) that you can track. Once it's fixed, you should no longer encounter any such errors on Bun's SQL side
34+
</Callout>
35+
3136
<FileStructure />
3237

3338
#### Step 1 - Install required packages

src/content/docs/get-started/bun-sql-new.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ import ConnectBun from '@mdx/get-started/postgresql/ConnectBun.mdx';
2626
- **Bun SQL** - native bindings for working with PostgreSQL databases - [read here](https://bun.sh/docs/api/sql)
2727
</Prerequisites>
2828

29+
<Callout type='error'>
30+
In version `1.2.0`, Bun has issues with executing concurrent statements, which may lead to errors if you try to run several queries simultaneously.
31+
We've created a [github issue](https://github.com/oven-sh/bun/issues/16774) that you can track. Once it's fixed, you should no longer encounter any such errors on Bun's SQL side
32+
</Callout>
33+
2934
<FileStructure />
3035

3136
#### Step 1 - Install required packages

src/mdx/get-started/postgresql/ConnectBun.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ import 'dotenv/config';
2424
import { drizzle } from 'drizzle-orm/bun-sql';
2525
import { SQL } from 'bun';
2626

27-
const client = new SQL(process.env.DB_FILE_NAME!);
27+
const client = new SQL(process.env.DATABASE_URL!);
2828
const db = drizzle({ client });
2929
```

0 commit comments

Comments
 (0)