mirror of
https://github.com/ent/ent.git
synced 2026-04-28 05:30:56 +03:00
dialect/sql/sqlgraph: add builders to create spec (#3288)
This commit is contained in:
@@ -332,6 +332,11 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// NewFieldSpec creates a new FieldSpec with its required fields.
|
||||
func NewFieldSpec(column string, typ field.Type) *FieldSpec {
|
||||
return &FieldSpec{Column: column, Type: typ}
|
||||
}
|
||||
|
||||
// FieldValues returns the values of additional fields that were set on the join-table.
|
||||
func (e *EdgeTarget) FieldValues() []any {
|
||||
vs := make([]any, len(e.Fields))
|
||||
@@ -381,6 +386,11 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// NewCreateSpec creates a new node creation spec.
|
||||
func NewCreateSpec(table string, id *FieldSpec) *CreateSpec {
|
||||
return &CreateSpec{Table: table, ID: id}
|
||||
}
|
||||
|
||||
// SetField appends a new field setter to the creation spec.
|
||||
func (u *CreateSpec) SetField(column string, t field.Type, value driver.Value) {
|
||||
u.Fields = append(u.Fields, &FieldSpec{
|
||||
|
||||
Reference in New Issue
Block a user