Skip to content

Commit

Permalink
Update quickstart + remove prisma (#55)
Browse files Browse the repository at this point in the history
I think we should temporarily remove Prisma from our docs because we
don't fully support it (e.g., time travel debugger doesn't work with
Prisma).

This PR also updates docusaurus version and tweaks the quickstart.
  • Loading branch information
qianl15 authored Feb 22, 2024
1 parent 59c1c34 commit 632c209
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 425 deletions.
2 changes: 1 addition & 1 deletion docs/api-reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DBOS currently only supports Postgres-compatible databases.
- **username**: Username with which to connect to the database.
- **password**: Password with which to connect to the database. We strongly recommend using an environment variable for this field, instead of plain text.
- **app_db_name**: Name of the application database.
- **app_db_client** (optional): Client to use for connecting to the application database. Must be one of `knex`, `prisma`, or `typeorm`. Defaults to `knex`. The client specified here is the one used in [`TransactionContext`](../api-reference/contexts#transactioncontextt).
- **app_db_client** (optional): Client to use for connecting to the application database. Must be either `knex` or `typeorm`. Defaults to `knex`. The client specified here is the one used in [`TransactionContext`](../api-reference/contexts#transactioncontextt).
- **ssl_ca** (optional): If using SSL/TLS to securely connect to a database, path to an SSL root certificate file. Equivalent to the [`sslrootcert`](https://www.postgresql.org/docs/current/libpq-ssl.html) connection parameter in `psql`.
- **connectionTimeoutMillis** (optional): Database connection timeout in milliseconds. Defaults to `3000`.
- **migrate** (optional): A list of commands to run to apply your application's schema to the database. We recommend using a migration tool like those built into [Knex](https://knexjs.org/guide/migrations.html) and [TypeORM](https://typeorm.io/migrations).
Expand Down
24 changes: 7 additions & 17 deletions docs/api-reference/contexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,14 @@ import { EntityManager } from "typeorm";
static async exampleTransaction(ctxt: TransactionContext<EntityManager>, ...)
```
**[Prisma](https://www.prisma.io/docs/concepts/components/prisma-client)**
```typescript
import { PrismaClient } from "@prisma/client";
static async exampleTransaction(ctxt: TransactionContext<Prisma>, ...)
```
### Properties
- [client](#transactionctxtclient)
### transactionCtxt.client
```typescript
client: T; // One of [Knex, EntityManager, PrismaClient]
client: T; // One of [Knex, EntityManager]
```
Provides access to the chosen application database client.
Expand Down Expand Up @@ -504,18 +497,15 @@ The `query` fucntion provides read access to the database. See [Placing Databas
### Placing Database Queries From `MiddlewareContext`
`MiddlewareContext` supports read-only database queries, via a method called `query`. To provide a scoped database connection and to ensure cleanup, the `query` API works via a callback function. The application is to pass in a `qry` function that will be executed in a context with access to the database client `dbclient`. The provided `dbClient` will either be a `Knex`, `PrismaClient`, or TypeORM `EntityManager` depending on the application's choice of SQL access library. This callback function may take arguments, and return a value.
`MiddlewareContext` supports read-only database queries, via a method called `query`. To provide a scoped database connection and to ensure cleanup, the `query` API works via a callback function. The application is to pass in a `qry` function that will be executed in a context with access to the database client `dbclient`. The provided `dbClient` will either be a `Knex` or TypeORM `EntityManager` depending on the application's choice of SQL access library. This callback function may take arguments, and return a value.
Example, for Prisma:
Example, for Knex:
```typescript
const u = await ctx.query(
(dbClient: PrismaClient, uname: string) => {
return dbClient.dbos_test_user.findFirst({
where: {
username: uname,
},
});
// The qry function that takes in a dbClient and a list of arguments (uname in this case)
(dbClient: Knex, uname: string) => {
return dbClient<UserTable>(userTableName).select("username").where({ username: uname })
},
user
userName // Input value for the uname argument
);
```
2 changes: 1 addition & 1 deletion docs/api-reference/testing-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ After your tests finish, [destroy the runtime](#runtimedestroy) to release resou
::::tip

If you use TypeORM, you can use the testing runtime to [create](#runtimecreateuserschema) or [drop](#runtimedropuserschema) your schemas.
If you use Knex or Prisma, you are responsible for setting up schemas/tables and cleaning them up.
If you use Knex, you are responsible for setting up schemas/tables and cleaning them up, for example by using Knex migrations.

::::

Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/quickstart-programming-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ To learn more about HTTP endpoints and handlers, see [our guide](../tutorials/ht

:::info

In this quickstart, we write our database operations in raw SQL (using [knex.raw](https://knexjs.org/guide/raw.html)) to make them easy to follow, but we also support [knex's query builder](https://knexjs.org/guide/query-builder.html) and the popular TypeScript ORMs [Prisma](https://www.prisma.io/) and [TypeORM](https://typeorm.io/).
In this quickstart, we write our database operations in raw SQL (using [knex.raw](https://knexjs.org/guide/raw.html)) to make them easy to follow, but we also support [knex's query builder](https://knexjs.org/guide/query-builder.html) and the popular TypeScript ORM [TypeORM](https://typeorm.io/).

:::

Expand Down
8 changes: 4 additions & 4 deletions docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import TabItem from '@theme/TabItem';

# DBOS SDK Quickstart

Here's how to get a DBOS application up and running in less than five minutes!
Here's how to get a simple DBOS "Hello, Database!" application up and running in less than five minutes!

### System Requirements
The DBOS SDK requires [Node.js 20 or later](https://nodejs.org/en). To install (assuming you don't already have Node.js installed), run the following commands in your terminal:
The DBOS SDK requires [Node.js 20 or later](https://nodejs.org/en). To install (assuming you don't already have Node.js installed), copy and run the following commands in your terminal:

<Tabs groupId="operating-systems">
<TabItem value="mac" label="macOS">
Expand Down Expand Up @@ -47,10 +47,10 @@ This tutorial uses [Docker](https://www.docker.com/) to launch a Postgres databa

<Tabs groupId="operating-systems">
<TabItem value="mac" label="macOS">
The easiest way to install Docker on MacOS is through [Docker Desktop](https://docs.docker.com/desktop/install/mac-install/).
An easy way to install Docker on MacOS is through [Docker Desktop](https://docs.docker.com/desktop/install/mac-install/).
</TabItem>
<TabItem value="win" label="Windows (WSL)">
The easiest way to install Docker on Windows is through [Docker Desktop](https://docs.docker.com/desktop/install/windows-install/).
An easy way to install Docker on Windows is through [Docker Desktop](https://docs.docker.com/desktop/install/windows-install/).
</TabItem>
<TabItem value="ubuntu" label="Ubuntu">
```bash
Expand Down
16 changes: 1 addition & 15 deletions docs/tutorials/demo-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Demo Applications
description: Learn how to build larger apps with DBOS
---

To show you how to develop larger applications with DBOS, we've built three demo applications, each highlighting a different set of DBOS's powerful features.
To show you how to develop larger applications with DBOS, we've built two demo applications, each highlighting a different set of DBOS's powerful features.

## [E-Commerce](https://github.com/dbos-inc/dbos-demo-apps/tree/main/e-commerce)

Expand All @@ -19,20 +19,6 @@ The E-Commerce demo demonstrates:

For more technical details, please see the [Under the Covers](https://github.com/dbos-inc/dbos-demo-apps/blob/main/e-commerce/README.md#under-the-covers) section of the E-Commerce README.

## [Bank](https://github.com/dbos-inc/dbos-demo-apps/tree/main/bank)

The Bank demo is a toy banking app. Users can deposit or withdraw "cash" or transfer money between accounts potentially in different banks.

The Bank demo demonstrates:
* Reliable orchestration of complex workflows involving multiple database transactions and communicators
* Using [Prisma](https://www.prisma.io/) for database interaction and schema management
* Setting an [idempotency key](./idempotency-tutorial.md) in HTTP header for exactly-once cross-bank transactions
* JWT-based authentication through integration with an external [Keycloak](https://www.keycloak.org/) service
* [Declarative security](./authentication-authorization.md)
* Unit tests with the [testing runtime](./testing-tutorial.md)
* Integration with an [Angular](https://angular.io/) frontend


## [YKY Social](https://github.com/dbos-inc/dbos-demo-apps/tree/main/yky-social)
YKY Social is a toy social network app, which allows users to register, create profiles, follow friends, and post messages to each other.

Expand Down
98 changes: 0 additions & 98 deletions docs/tutorials/using-prisma.md

This file was deleted.

Loading

0 comments on commit 632c209

Please sign in to comment.