252 lines
8.3 KiB
Go
252 lines
8.3 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"voidraft/internal/models/ent/keybinding"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// KeyBinding is the model entity for the KeyBinding schema.
|
|
type KeyBinding struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// UUID for cross-device sync (UUIDv7)
|
|
UUID string `json:"uuid"`
|
|
// creation time
|
|
CreatedAt string `json:"created_at"`
|
|
// update time
|
|
UpdatedAt string `json:"updated_at"`
|
|
// deleted at
|
|
DeletedAt *string `json:"deleted_at,omitempty"`
|
|
// command identifier
|
|
Name string `json:"name"`
|
|
// keybinding type: standard or emacs
|
|
Type string `json:"type"`
|
|
// universal keybinding (cross-platform)
|
|
Key string `json:"key,omitempty"`
|
|
// macOS specific keybinding
|
|
Macos string `json:"macos,omitempty"`
|
|
// Windows specific keybinding
|
|
Windows string `json:"windows,omitempty"`
|
|
// Linux specific keybinding
|
|
Linux string `json:"linux,omitempty"`
|
|
// extension name (functional category)
|
|
Extension string `json:"extension"`
|
|
// whether this keybinding is enabled
|
|
Enabled bool `json:"enabled"`
|
|
// prevent browser default behavior
|
|
PreventDefault bool `json:"preventDefault"`
|
|
// keybinding scope (default: editor)
|
|
Scope string `json:"scope,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*KeyBinding) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case keybinding.FieldEnabled, keybinding.FieldPreventDefault:
|
|
values[i] = new(sql.NullBool)
|
|
case keybinding.FieldID:
|
|
values[i] = new(sql.NullInt64)
|
|
case keybinding.FieldUUID, keybinding.FieldCreatedAt, keybinding.FieldUpdatedAt, keybinding.FieldDeletedAt, keybinding.FieldName, keybinding.FieldType, keybinding.FieldKey, keybinding.FieldMacos, keybinding.FieldWindows, keybinding.FieldLinux, keybinding.FieldExtension, keybinding.FieldScope:
|
|
values[i] = new(sql.NullString)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the KeyBinding fields.
|
|
func (_m *KeyBinding) assignValues(columns []string, values []any) error {
|
|
if m, n := len(values), len(columns); m < n {
|
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
|
}
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case keybinding.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
_m.ID = int(value.Int64)
|
|
case keybinding.FieldUUID:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field uuid", values[i])
|
|
} else if value.Valid {
|
|
_m.UUID = value.String
|
|
}
|
|
case keybinding.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
|
} else if value.Valid {
|
|
_m.CreatedAt = value.String
|
|
}
|
|
case keybinding.FieldUpdatedAt:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
|
} else if value.Valid {
|
|
_m.UpdatedAt = value.String
|
|
}
|
|
case keybinding.FieldDeletedAt:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
|
|
} else if value.Valid {
|
|
_m.DeletedAt = new(string)
|
|
*_m.DeletedAt = value.String
|
|
}
|
|
case keybinding.FieldName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
} else if value.Valid {
|
|
_m.Name = value.String
|
|
}
|
|
case keybinding.FieldType:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field type", values[i])
|
|
} else if value.Valid {
|
|
_m.Type = value.String
|
|
}
|
|
case keybinding.FieldKey:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field key", values[i])
|
|
} else if value.Valid {
|
|
_m.Key = value.String
|
|
}
|
|
case keybinding.FieldMacos:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field macos", values[i])
|
|
} else if value.Valid {
|
|
_m.Macos = value.String
|
|
}
|
|
case keybinding.FieldWindows:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field windows", values[i])
|
|
} else if value.Valid {
|
|
_m.Windows = value.String
|
|
}
|
|
case keybinding.FieldLinux:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field linux", values[i])
|
|
} else if value.Valid {
|
|
_m.Linux = value.String
|
|
}
|
|
case keybinding.FieldExtension:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field extension", values[i])
|
|
} else if value.Valid {
|
|
_m.Extension = value.String
|
|
}
|
|
case keybinding.FieldEnabled:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field enabled", values[i])
|
|
} else if value.Valid {
|
|
_m.Enabled = value.Bool
|
|
}
|
|
case keybinding.FieldPreventDefault:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field prevent_default", values[i])
|
|
} else if value.Valid {
|
|
_m.PreventDefault = value.Bool
|
|
}
|
|
case keybinding.FieldScope:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field scope", values[i])
|
|
} else if value.Valid {
|
|
_m.Scope = value.String
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the KeyBinding.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *KeyBinding) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this KeyBinding.
|
|
// Note that you need to call KeyBinding.Unwrap() before calling this method if this KeyBinding
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *KeyBinding) Update() *KeyBindingUpdateOne {
|
|
return NewKeyBindingClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the KeyBinding entity that was returned from a transaction after it was closed,
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
|
func (_m *KeyBinding) Unwrap() *KeyBinding {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: KeyBinding is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *KeyBinding) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("KeyBinding(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("uuid=")
|
|
builder.WriteString(_m.UUID)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(_m.CreatedAt)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(_m.UpdatedAt)
|
|
builder.WriteString(", ")
|
|
if v := _m.DeletedAt; v != nil {
|
|
builder.WriteString("deleted_at=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteString(", ")
|
|
builder.WriteString("name=")
|
|
builder.WriteString(_m.Name)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("type=")
|
|
builder.WriteString(_m.Type)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("key=")
|
|
builder.WriteString(_m.Key)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("macos=")
|
|
builder.WriteString(_m.Macos)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("windows=")
|
|
builder.WriteString(_m.Windows)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("linux=")
|
|
builder.WriteString(_m.Linux)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("extension=")
|
|
builder.WriteString(_m.Extension)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("enabled=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Enabled))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("prevent_default=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.PreventDefault))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("scope=")
|
|
builder.WriteString(_m.Scope)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// KeyBindings is a parsable slice of KeyBinding.
|
|
type KeyBindings []*KeyBinding
|