mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/72 Reviewed By: alexsn Differential Revision: D17783580 fbshipit-source-id: 597f124a28415fef66b0b16811ad2acac8df631d
45 lines
992 B
Go
45 lines
992 B
Go
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
// This source code is licensed under the Apache 2.0 license found
|
|
// in the LICENSE file in the root directory of this source tree.
|
|
|
|
// Code generated (@generated) by entc, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/facebookincubator/ent/dialect/sql"
|
|
)
|
|
|
|
// dsn for the database. In order to run the tests locally, run the following command:
|
|
//
|
|
// ENT_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().
|
|
SaveX(ctx)
|
|
log.Println("user created:", u)
|
|
|
|
// query edges.
|
|
|
|
// Output:
|
|
}
|