Skip to content

Commit

Permalink
docs(quickstart): add cloneable repo demo (#1056)
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen authored Oct 24, 2023
1 parent 45eb84c commit be41488
Showing 1 changed file with 53 additions and 5 deletions.
58 changes: 53 additions & 5 deletions docs/pages/docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,57 @@
# Quickstart

## Setup
The fastest way to get started is to [clone the quickstart repository](#use-the-quickstart-repository).
Alternatively, you can go through the [manual below to create a new project from scratch](#manual-setup).

### Initialise a new Go project
## Use the quickstart repository

If you don't have a Go project yet, initialise one using Go modules:
Clone the quickstart repository:

```shell
git clone [email protected]:steebchen/prisma-go-demo.git && cd prisma-go-demo
```

Create the pre-defined SQLite database and generate the Go client:

```shell
go run github.com/steebchen/prisma-client-go db push
```

Finally, run the simple main program at `main.go`:

```shell
go run .
# created post: {
# "id": "ckfnrp7ec0000oh9kygil9s94",
# "createdAt": "2020-09-29T09:37:44.628Z",
# "updatedAt": "2020-09-29T09:37:44.628Z",
# "title": "Hi from Prisma!",
# "published": true,
# "desc": "Prisma is a database toolkit and makes databases easy."
# }
# post: {
# "id": "ckfnrp7ec0000oh9kygil9s94",
# "createdAt": "2020-09-29T09:37:44.628Z",
# "updatedAt": "2020-09-29T09:37:44.628Z",
# "title": "Hi from Prisma!",
# "published": true,
# "desc": "Prisma is a database toolkit and makes databases easy."
# }
# The posts's title is: Prisma is a database toolkit and makes databases easy.
```

### Next steps

We just scratched the surface of what you can do. Read the [advanced tutorial](advanced.md) to learn about more
complex queries and how you can query for relations.

You can also read the full docs at [GoPrisma](https://goprisma.org/docs).

## Manual setup

### Initialize a new Go project

If you don't have a Go project yet, initialize one using Go modules:

```shell script
mkdir demo && cd demo
Expand Down Expand Up @@ -61,7 +108,7 @@ tool [`migrate`](https://www.prisma.io/docs/concepts/components/prisma-migrate)

## Usage

Create a file `main.go`:
Create a file `main.go` (and adapt the import to the db folder if needed):

```go
package main
Expand All @@ -71,6 +118,7 @@ import (
"encoding/json"
"fmt"

// adapt "demo" to your module name if it differs
"demo/db"
)

Expand Down Expand Up @@ -133,7 +181,7 @@ func run() error {
}
```

make sure your go.mod is up to date:
make sure your go.mod is up-to-date:

```
go mod tidy
Expand Down

0 comments on commit be41488

Please sign in to comment.