Skip to content

Commit

Permalink
ORM docs and uuid-ossp extension docs
Browse files Browse the repository at this point in the history
  • Loading branch information
samwillis committed Aug 4, 2024
1 parent a6bbb81 commit 85ffc75
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default defineConfig({
{ text: 'Framework Hooks', link: '/docs/framework-hooks' },
{ text: 'Multi-tab Worker', link: '/docs/multi-tab-worker' },
{ text: 'REPL Component', link: '/docs/repl' },
{ text: 'ORM Support', link: '/docs/orm-support' },
]
},
{
Expand Down
28 changes: 28 additions & 0 deletions docs/docs/orm-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ORM Support

## Drizzle

[Drizzle](https://orm.drizzle.team) is a TypeScript ORM with support for many datbases include PGlite. Features include:

- A declarative realtional query API
- An SQL-like query builder API
- Migrations

To use PGlite with Drizzle just wrap you PGlite instance with a `drizzle()` call:

```sh
npm i drizzle-orm @electric-sql/pglite
npm i -D drizzle-kit
```

```ts
import { PGlite } from '@electric-sql/pglite';
import { drizzle } from 'drizzle-orm/pglite';

const client = new PGlite();
const db = drizzle(client);

await db.select().from(users);
```

See the [Drizzle documentation](https://orm.drizzle.team/docs/get-started-postgresql#pglite) for more details.
25 changes: 21 additions & 4 deletions docs/extensions/extensions.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,19 @@ let baseExtensions: Extension[] = [
importPath: "@electric-sql/pglite/contrib/tsm_system_time",
importName: "tsm_system_time",
},
{
name: "uuid-ossp",
description: `
The uuid-ossp module provides functions to generate universally unique
identifiers (UUIDs) using one of several standard algorithms. There are also
functions to produce certain special UUID constants. This module is only
necessary for special requirements beyond what is available in core PostgreSQL.
`,
docs: "https://www.postgresql.org/docs/current/uuid-ossp.html",
tags: ["postgres extension", "postgres/contrib"],
importPath: "@electric-sql/pglite/contrib/uuid_ossp",
importName: "uuid_ossp",
},
];

const tags = [
Expand Down Expand Up @@ -317,20 +330,24 @@ export default {
if (!descriptionHtml) {
let description = dedent(extension.description).trim();
if (extension.core) {
description += '\n\n' + dedent`
description +=
"\n\n" +
dedent`
\`${extension.name}\` is included in the main PGlite package.
`
`;
} else if (extension.npmPackage) {
description += dedent`
<!-- this comment is a hack to force a new paragraph -->
${"```"}sh
npm install ${extension.npmPackage}
${"```"}
`
`;
}
if (extension.importName && extension.importPath) {
description += '\n\n' + dedent`
description +=
"\n\n" +
dedent`
${"```"}js
import { ${extension.importName} } from '${extension.importPath}';
const pg = new PGlite({
Expand Down

0 comments on commit 85ffc75

Please sign in to comment.