entc/gen: add type for type edges (#318)

Will be used for adding methods on the struct edges
This commit is contained in:
Ariel Mashraki
2020-01-26 12:39:18 +02:00
committed by GitHub
parent 7c3bcde599
commit bc89ed4e0f
48 changed files with 437 additions and 294 deletions

View File

@@ -23,10 +23,13 @@ type City struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the CityQuery when eager-loading is set.
Edges struct {
// Streets holds the value of the streets edge.
Streets []*Street
} `json:"edges"`
Edges CityEdges `json:"edges"`
}
// CityEdges holds the relations/edges for other nodes in the graph.
type CityEdges struct {
// Streets holds the value of the streets edge.
Streets []*Street
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -23,13 +23,16 @@ type Street struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the StreetQuery when eager-loading is set.
Edges struct {
// City holds the value of the city edge.
City *City
} `json:"edges"`
Edges StreetEdges `json:"edges"`
city_id *int
}
// StreetEdges holds the relations/edges for other nodes in the graph.
type StreetEdges struct {
// City holds the value of the city edge.
City *City
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Street) scanValues() []interface{} {
return []interface{}{

View File

@@ -23,10 +23,13 @@ type Group struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the GroupQuery when eager-loading is set.
Edges struct {
// Users holds the value of the users edge.
Users []*User
} `json:"edges"`
Edges GroupEdges `json:"edges"`
}
// GroupEdges holds the relations/edges for other nodes in the graph.
type GroupEdges struct {
// Users holds the value of the users edge.
Users []*User
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -25,10 +25,13 @@ type User struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Groups holds the value of the groups edge.
Groups []*Group
} `json:"edges"`
Edges UserEdges `json:"edges"`
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Groups holds the value of the groups edge.
Groups []*Group
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -25,10 +25,13 @@ type User struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Friends holds the value of the friends edge.
Friends []*User
} `json:"edges"`
Edges UserEdges `json:"edges"`
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Friends holds the value of the friends edge.
Friends []*User
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -25,12 +25,15 @@ type User struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Followers holds the value of the followers edge.
Followers []*User
// Following holds the value of the following edge.
Following []*User
} `json:"edges"`
Edges UserEdges `json:"edges"`
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Followers holds the value of the followers edge.
Followers []*User
// Following holds the value of the following edge.
Following []*User
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -23,13 +23,16 @@ type Pet struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the PetQuery when eager-loading is set.
Edges struct {
// Owner holds the value of the owner edge.
Owner *User
} `json:"edges"`
Edges PetEdges `json:"edges"`
owner_id *int
}
// PetEdges holds the relations/edges for other nodes in the graph.
type PetEdges struct {
// Owner holds the value of the owner edge.
Owner *User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Pet) scanValues() []interface{} {
return []interface{}{

View File

@@ -25,10 +25,13 @@ type User struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Pets holds the value of the pets edge.
Pets []*Pet
} `json:"edges"`
Edges UserEdges `json:"edges"`
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Pets holds the value of the pets edge.
Pets []*Pet
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -23,15 +23,18 @@ type Node struct {
Value int `json:"value,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the NodeQuery when eager-loading is set.
Edges struct {
// Parent holds the value of the parent edge.
Parent *Node
// Children holds the value of the children edge.
Children []*Node
} `json:"edges"`
Edges NodeEdges `json:"edges"`
parent_id *int
}
// NodeEdges holds the relations/edges for other nodes in the graph.
type NodeEdges struct {
// Parent holds the value of the parent edge.
Parent *Node
// Children holds the value of the children edge.
Children []*Node
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Node) scanValues() []interface{} {
return []interface{}{

View File

@@ -26,13 +26,16 @@ type Card struct {
Number string `json:"number,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the CardQuery when eager-loading is set.
Edges struct {
// Owner holds the value of the owner edge.
Owner *User
} `json:"edges"`
Edges CardEdges `json:"edges"`
owner_id *int
}
// CardEdges holds the relations/edges for other nodes in the graph.
type CardEdges struct {
// Owner holds the value of the owner edge.
Owner *User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Card) scanValues() []interface{} {
return []interface{}{

View File

@@ -25,10 +25,13 @@ type User struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Card holds the value of the card edge.
Card *Card
} `json:"edges"`
Edges UserEdges `json:"edges"`
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Card holds the value of the card edge.
Card *Card
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -25,13 +25,16 @@ type User struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Spouse holds the value of the spouse edge.
Spouse *User
} `json:"edges"`
Edges UserEdges `json:"edges"`
user_spouse_id *int
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Spouse holds the value of the spouse edge.
Spouse *User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*User) scanValues() []interface{} {
return []interface{}{

View File

@@ -23,15 +23,18 @@ type Node struct {
Value int `json:"value,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the NodeQuery when eager-loading is set.
Edges struct {
// Prev holds the value of the prev edge.
Prev *Node
// Next holds the value of the next edge.
Next *Node
} `json:"edges"`
Edges NodeEdges `json:"edges"`
prev_id *int
}
// NodeEdges holds the relations/edges for other nodes in the graph.
type NodeEdges struct {
// Prev holds the value of the prev edge.
Prev *Node
// Next holds the value of the next edge.
Next *Node
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Node) scanValues() []interface{} {
return []interface{}{

View File

@@ -26,13 +26,16 @@ type Car struct {
RegisteredAt time.Time `json:"registered_at,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the CarQuery when eager-loading is set.
Edges struct {
// Owner holds the value of the owner edge.
Owner *User
} `json:"edges"`
Edges CarEdges `json:"edges"`
owner_id *int
}
// CarEdges holds the relations/edges for other nodes in the graph.
type CarEdges struct {
// Owner holds the value of the owner edge.
Owner *User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Car) scanValues() []interface{} {
return []interface{}{

View File

@@ -23,10 +23,13 @@ type Group struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the GroupQuery when eager-loading is set.
Edges struct {
// Users holds the value of the users edge.
Users []*User
} `json:"edges"`
Edges GroupEdges `json:"edges"`
}
// GroupEdges holds the relations/edges for other nodes in the graph.
type GroupEdges struct {
// Users holds the value of the users edge.
Users []*User
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -25,12 +25,15 @@ type User struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Cars holds the value of the cars edge.
Cars []*Car
// Groups holds the value of the groups edge.
Groups []*Group
} `json:"edges"`
Edges UserEdges `json:"edges"`
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Cars holds the value of the cars edge.
Cars []*Car
// Groups holds the value of the groups edge.
Groups []*Group
}
// scanValues returns the types for scanning values from sql.Rows.

View File

@@ -23,15 +23,18 @@ type Group struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the GroupQuery when eager-loading is set.
Edges struct {
// Users holds the value of the users edge.
Users []*User
// Admin holds the value of the admin edge.
Admin *User
} `json:"edges"`
Edges GroupEdges `json:"edges"`
admin_id *int
}
// GroupEdges holds the relations/edges for other nodes in the graph.
type GroupEdges struct {
// Users holds the value of the users edge.
Users []*User
// Admin holds the value of the admin edge.
Admin *User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Group) scanValues() []interface{} {
return []interface{}{

View File

@@ -23,15 +23,18 @@ type Pet struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the PetQuery when eager-loading is set.
Edges struct {
// Friends holds the value of the friends edge.
Friends []*Pet
// Owner holds the value of the owner edge.
Owner *User
} `json:"edges"`
Edges PetEdges `json:"edges"`
owner_id *int
}
// PetEdges holds the relations/edges for other nodes in the graph.
type PetEdges struct {
// Friends holds the value of the friends edge.
Friends []*Pet
// Owner holds the value of the owner edge.
Owner *User
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Pet) scanValues() []interface{} {
return []interface{}{

View File

@@ -25,16 +25,19 @@ type User struct {
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the UserQuery when eager-loading is set.
Edges struct {
// Pets holds the value of the pets edge.
Pets []*Pet
// Friends holds the value of the friends edge.
Friends []*User
// Groups holds the value of the groups edge.
Groups []*Group
// Manage holds the value of the manage edge.
Manage []*Group
} `json:"edges"`
Edges UserEdges `json:"edges"`
}
// UserEdges holds the relations/edges for other nodes in the graph.
type UserEdges struct {
// Pets holds the value of the pets edge.
Pets []*Pet
// Friends holds the value of the friends edge.
Friends []*User
// Groups holds the value of the groups edge.
Groups []*Group
// Manage holds the value of the manage edge.
Manage []*Group
}
// scanValues returns the types for scanning values from sql.Rows.