Files
ent/entc/integration/migrate/entv1/example_test.go
Alex Snast 4c1f28d58f ent/schema: allow setting collation for string fields
Reviewed By: a8m

Differential Revision: D17090481

fbshipit-source-id: a08768c9bac4318a91bc6a067c85d6eb022c3024
2019-08-28 04:52:32 -07:00

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:
}