mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Reviewed By: a8m Differential Revision: D17090481 fbshipit-source-id: a08768c9bac4318a91bc6a067c85d6eb022c3024
45 lines
868 B
Go
45 lines
868 B
Go
// Code generated (@generated) by entc, DO NOT EDIT.
|
|
|
|
package entv1
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/facebookincubator/ent/dialect/sql"
|
|
)
|
|
|
|
// dsn for the database. In order to run the tests locally, run the following command:
|
|
//
|
|
// ENTV1_INTEGRATION_ENDPOINT="root:pass@tcp(localhost:3306)/test?parseTime=True" go test -v
|
|
//
|
|
var dsn string
|
|
|
|
func ExampleUser() {
|
|
if dsn == "" {
|
|
return
|
|
}
|
|
ctx := context.Background()
|
|
drv, err := sql.Open("mysql", dsn)
|
|
if err != nil {
|
|
log.Fatalf("failed creating database client: %v", err)
|
|
}
|
|
defer drv.Close()
|
|
client := NewClient(Driver(drv))
|
|
// creating vertices for the user's edges.
|
|
|
|
// create user vertex with its edges.
|
|
u := client.User.
|
|
Create().
|
|
SetAge(1).
|
|
SetName("string").
|
|
SetAddress("string").
|
|
SetRole("string").
|
|
SaveX(ctx)
|
|
log.Println("user created:", u)
|
|
|
|
// query edges.
|
|
|
|
// Output:
|
|
}
|