mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
website/blog/entviz: add import on entc.go snippet (#2040)
* blog/entviz: add import on entc.go snippet * Update doc/website/blog/2021-08-26-visualizing-your-data-graph-using-entviz.md Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com> * blog/entviz: full code snippet for `entc.go` Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
This commit is contained in:
@@ -42,9 +42,19 @@ go get github.com/hedwigz/entviz
|
||||
If you are not familiar with `entc` you're welcome to read [entc documentation](https://entgo.io/docs/code-gen#use-entc-as-a-package) to learn more about it.
|
||||
:::
|
||||
```go title="ent/entc.go"
|
||||
err := entc.Generate("./schema", &gen.Config{}, entc.Extensions(entviz.Extension{}))
|
||||
if err != nil {
|
||||
log.Fatalf("running ent codegen: %v", err)
|
||||
import (
|
||||
"log"
|
||||
|
||||
"entgo.io/ent/entc"
|
||||
"entgo.io/ent/entc/gen"
|
||||
"github.com/hedwigz/entviz"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := entc.Generate("./schema", &gen.Config{}, entc.Extensions(entviz.Extension{}))
|
||||
if err != nil {
|
||||
log.Fatalf("running ent codegen: %v", err)
|
||||
}
|
||||
}
|
||||
```
|
||||
Let's say we have a simple schema with a user entity and some fields:
|
||||
|
||||
Reference in New Issue
Block a user