update migrate
This commit is contained in:
28
ent/group.go
28
ent/group.go
@ -3,10 +3,11 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"api/ent/group"
|
||||
"fmt"
|
||||
"strings"
|
||||
"t/ent/group"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
@ -17,9 +18,12 @@ type Group struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Password holds the value of the "password" field.
|
||||
Password string `json:"-"`
|
||||
// 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 GroupEdges `json:"edges"`
|
||||
Edges GroupEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// GroupEdges holds the relations/edges for other nodes in the graph.
|
||||
@ -47,10 +51,10 @@ func (*Group) scanValues(columns []string) ([]any, error) {
|
||||
switch columns[i] {
|
||||
case group.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case group.FieldName:
|
||||
case group.FieldName, group.FieldPassword:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected column %q for type Group", columns[i])
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
@ -76,11 +80,25 @@ func (gr *Group) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
gr.Name = value.String
|
||||
}
|
||||
case group.FieldPassword:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password", values[i])
|
||||
} else if value.Valid {
|
||||
gr.Password = value.String
|
||||
}
|
||||
default:
|
||||
gr.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Group.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (gr *Group) Value(name string) (ent.Value, error) {
|
||||
return gr.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryUsers queries the "users" edge of the Group entity.
|
||||
func (gr *Group) QueryUsers() *UserQuery {
|
||||
return NewGroupClient(gr.config).QueryUsers(gr)
|
||||
@ -111,6 +129,8 @@ func (gr *Group) String() string {
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", gr.ID))
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(gr.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("password=<sensitive>")
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
Reference in New Issue
Block a user