https://github.com/steebchen/go-codegen-prototype
context: https://github.com/prisma/photongo/issues/9
https://github.com/steebchen/go-codegen-prototype
Last synced: 10 months ago
JSON representation
context: https://github.com/prisma/photongo/issues/9
- Host: GitHub
- URL: https://github.com/steebchen/go-codegen-prototype
- Owner: steebchen
- Created: 2019-10-11T10:37:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-14T11:31:04.000Z (about 6 years ago)
- Last Synced: 2024-12-31T01:41:41.222Z (12 months ago)
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go codegen minimal prototype
This is a small prototype to show how Photon Go (a generated database client) can help the developer by analyzing complex queries and generating types.
## Usage
Write your query in `example/example.go`:
```go
var result MyQuery1
err = client.Post.Select.Name("MyQuery1").Fields(
Post.Likes.Sum(),
).GroupBy(
Post.Title.Group(),
).Into(&result).Exec(ctx)
if err != nil {
panic(err)
}
```
To generate the structs (i.e. `MyQuery1`), run `go run .` in the project root. This generates `./example/photon/structs_gen.go` with structs for your queries.
When you add or remove query parameters (i.e. `Post.Count()`), you have to re-run `go run .`.
Later, this will be a separate cli tool and/or built-in in the Prisma cli as `prisma generate`.