Skip to content

Commit 0dab776

Browse files
committed
drizzle.mock
1 parent 5594dbb commit 0dab776

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/content/documentation/docs/goodies.mdx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Section from '@mdx/Section.astro';
66
import CodeTabs from '@components/markdown/CodeTabs.astro';
77

88
## Type API
9-
109
To retrieve a type from your table schema for `select` and `insert` queries, you can make use of our type helpers.
1110

1211
<Tabs items={["PostgreSQL","MySQL","SQLite"]}>
@@ -398,3 +397,21 @@ if (is(value, Column)) {
398397
// value's type is narrowed to Column
399398
}
400399
```
400+
401+
### Mock Driver
402+
This API is a successor to `drizzle({} as any)` undefined API which we've used in tests and rarely by other developers.
403+
404+
We decided to build and expose a proper API, every `drizzle` driver now has `drizzle.mock()`:
405+
```ts
406+
import { drizzle } from "drizzle-orm/node-postgres";
407+
408+
const db = drizzle.mock();
409+
```
410+
411+
you can provide schema if necessary for types
412+
```ts
413+
import { drizzle } from "drizzle-orm/node-postgres";
414+
import * as schema from "./schema"
415+
416+
const db = drizzle.mock({ schema });
417+
```

0 commit comments

Comments
 (0)