Skip to content

Commit

Permalink
docs: document SQLDatabase.named for Encore.ts (encoredev#1588)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcus Kohlberg <78424526+marcuskohlberg@users.noreply.github.com>
  • Loading branch information
eandre and marcuskohlberg authored Nov 21, 2024
1 parent 268e27e commit c2c351f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/ts/develop/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ export const signup = api(

// If this is a testing environment, skip sending the verification email.
switch (appMeta().environment.type) {
case ("test", "development"):
case "test":
case "development":
await markEmailVerified(userID);
break;
default:
Expand Down
16 changes: 13 additions & 3 deletions docs/ts/primitives/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ lang: ts

Encore treats SQL databases as logical resources and natively supports **PostgreSQL** databases.

<GitHubLink
href="https://github.com/encoredev/examples/tree/main/ts/url-shortener"
desc="URL Shortener example that uses a PostgreSQL database."
<GitHubLink
href="https://github.com/encoredev/examples/tree/main/ts/url-shortener"
desc="URL Shortener example that uses a PostgreSQL database."
/>

## Creating a database
Expand Down Expand Up @@ -216,6 +216,16 @@ ORMs like [Prisma](/docs/ts/develop/orms/prisma) and [Drizzle](/docs/ts/develop/

For more information on using ORMs with Encore, see the [ORMs](/docs/ts/develop/orms) page.

## Sharing databases between services

There are two primary ways of sharing a database between services:

- You can define the `SQLDatabase` object in a shared module as an exported variable, and reference this object
from every service that needs to access the database.
- You can define the `SQLDatabase` object in one service using `new SQLDatabase("name", ...)`, and have other services access it by creating a reference using `SQLDatabase.named("name")`.

Both approaches have the same effect, but the latter is more explicit.

## PostgreSQL Extensions

Encore uses the [encoredotdev/postgres](https://github.com/encoredev/postgres-image) docker image for local development,
Expand Down

0 comments on commit c2c351f

Please sign in to comment.