🚧 Refactor backup service
This commit is contained in:
@@ -16,17 +16,19 @@ type Document 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"`
|
||||
// 删除时间,NULL表示未删除
|
||||
// deleted at
|
||||
DeletedAt *string `json:"deleted_at,omitempty"`
|
||||
// 文档标题
|
||||
// document title
|
||||
Title string `json:"title"`
|
||||
// 文档内容
|
||||
// document content
|
||||
Content string `json:"content"`
|
||||
// 是否锁定
|
||||
// document locked status
|
||||
Locked bool `json:"locked"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
@@ -40,7 +42,7 @@ func (*Document) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullBool)
|
||||
case document.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case document.FieldCreatedAt, document.FieldUpdatedAt, document.FieldDeletedAt, document.FieldTitle, document.FieldContent:
|
||||
case document.FieldUUID, document.FieldCreatedAt, document.FieldUpdatedAt, document.FieldDeletedAt, document.FieldTitle, document.FieldContent:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -63,6 +65,12 @@ func (_m *Document) assignValues(columns []string, values []any) error {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
_m.ID = int(value.Int64)
|
||||
case document.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 document.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
@@ -136,6 +144,9 @@ func (_m *Document) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Document(")
|
||||
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(", ")
|
||||
|
||||
@@ -12,6 +12,8 @@ const (
|
||||
Label = "document"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldUUID holds the string denoting the uuid field in the database.
|
||||
FieldUUID = "uuid"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
@@ -31,6 +33,7 @@ const (
|
||||
// Columns holds all SQL columns for document fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldUUID,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
FieldDeletedAt,
|
||||
@@ -57,6 +60,8 @@ func ValidColumn(column string) bool {
|
||||
var (
|
||||
Hooks [2]ent.Hook
|
||||
Interceptors [1]ent.Interceptor
|
||||
// DefaultUUID holds the default value on creation for the "uuid" field.
|
||||
DefaultUUID func() string
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() string
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
@@ -77,6 +82,11 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUUID orders the results by the uuid field.
|
||||
func ByUUID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUUID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
|
||||
@@ -53,6 +53,11 @@ func IDLTE(id int) predicate.Document {
|
||||
return predicate.Document(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// UUID applies equality check predicate on the "uuid" field. It's identical to UUIDEQ.
|
||||
func UUID(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldEQ(FieldCreatedAt, v))
|
||||
@@ -83,6 +88,81 @@ func Locked(v bool) predicate.Document {
|
||||
return predicate.Document(sql.FieldEQ(FieldLocked, v))
|
||||
}
|
||||
|
||||
// UUIDEQ applies the EQ predicate on the "uuid" field.
|
||||
func UUIDEQ(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDNEQ applies the NEQ predicate on the "uuid" field.
|
||||
func UUIDNEQ(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldNEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDIn applies the In predicate on the "uuid" field.
|
||||
func UUIDIn(vs ...string) predicate.Document {
|
||||
return predicate.Document(sql.FieldIn(FieldUUID, vs...))
|
||||
}
|
||||
|
||||
// UUIDNotIn applies the NotIn predicate on the "uuid" field.
|
||||
func UUIDNotIn(vs ...string) predicate.Document {
|
||||
return predicate.Document(sql.FieldNotIn(FieldUUID, vs...))
|
||||
}
|
||||
|
||||
// UUIDGT applies the GT predicate on the "uuid" field.
|
||||
func UUIDGT(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldGT(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDGTE applies the GTE predicate on the "uuid" field.
|
||||
func UUIDGTE(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldGTE(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDLT applies the LT predicate on the "uuid" field.
|
||||
func UUIDLT(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldLT(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDLTE applies the LTE predicate on the "uuid" field.
|
||||
func UUIDLTE(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldLTE(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDContains applies the Contains predicate on the "uuid" field.
|
||||
func UUIDContains(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldContains(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDHasPrefix applies the HasPrefix predicate on the "uuid" field.
|
||||
func UUIDHasPrefix(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldHasPrefix(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDHasSuffix applies the HasSuffix predicate on the "uuid" field.
|
||||
func UUIDHasSuffix(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldHasSuffix(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDIsNil applies the IsNil predicate on the "uuid" field.
|
||||
func UUIDIsNil() predicate.Document {
|
||||
return predicate.Document(sql.FieldIsNull(FieldUUID))
|
||||
}
|
||||
|
||||
// UUIDNotNil applies the NotNil predicate on the "uuid" field.
|
||||
func UUIDNotNil() predicate.Document {
|
||||
return predicate.Document(sql.FieldNotNull(FieldUUID))
|
||||
}
|
||||
|
||||
// UUIDEqualFold applies the EqualFold predicate on the "uuid" field.
|
||||
func UUIDEqualFold(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldEqualFold(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDContainsFold applies the ContainsFold predicate on the "uuid" field.
|
||||
func UUIDContainsFold(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldContainsFold(FieldUUID, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v string) predicate.Document {
|
||||
return predicate.Document(sql.FieldEQ(FieldCreatedAt, v))
|
||||
|
||||
@@ -19,6 +19,20 @@ type DocumentCreate struct {
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetUUID sets the "uuid" field.
|
||||
func (_c *DocumentCreate) SetUUID(v string) *DocumentCreate {
|
||||
_c.mutation.SetUUID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUUID sets the "uuid" field if the given value is not nil.
|
||||
func (_c *DocumentCreate) SetNillableUUID(v *string) *DocumentCreate {
|
||||
if v != nil {
|
||||
_c.SetUUID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *DocumentCreate) SetCreatedAt(v string) *DocumentCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
@@ -132,6 +146,13 @@ func (_c *DocumentCreate) ExecX(ctx context.Context) {
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *DocumentCreate) defaults() error {
|
||||
if _, ok := _c.mutation.UUID(); !ok {
|
||||
if document.DefaultUUID == nil {
|
||||
return fmt.Errorf("ent: uninitialized document.DefaultUUID (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := document.DefaultUUID()
|
||||
_c.mutation.SetUUID(v)
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
if document.DefaultCreatedAt == nil {
|
||||
return fmt.Errorf("ent: uninitialized document.DefaultCreatedAt (forgotten import ent/runtime?)")
|
||||
@@ -202,6 +223,10 @@ func (_c *DocumentCreate) createSpec() (*Document, *sqlgraph.CreateSpec) {
|
||||
_node = &Document{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(document.Table, sqlgraph.NewFieldSpec(document.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := _c.mutation.UUID(); ok {
|
||||
_spec.SetField(document.FieldUUID, field.TypeString, value)
|
||||
_node.UUID = value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(document.FieldCreatedAt, field.TypeString, value)
|
||||
_node.CreatedAt = value
|
||||
|
||||
@@ -265,12 +265,12 @@ func (_q *DocumentQuery) Clone() *DocumentQuery {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt string `json:"created_at"`
|
||||
// UUID string `json:"uuid"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Document.Query().
|
||||
// GroupBy(document.FieldCreatedAt).
|
||||
// GroupBy(document.FieldUUID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *DocumentQuery) GroupBy(field string, fields ...string) *DocumentGroupBy {
|
||||
@@ -288,11 +288,11 @@ func (_q *DocumentQuery) GroupBy(field string, fields ...string) *DocumentGroupB
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt string `json:"created_at"`
|
||||
// UUID string `json:"uuid"`
|
||||
// }
|
||||
//
|
||||
// client.Document.Query().
|
||||
// Select(document.FieldCreatedAt).
|
||||
// Select(document.FieldUUID).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *DocumentQuery) Select(fields ...string) *DocumentSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -170,6 +170,9 @@ func (_u *DocumentUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if _u.mutation.UUIDCleared() {
|
||||
_spec.ClearField(document.FieldUUID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(document.FieldUpdatedAt, field.TypeString, value)
|
||||
}
|
||||
@@ -385,6 +388,9 @@ func (_u *DocumentUpdateOne) sqlSave(ctx context.Context) (_node *Document, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if _u.mutation.UUIDCleared() {
|
||||
_spec.ClearField(document.FieldUUID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(document.FieldUpdatedAt, field.TypeString, value)
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
},
|
||||
Type: "Document",
|
||||
Fields: map[string]*sqlgraph.FieldSpec{
|
||||
document.FieldUUID: {Type: field.TypeString, Column: document.FieldUUID},
|
||||
document.FieldCreatedAt: {Type: field.TypeString, Column: document.FieldCreatedAt},
|
||||
document.FieldUpdatedAt: {Type: field.TypeString, Column: document.FieldUpdatedAt},
|
||||
document.FieldDeletedAt: {Type: field.TypeString, Column: document.FieldDeletedAt},
|
||||
@@ -47,6 +48,7 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
},
|
||||
Type: "Extension",
|
||||
Fields: map[string]*sqlgraph.FieldSpec{
|
||||
extension.FieldUUID: {Type: field.TypeString, Column: extension.FieldUUID},
|
||||
extension.FieldCreatedAt: {Type: field.TypeString, Column: extension.FieldCreatedAt},
|
||||
extension.FieldUpdatedAt: {Type: field.TypeString, Column: extension.FieldUpdatedAt},
|
||||
extension.FieldDeletedAt: {Type: field.TypeString, Column: extension.FieldDeletedAt},
|
||||
@@ -66,6 +68,7 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
},
|
||||
Type: "KeyBinding",
|
||||
Fields: map[string]*sqlgraph.FieldSpec{
|
||||
keybinding.FieldUUID: {Type: field.TypeString, Column: keybinding.FieldUUID},
|
||||
keybinding.FieldCreatedAt: {Type: field.TypeString, Column: keybinding.FieldCreatedAt},
|
||||
keybinding.FieldUpdatedAt: {Type: field.TypeString, Column: keybinding.FieldUpdatedAt},
|
||||
keybinding.FieldDeletedAt: {Type: field.TypeString, Column: keybinding.FieldDeletedAt},
|
||||
@@ -86,6 +89,7 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
},
|
||||
Type: "Theme",
|
||||
Fields: map[string]*sqlgraph.FieldSpec{
|
||||
theme.FieldUUID: {Type: field.TypeString, Column: theme.FieldUUID},
|
||||
theme.FieldCreatedAt: {Type: field.TypeString, Column: theme.FieldCreatedAt},
|
||||
theme.FieldUpdatedAt: {Type: field.TypeString, Column: theme.FieldUpdatedAt},
|
||||
theme.FieldDeletedAt: {Type: field.TypeString, Column: theme.FieldDeletedAt},
|
||||
@@ -143,6 +147,11 @@ func (f *DocumentFilter) WhereID(p entql.IntP) {
|
||||
f.Where(p.Field(document.FieldID))
|
||||
}
|
||||
|
||||
// WhereUUID applies the entql string predicate on the uuid field.
|
||||
func (f *DocumentFilter) WhereUUID(p entql.StringP) {
|
||||
f.Where(p.Field(document.FieldUUID))
|
||||
}
|
||||
|
||||
// WhereCreatedAt applies the entql string predicate on the created_at field.
|
||||
func (f *DocumentFilter) WhereCreatedAt(p entql.StringP) {
|
||||
f.Where(p.Field(document.FieldCreatedAt))
|
||||
@@ -213,6 +222,11 @@ func (f *ExtensionFilter) WhereID(p entql.IntP) {
|
||||
f.Where(p.Field(extension.FieldID))
|
||||
}
|
||||
|
||||
// WhereUUID applies the entql string predicate on the uuid field.
|
||||
func (f *ExtensionFilter) WhereUUID(p entql.StringP) {
|
||||
f.Where(p.Field(extension.FieldUUID))
|
||||
}
|
||||
|
||||
// WhereCreatedAt applies the entql string predicate on the created_at field.
|
||||
func (f *ExtensionFilter) WhereCreatedAt(p entql.StringP) {
|
||||
f.Where(p.Field(extension.FieldCreatedAt))
|
||||
@@ -283,6 +297,11 @@ func (f *KeyBindingFilter) WhereID(p entql.IntP) {
|
||||
f.Where(p.Field(keybinding.FieldID))
|
||||
}
|
||||
|
||||
// WhereUUID applies the entql string predicate on the uuid field.
|
||||
func (f *KeyBindingFilter) WhereUUID(p entql.StringP) {
|
||||
f.Where(p.Field(keybinding.FieldUUID))
|
||||
}
|
||||
|
||||
// WhereCreatedAt applies the entql string predicate on the created_at field.
|
||||
func (f *KeyBindingFilter) WhereCreatedAt(p entql.StringP) {
|
||||
f.Where(p.Field(keybinding.FieldCreatedAt))
|
||||
@@ -358,6 +377,11 @@ func (f *ThemeFilter) WhereID(p entql.IntP) {
|
||||
f.Where(p.Field(theme.FieldID))
|
||||
}
|
||||
|
||||
// WhereUUID applies the entql string predicate on the uuid field.
|
||||
func (f *ThemeFilter) WhereUUID(p entql.StringP) {
|
||||
f.Where(p.Field(theme.FieldUUID))
|
||||
}
|
||||
|
||||
// WhereCreatedAt applies the entql string predicate on the created_at field.
|
||||
func (f *ThemeFilter) WhereCreatedAt(p entql.StringP) {
|
||||
f.Where(p.Field(theme.FieldCreatedAt))
|
||||
|
||||
@@ -17,17 +17,19 @@ type Extension 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"`
|
||||
// 删除时间,NULL表示未删除
|
||||
// deleted at
|
||||
DeletedAt *string `json:"deleted_at,omitempty"`
|
||||
// 扩展标识符
|
||||
// extension key
|
||||
Key string `json:"key"`
|
||||
// 是否启用
|
||||
// extension enabled or not
|
||||
Enabled bool `json:"enabled"`
|
||||
// 扩展配置
|
||||
// extension config
|
||||
Config map[string]interface{} `json:"config"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
@@ -43,7 +45,7 @@ func (*Extension) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullBool)
|
||||
case extension.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case extension.FieldCreatedAt, extension.FieldUpdatedAt, extension.FieldDeletedAt, extension.FieldKey:
|
||||
case extension.FieldUUID, extension.FieldCreatedAt, extension.FieldUpdatedAt, extension.FieldDeletedAt, extension.FieldKey:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -66,6 +68,12 @@ func (_m *Extension) assignValues(columns []string, values []any) error {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
_m.ID = int(value.Int64)
|
||||
case extension.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 extension.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
@@ -141,6 +149,9 @@ func (_m *Extension) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Extension(")
|
||||
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(", ")
|
||||
|
||||
@@ -12,6 +12,8 @@ const (
|
||||
Label = "extension"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldUUID holds the string denoting the uuid field in the database.
|
||||
FieldUUID = "uuid"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
@@ -31,6 +33,7 @@ const (
|
||||
// Columns holds all SQL columns for extension fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldUUID,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
FieldDeletedAt,
|
||||
@@ -57,6 +60,8 @@ func ValidColumn(column string) bool {
|
||||
var (
|
||||
Hooks [2]ent.Hook
|
||||
Interceptors [1]ent.Interceptor
|
||||
// DefaultUUID holds the default value on creation for the "uuid" field.
|
||||
DefaultUUID func() string
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() string
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
@@ -75,6 +80,11 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUUID orders the results by the uuid field.
|
||||
func ByUUID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUUID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
|
||||
@@ -53,6 +53,11 @@ func IDLTE(id int) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// UUID applies equality check predicate on the "uuid" field. It's identical to UUIDEQ.
|
||||
func UUID(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldEQ(FieldCreatedAt, v))
|
||||
@@ -78,6 +83,81 @@ func Enabled(v bool) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldEQ(FieldEnabled, v))
|
||||
}
|
||||
|
||||
// UUIDEQ applies the EQ predicate on the "uuid" field.
|
||||
func UUIDEQ(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDNEQ applies the NEQ predicate on the "uuid" field.
|
||||
func UUIDNEQ(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldNEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDIn applies the In predicate on the "uuid" field.
|
||||
func UUIDIn(vs ...string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldIn(FieldUUID, vs...))
|
||||
}
|
||||
|
||||
// UUIDNotIn applies the NotIn predicate on the "uuid" field.
|
||||
func UUIDNotIn(vs ...string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldNotIn(FieldUUID, vs...))
|
||||
}
|
||||
|
||||
// UUIDGT applies the GT predicate on the "uuid" field.
|
||||
func UUIDGT(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldGT(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDGTE applies the GTE predicate on the "uuid" field.
|
||||
func UUIDGTE(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldGTE(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDLT applies the LT predicate on the "uuid" field.
|
||||
func UUIDLT(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldLT(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDLTE applies the LTE predicate on the "uuid" field.
|
||||
func UUIDLTE(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldLTE(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDContains applies the Contains predicate on the "uuid" field.
|
||||
func UUIDContains(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldContains(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDHasPrefix applies the HasPrefix predicate on the "uuid" field.
|
||||
func UUIDHasPrefix(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldHasPrefix(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDHasSuffix applies the HasSuffix predicate on the "uuid" field.
|
||||
func UUIDHasSuffix(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldHasSuffix(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDIsNil applies the IsNil predicate on the "uuid" field.
|
||||
func UUIDIsNil() predicate.Extension {
|
||||
return predicate.Extension(sql.FieldIsNull(FieldUUID))
|
||||
}
|
||||
|
||||
// UUIDNotNil applies the NotNil predicate on the "uuid" field.
|
||||
func UUIDNotNil() predicate.Extension {
|
||||
return predicate.Extension(sql.FieldNotNull(FieldUUID))
|
||||
}
|
||||
|
||||
// UUIDEqualFold applies the EqualFold predicate on the "uuid" field.
|
||||
func UUIDEqualFold(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldEqualFold(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDContainsFold applies the ContainsFold predicate on the "uuid" field.
|
||||
func UUIDContainsFold(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldContainsFold(FieldUUID, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v string) predicate.Extension {
|
||||
return predicate.Extension(sql.FieldEQ(FieldCreatedAt, v))
|
||||
|
||||
@@ -19,6 +19,20 @@ type ExtensionCreate struct {
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetUUID sets the "uuid" field.
|
||||
func (_c *ExtensionCreate) SetUUID(v string) *ExtensionCreate {
|
||||
_c.mutation.SetUUID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUUID sets the "uuid" field if the given value is not nil.
|
||||
func (_c *ExtensionCreate) SetNillableUUID(v *string) *ExtensionCreate {
|
||||
if v != nil {
|
||||
_c.SetUUID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *ExtensionCreate) SetCreatedAt(v string) *ExtensionCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
@@ -124,6 +138,13 @@ func (_c *ExtensionCreate) ExecX(ctx context.Context) {
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *ExtensionCreate) defaults() error {
|
||||
if _, ok := _c.mutation.UUID(); !ok {
|
||||
if extension.DefaultUUID == nil {
|
||||
return fmt.Errorf("ent: uninitialized extension.DefaultUUID (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := extension.DefaultUUID()
|
||||
_c.mutation.SetUUID(v)
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
if extension.DefaultCreatedAt == nil {
|
||||
return fmt.Errorf("ent: uninitialized extension.DefaultCreatedAt (forgotten import ent/runtime?)")
|
||||
@@ -190,6 +211,10 @@ func (_c *ExtensionCreate) createSpec() (*Extension, *sqlgraph.CreateSpec) {
|
||||
_node = &Extension{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(extension.Table, sqlgraph.NewFieldSpec(extension.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := _c.mutation.UUID(); ok {
|
||||
_spec.SetField(extension.FieldUUID, field.TypeString, value)
|
||||
_node.UUID = value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(extension.FieldCreatedAt, field.TypeString, value)
|
||||
_node.CreatedAt = value
|
||||
|
||||
@@ -265,12 +265,12 @@ func (_q *ExtensionQuery) Clone() *ExtensionQuery {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt string `json:"created_at"`
|
||||
// UUID string `json:"uuid"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Extension.Query().
|
||||
// GroupBy(extension.FieldCreatedAt).
|
||||
// GroupBy(extension.FieldUUID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ExtensionQuery) GroupBy(field string, fields ...string) *ExtensionGroupBy {
|
||||
@@ -288,11 +288,11 @@ func (_q *ExtensionQuery) GroupBy(field string, fields ...string) *ExtensionGrou
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt string `json:"created_at"`
|
||||
// UUID string `json:"uuid"`
|
||||
// }
|
||||
//
|
||||
// client.Extension.Query().
|
||||
// Select(extension.FieldCreatedAt).
|
||||
// Select(extension.FieldUUID).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ExtensionQuery) Select(fields ...string) *ExtensionSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -162,6 +162,9 @@ func (_u *ExtensionUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if _u.mutation.UUIDCleared() {
|
||||
_spec.ClearField(extension.FieldUUID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(extension.FieldUpdatedAt, field.TypeString, value)
|
||||
}
|
||||
@@ -369,6 +372,9 @@ func (_u *ExtensionUpdateOne) sqlSave(ctx context.Context) (_node *Extension, er
|
||||
}
|
||||
}
|
||||
}
|
||||
if _u.mutation.UUIDCleared() {
|
||||
_spec.ClearField(extension.FieldUUID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(extension.FieldUpdatedAt, field.TypeString, value)
|
||||
}
|
||||
|
||||
@@ -16,19 +16,21 @@ 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"`
|
||||
// 删除时间,NULL表示未删除
|
||||
// deleted at
|
||||
DeletedAt *string `json:"deleted_at,omitempty"`
|
||||
// 快捷键标识符
|
||||
// key binding key
|
||||
Key string `json:"key"`
|
||||
// 快捷键命令
|
||||
// key binding command
|
||||
Command string `json:"command"`
|
||||
// 所属扩展标识符
|
||||
// key binding extension
|
||||
Extension string `json:"extension,omitempty"`
|
||||
// 是否启用
|
||||
// key binding enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
@@ -42,7 +44,7 @@ func (*KeyBinding) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new(sql.NullBool)
|
||||
case keybinding.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case keybinding.FieldCreatedAt, keybinding.FieldUpdatedAt, keybinding.FieldDeletedAt, keybinding.FieldKey, keybinding.FieldCommand, keybinding.FieldExtension:
|
||||
case keybinding.FieldUUID, keybinding.FieldCreatedAt, keybinding.FieldUpdatedAt, keybinding.FieldDeletedAt, keybinding.FieldKey, keybinding.FieldCommand, keybinding.FieldExtension:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -65,6 +67,12 @@ func (_m *KeyBinding) assignValues(columns []string, values []any) error {
|
||||
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])
|
||||
@@ -144,6 +152,9 @@ 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(", ")
|
||||
|
||||
@@ -12,6 +12,8 @@ const (
|
||||
Label = "key_binding"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldUUID holds the string denoting the uuid field in the database.
|
||||
FieldUUID = "uuid"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
@@ -33,6 +35,7 @@ const (
|
||||
// Columns holds all SQL columns for keybinding fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldUUID,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
FieldDeletedAt,
|
||||
@@ -60,6 +63,8 @@ func ValidColumn(column string) bool {
|
||||
var (
|
||||
Hooks [2]ent.Hook
|
||||
Interceptors [1]ent.Interceptor
|
||||
// DefaultUUID holds the default value on creation for the "uuid" field.
|
||||
DefaultUUID func() string
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() string
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
@@ -82,6 +87,11 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUUID orders the results by the uuid field.
|
||||
func ByUUID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUUID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
|
||||
@@ -53,6 +53,11 @@ func IDLTE(id int) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// UUID applies equality check predicate on the "uuid" field. It's identical to UUIDEQ.
|
||||
func UUID(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldEQ(FieldCreatedAt, v))
|
||||
@@ -88,6 +93,81 @@ func Enabled(v bool) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldEQ(FieldEnabled, v))
|
||||
}
|
||||
|
||||
// UUIDEQ applies the EQ predicate on the "uuid" field.
|
||||
func UUIDEQ(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDNEQ applies the NEQ predicate on the "uuid" field.
|
||||
func UUIDNEQ(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldNEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDIn applies the In predicate on the "uuid" field.
|
||||
func UUIDIn(vs ...string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldIn(FieldUUID, vs...))
|
||||
}
|
||||
|
||||
// UUIDNotIn applies the NotIn predicate on the "uuid" field.
|
||||
func UUIDNotIn(vs ...string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldNotIn(FieldUUID, vs...))
|
||||
}
|
||||
|
||||
// UUIDGT applies the GT predicate on the "uuid" field.
|
||||
func UUIDGT(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldGT(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDGTE applies the GTE predicate on the "uuid" field.
|
||||
func UUIDGTE(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldGTE(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDLT applies the LT predicate on the "uuid" field.
|
||||
func UUIDLT(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldLT(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDLTE applies the LTE predicate on the "uuid" field.
|
||||
func UUIDLTE(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldLTE(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDContains applies the Contains predicate on the "uuid" field.
|
||||
func UUIDContains(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldContains(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDHasPrefix applies the HasPrefix predicate on the "uuid" field.
|
||||
func UUIDHasPrefix(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldHasPrefix(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDHasSuffix applies the HasSuffix predicate on the "uuid" field.
|
||||
func UUIDHasSuffix(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldHasSuffix(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDIsNil applies the IsNil predicate on the "uuid" field.
|
||||
func UUIDIsNil() predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldIsNull(FieldUUID))
|
||||
}
|
||||
|
||||
// UUIDNotNil applies the NotNil predicate on the "uuid" field.
|
||||
func UUIDNotNil() predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldNotNull(FieldUUID))
|
||||
}
|
||||
|
||||
// UUIDEqualFold applies the EqualFold predicate on the "uuid" field.
|
||||
func UUIDEqualFold(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldEqualFold(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDContainsFold applies the ContainsFold predicate on the "uuid" field.
|
||||
func UUIDContainsFold(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldContainsFold(FieldUUID, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v string) predicate.KeyBinding {
|
||||
return predicate.KeyBinding(sql.FieldEQ(FieldCreatedAt, v))
|
||||
|
||||
@@ -19,6 +19,20 @@ type KeyBindingCreate struct {
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetUUID sets the "uuid" field.
|
||||
func (_c *KeyBindingCreate) SetUUID(v string) *KeyBindingCreate {
|
||||
_c.mutation.SetUUID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUUID sets the "uuid" field if the given value is not nil.
|
||||
func (_c *KeyBindingCreate) SetNillableUUID(v *string) *KeyBindingCreate {
|
||||
if v != nil {
|
||||
_c.SetUUID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *KeyBindingCreate) SetCreatedAt(v string) *KeyBindingCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
@@ -138,6 +152,13 @@ func (_c *KeyBindingCreate) ExecX(ctx context.Context) {
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *KeyBindingCreate) defaults() error {
|
||||
if _, ok := _c.mutation.UUID(); !ok {
|
||||
if keybinding.DefaultUUID == nil {
|
||||
return fmt.Errorf("ent: uninitialized keybinding.DefaultUUID (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := keybinding.DefaultUUID()
|
||||
_c.mutation.SetUUID(v)
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
if keybinding.DefaultCreatedAt == nil {
|
||||
return fmt.Errorf("ent: uninitialized keybinding.DefaultCreatedAt (forgotten import ent/runtime?)")
|
||||
@@ -217,6 +238,10 @@ func (_c *KeyBindingCreate) createSpec() (*KeyBinding, *sqlgraph.CreateSpec) {
|
||||
_node = &KeyBinding{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(keybinding.Table, sqlgraph.NewFieldSpec(keybinding.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := _c.mutation.UUID(); ok {
|
||||
_spec.SetField(keybinding.FieldUUID, field.TypeString, value)
|
||||
_node.UUID = value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(keybinding.FieldCreatedAt, field.TypeString, value)
|
||||
_node.CreatedAt = value
|
||||
|
||||
@@ -265,12 +265,12 @@ func (_q *KeyBindingQuery) Clone() *KeyBindingQuery {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt string `json:"created_at"`
|
||||
// UUID string `json:"uuid"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.KeyBinding.Query().
|
||||
// GroupBy(keybinding.FieldCreatedAt).
|
||||
// GroupBy(keybinding.FieldUUID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *KeyBindingQuery) GroupBy(field string, fields ...string) *KeyBindingGroupBy {
|
||||
@@ -288,11 +288,11 @@ func (_q *KeyBindingQuery) GroupBy(field string, fields ...string) *KeyBindingGr
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt string `json:"created_at"`
|
||||
// UUID string `json:"uuid"`
|
||||
// }
|
||||
//
|
||||
// client.KeyBinding.Query().
|
||||
// Select(keybinding.FieldCreatedAt).
|
||||
// Select(keybinding.FieldUUID).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *KeyBindingQuery) Select(fields ...string) *KeyBindingSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -194,6 +194,9 @@ func (_u *KeyBindingUpdate) sqlSave(ctx context.Context) (_node int, err error)
|
||||
}
|
||||
}
|
||||
}
|
||||
if _u.mutation.UUIDCleared() {
|
||||
_spec.ClearField(keybinding.FieldUUID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(keybinding.FieldUpdatedAt, field.TypeString, value)
|
||||
}
|
||||
@@ -436,6 +439,9 @@ func (_u *KeyBindingUpdateOne) sqlSave(ctx context.Context) (_node *KeyBinding,
|
||||
}
|
||||
}
|
||||
}
|
||||
if _u.mutation.UUIDCleared() {
|
||||
_spec.ClearField(keybinding.FieldUUID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(keybinding.FieldUpdatedAt, field.TypeString, value)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ var (
|
||||
// DocumentsColumns holds the columns for the "documents" table.
|
||||
DocumentsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "uuid", Type: field.TypeString, Unique: true, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeString},
|
||||
{Name: "updated_at", Type: field.TypeString},
|
||||
{Name: "deleted_at", Type: field.TypeString, Nullable: true},
|
||||
@@ -26,30 +27,36 @@ var (
|
||||
PrimaryKey: []*schema.Column{DocumentsColumns[0]},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "document_deleted_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{DocumentsColumns[3]},
|
||||
},
|
||||
{
|
||||
Name: "document_title",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{DocumentsColumns[4]},
|
||||
},
|
||||
{
|
||||
Name: "document_created_at",
|
||||
Name: "document_uuid",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{DocumentsColumns[1]},
|
||||
},
|
||||
{
|
||||
Name: "document_updated_at",
|
||||
Name: "document_deleted_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{DocumentsColumns[4]},
|
||||
},
|
||||
{
|
||||
Name: "document_title",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{DocumentsColumns[5]},
|
||||
},
|
||||
{
|
||||
Name: "document_created_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{DocumentsColumns[2]},
|
||||
},
|
||||
{
|
||||
Name: "document_updated_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{DocumentsColumns[3]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// ExtensionsColumns holds the columns for the "extensions" table.
|
||||
ExtensionsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "uuid", Type: field.TypeString, Unique: true, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeString},
|
||||
{Name: "updated_at", Type: field.TypeString},
|
||||
{Name: "deleted_at", Type: field.TypeString, Nullable: true},
|
||||
@@ -63,21 +70,27 @@ var (
|
||||
Columns: ExtensionsColumns,
|
||||
PrimaryKey: []*schema.Column{ExtensionsColumns[0]},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "extension_uuid",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ExtensionsColumns[1]},
|
||||
},
|
||||
{
|
||||
Name: "extension_deleted_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ExtensionsColumns[3]},
|
||||
Columns: []*schema.Column{ExtensionsColumns[4]},
|
||||
},
|
||||
{
|
||||
Name: "extension_enabled",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ExtensionsColumns[5]},
|
||||
Columns: []*schema.Column{ExtensionsColumns[6]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// KeyBindingsColumns holds the columns for the "key_bindings" table.
|
||||
KeyBindingsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "uuid", Type: field.TypeString, Unique: true, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeString},
|
||||
{Name: "updated_at", Type: field.TypeString},
|
||||
{Name: "deleted_at", Type: field.TypeString, Nullable: true},
|
||||
@@ -92,26 +105,32 @@ var (
|
||||
Columns: KeyBindingsColumns,
|
||||
PrimaryKey: []*schema.Column{KeyBindingsColumns[0]},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "keybinding_uuid",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{KeyBindingsColumns[1]},
|
||||
},
|
||||
{
|
||||
Name: "keybinding_deleted_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{KeyBindingsColumns[3]},
|
||||
Columns: []*schema.Column{KeyBindingsColumns[4]},
|
||||
},
|
||||
{
|
||||
Name: "keybinding_extension",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{KeyBindingsColumns[6]},
|
||||
Columns: []*schema.Column{KeyBindingsColumns[7]},
|
||||
},
|
||||
{
|
||||
Name: "keybinding_enabled",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{KeyBindingsColumns[7]},
|
||||
Columns: []*schema.Column{KeyBindingsColumns[8]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// ThemesColumns holds the columns for the "themes" table.
|
||||
ThemesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "uuid", Type: field.TypeString, Unique: true, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeString},
|
||||
{Name: "updated_at", Type: field.TypeString},
|
||||
{Name: "deleted_at", Type: field.TypeString, Nullable: true},
|
||||
@@ -125,10 +144,15 @@ var (
|
||||
Columns: ThemesColumns,
|
||||
PrimaryKey: []*schema.Column{ThemesColumns[0]},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "theme_uuid",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ThemesColumns[1]},
|
||||
},
|
||||
{
|
||||
Name: "theme_deleted_at",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{ThemesColumns[3]},
|
||||
Columns: []*schema.Column{ThemesColumns[4]},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ type DocumentMutation struct {
|
||||
op Op
|
||||
typ string
|
||||
id *int
|
||||
uuid *string
|
||||
created_at *string
|
||||
updated_at *string
|
||||
deleted_at *string
|
||||
@@ -148,6 +149,55 @@ func (m *DocumentMutation) IDs(ctx context.Context) ([]int, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetUUID sets the "uuid" field.
|
||||
func (m *DocumentMutation) SetUUID(s string) {
|
||||
m.uuid = &s
|
||||
}
|
||||
|
||||
// UUID returns the value of the "uuid" field in the mutation.
|
||||
func (m *DocumentMutation) UUID() (r string, exists bool) {
|
||||
v := m.uuid
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldUUID returns the old "uuid" field's value of the Document entity.
|
||||
// If the Document object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *DocumentMutation) OldUUID(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldUUID is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldUUID requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldUUID: %w", err)
|
||||
}
|
||||
return oldValue.UUID, nil
|
||||
}
|
||||
|
||||
// ClearUUID clears the value of the "uuid" field.
|
||||
func (m *DocumentMutation) ClearUUID() {
|
||||
m.uuid = nil
|
||||
m.clearedFields[document.FieldUUID] = struct{}{}
|
||||
}
|
||||
|
||||
// UUIDCleared returns if the "uuid" field was cleared in this mutation.
|
||||
func (m *DocumentMutation) UUIDCleared() bool {
|
||||
_, ok := m.clearedFields[document.FieldUUID]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetUUID resets all changes to the "uuid" field.
|
||||
func (m *DocumentMutation) ResetUUID() {
|
||||
m.uuid = nil
|
||||
delete(m.clearedFields, document.FieldUUID)
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (m *DocumentMutation) SetCreatedAt(s string) {
|
||||
m.created_at = &s
|
||||
@@ -424,7 +474,10 @@ func (m *DocumentMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *DocumentMutation) Fields() []string {
|
||||
fields := make([]string, 0, 6)
|
||||
fields := make([]string, 0, 7)
|
||||
if m.uuid != nil {
|
||||
fields = append(fields, document.FieldUUID)
|
||||
}
|
||||
if m.created_at != nil {
|
||||
fields = append(fields, document.FieldCreatedAt)
|
||||
}
|
||||
@@ -451,6 +504,8 @@ func (m *DocumentMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *DocumentMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case document.FieldUUID:
|
||||
return m.UUID()
|
||||
case document.FieldCreatedAt:
|
||||
return m.CreatedAt()
|
||||
case document.FieldUpdatedAt:
|
||||
@@ -472,6 +527,8 @@ func (m *DocumentMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *DocumentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case document.FieldUUID:
|
||||
return m.OldUUID(ctx)
|
||||
case document.FieldCreatedAt:
|
||||
return m.OldCreatedAt(ctx)
|
||||
case document.FieldUpdatedAt:
|
||||
@@ -493,6 +550,13 @@ func (m *DocumentMutation) OldField(ctx context.Context, name string) (ent.Value
|
||||
// type.
|
||||
func (m *DocumentMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case document.FieldUUID:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetUUID(v)
|
||||
return nil
|
||||
case document.FieldCreatedAt:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
@@ -565,6 +629,9 @@ func (m *DocumentMutation) AddField(name string, value ent.Value) error {
|
||||
// mutation.
|
||||
func (m *DocumentMutation) ClearedFields() []string {
|
||||
var fields []string
|
||||
if m.FieldCleared(document.FieldUUID) {
|
||||
fields = append(fields, document.FieldUUID)
|
||||
}
|
||||
if m.FieldCleared(document.FieldDeletedAt) {
|
||||
fields = append(fields, document.FieldDeletedAt)
|
||||
}
|
||||
@@ -585,6 +652,9 @@ func (m *DocumentMutation) FieldCleared(name string) bool {
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *DocumentMutation) ClearField(name string) error {
|
||||
switch name {
|
||||
case document.FieldUUID:
|
||||
m.ClearUUID()
|
||||
return nil
|
||||
case document.FieldDeletedAt:
|
||||
m.ClearDeletedAt()
|
||||
return nil
|
||||
@@ -599,6 +669,9 @@ func (m *DocumentMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *DocumentMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case document.FieldUUID:
|
||||
m.ResetUUID()
|
||||
return nil
|
||||
case document.FieldCreatedAt:
|
||||
m.ResetCreatedAt()
|
||||
return nil
|
||||
@@ -675,6 +748,7 @@ type ExtensionMutation struct {
|
||||
op Op
|
||||
typ string
|
||||
id *int
|
||||
uuid *string
|
||||
created_at *string
|
||||
updated_at *string
|
||||
deleted_at *string
|
||||
@@ -785,6 +859,55 @@ func (m *ExtensionMutation) IDs(ctx context.Context) ([]int, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetUUID sets the "uuid" field.
|
||||
func (m *ExtensionMutation) SetUUID(s string) {
|
||||
m.uuid = &s
|
||||
}
|
||||
|
||||
// UUID returns the value of the "uuid" field in the mutation.
|
||||
func (m *ExtensionMutation) UUID() (r string, exists bool) {
|
||||
v := m.uuid
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldUUID returns the old "uuid" field's value of the Extension entity.
|
||||
// If the Extension object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *ExtensionMutation) OldUUID(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldUUID is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldUUID requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldUUID: %w", err)
|
||||
}
|
||||
return oldValue.UUID, nil
|
||||
}
|
||||
|
||||
// ClearUUID clears the value of the "uuid" field.
|
||||
func (m *ExtensionMutation) ClearUUID() {
|
||||
m.uuid = nil
|
||||
m.clearedFields[extension.FieldUUID] = struct{}{}
|
||||
}
|
||||
|
||||
// UUIDCleared returns if the "uuid" field was cleared in this mutation.
|
||||
func (m *ExtensionMutation) UUIDCleared() bool {
|
||||
_, ok := m.clearedFields[extension.FieldUUID]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetUUID resets all changes to the "uuid" field.
|
||||
func (m *ExtensionMutation) ResetUUID() {
|
||||
m.uuid = nil
|
||||
delete(m.clearedFields, extension.FieldUUID)
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (m *ExtensionMutation) SetCreatedAt(s string) {
|
||||
m.created_at = &s
|
||||
@@ -1061,7 +1184,10 @@ func (m *ExtensionMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *ExtensionMutation) Fields() []string {
|
||||
fields := make([]string, 0, 6)
|
||||
fields := make([]string, 0, 7)
|
||||
if m.uuid != nil {
|
||||
fields = append(fields, extension.FieldUUID)
|
||||
}
|
||||
if m.created_at != nil {
|
||||
fields = append(fields, extension.FieldCreatedAt)
|
||||
}
|
||||
@@ -1088,6 +1214,8 @@ func (m *ExtensionMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *ExtensionMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case extension.FieldUUID:
|
||||
return m.UUID()
|
||||
case extension.FieldCreatedAt:
|
||||
return m.CreatedAt()
|
||||
case extension.FieldUpdatedAt:
|
||||
@@ -1109,6 +1237,8 @@ func (m *ExtensionMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *ExtensionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case extension.FieldUUID:
|
||||
return m.OldUUID(ctx)
|
||||
case extension.FieldCreatedAt:
|
||||
return m.OldCreatedAt(ctx)
|
||||
case extension.FieldUpdatedAt:
|
||||
@@ -1130,6 +1260,13 @@ func (m *ExtensionMutation) OldField(ctx context.Context, name string) (ent.Valu
|
||||
// type.
|
||||
func (m *ExtensionMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case extension.FieldUUID:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetUUID(v)
|
||||
return nil
|
||||
case extension.FieldCreatedAt:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
@@ -1202,6 +1339,9 @@ func (m *ExtensionMutation) AddField(name string, value ent.Value) error {
|
||||
// mutation.
|
||||
func (m *ExtensionMutation) ClearedFields() []string {
|
||||
var fields []string
|
||||
if m.FieldCleared(extension.FieldUUID) {
|
||||
fields = append(fields, extension.FieldUUID)
|
||||
}
|
||||
if m.FieldCleared(extension.FieldDeletedAt) {
|
||||
fields = append(fields, extension.FieldDeletedAt)
|
||||
}
|
||||
@@ -1222,6 +1362,9 @@ func (m *ExtensionMutation) FieldCleared(name string) bool {
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *ExtensionMutation) ClearField(name string) error {
|
||||
switch name {
|
||||
case extension.FieldUUID:
|
||||
m.ClearUUID()
|
||||
return nil
|
||||
case extension.FieldDeletedAt:
|
||||
m.ClearDeletedAt()
|
||||
return nil
|
||||
@@ -1236,6 +1379,9 @@ func (m *ExtensionMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *ExtensionMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case extension.FieldUUID:
|
||||
m.ResetUUID()
|
||||
return nil
|
||||
case extension.FieldCreatedAt:
|
||||
m.ResetCreatedAt()
|
||||
return nil
|
||||
@@ -1312,6 +1458,7 @@ type KeyBindingMutation struct {
|
||||
op Op
|
||||
typ string
|
||||
id *int
|
||||
uuid *string
|
||||
created_at *string
|
||||
updated_at *string
|
||||
deleted_at *string
|
||||
@@ -1423,6 +1570,55 @@ func (m *KeyBindingMutation) IDs(ctx context.Context) ([]int, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetUUID sets the "uuid" field.
|
||||
func (m *KeyBindingMutation) SetUUID(s string) {
|
||||
m.uuid = &s
|
||||
}
|
||||
|
||||
// UUID returns the value of the "uuid" field in the mutation.
|
||||
func (m *KeyBindingMutation) UUID() (r string, exists bool) {
|
||||
v := m.uuid
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldUUID returns the old "uuid" field's value of the KeyBinding entity.
|
||||
// If the KeyBinding object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *KeyBindingMutation) OldUUID(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldUUID is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldUUID requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldUUID: %w", err)
|
||||
}
|
||||
return oldValue.UUID, nil
|
||||
}
|
||||
|
||||
// ClearUUID clears the value of the "uuid" field.
|
||||
func (m *KeyBindingMutation) ClearUUID() {
|
||||
m.uuid = nil
|
||||
m.clearedFields[keybinding.FieldUUID] = struct{}{}
|
||||
}
|
||||
|
||||
// UUIDCleared returns if the "uuid" field was cleared in this mutation.
|
||||
func (m *KeyBindingMutation) UUIDCleared() bool {
|
||||
_, ok := m.clearedFields[keybinding.FieldUUID]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetUUID resets all changes to the "uuid" field.
|
||||
func (m *KeyBindingMutation) ResetUUID() {
|
||||
m.uuid = nil
|
||||
delete(m.clearedFields, keybinding.FieldUUID)
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (m *KeyBindingMutation) SetCreatedAt(s string) {
|
||||
m.created_at = &s
|
||||
@@ -1735,7 +1931,10 @@ func (m *KeyBindingMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *KeyBindingMutation) Fields() []string {
|
||||
fields := make([]string, 0, 7)
|
||||
fields := make([]string, 0, 8)
|
||||
if m.uuid != nil {
|
||||
fields = append(fields, keybinding.FieldUUID)
|
||||
}
|
||||
if m.created_at != nil {
|
||||
fields = append(fields, keybinding.FieldCreatedAt)
|
||||
}
|
||||
@@ -1765,6 +1964,8 @@ func (m *KeyBindingMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *KeyBindingMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case keybinding.FieldUUID:
|
||||
return m.UUID()
|
||||
case keybinding.FieldCreatedAt:
|
||||
return m.CreatedAt()
|
||||
case keybinding.FieldUpdatedAt:
|
||||
@@ -1788,6 +1989,8 @@ func (m *KeyBindingMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *KeyBindingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case keybinding.FieldUUID:
|
||||
return m.OldUUID(ctx)
|
||||
case keybinding.FieldCreatedAt:
|
||||
return m.OldCreatedAt(ctx)
|
||||
case keybinding.FieldUpdatedAt:
|
||||
@@ -1811,6 +2014,13 @@ func (m *KeyBindingMutation) OldField(ctx context.Context, name string) (ent.Val
|
||||
// type.
|
||||
func (m *KeyBindingMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case keybinding.FieldUUID:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetUUID(v)
|
||||
return nil
|
||||
case keybinding.FieldCreatedAt:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
@@ -1890,6 +2100,9 @@ func (m *KeyBindingMutation) AddField(name string, value ent.Value) error {
|
||||
// mutation.
|
||||
func (m *KeyBindingMutation) ClearedFields() []string {
|
||||
var fields []string
|
||||
if m.FieldCleared(keybinding.FieldUUID) {
|
||||
fields = append(fields, keybinding.FieldUUID)
|
||||
}
|
||||
if m.FieldCleared(keybinding.FieldDeletedAt) {
|
||||
fields = append(fields, keybinding.FieldDeletedAt)
|
||||
}
|
||||
@@ -1910,6 +2123,9 @@ func (m *KeyBindingMutation) FieldCleared(name string) bool {
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *KeyBindingMutation) ClearField(name string) error {
|
||||
switch name {
|
||||
case keybinding.FieldUUID:
|
||||
m.ClearUUID()
|
||||
return nil
|
||||
case keybinding.FieldDeletedAt:
|
||||
m.ClearDeletedAt()
|
||||
return nil
|
||||
@@ -1924,6 +2140,9 @@ func (m *KeyBindingMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *KeyBindingMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case keybinding.FieldUUID:
|
||||
m.ResetUUID()
|
||||
return nil
|
||||
case keybinding.FieldCreatedAt:
|
||||
m.ResetCreatedAt()
|
||||
return nil
|
||||
@@ -2003,6 +2222,7 @@ type ThemeMutation struct {
|
||||
op Op
|
||||
typ string
|
||||
id *int
|
||||
uuid *string
|
||||
created_at *string
|
||||
updated_at *string
|
||||
deleted_at *string
|
||||
@@ -2113,6 +2333,55 @@ func (m *ThemeMutation) IDs(ctx context.Context) ([]int, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetUUID sets the "uuid" field.
|
||||
func (m *ThemeMutation) SetUUID(s string) {
|
||||
m.uuid = &s
|
||||
}
|
||||
|
||||
// UUID returns the value of the "uuid" field in the mutation.
|
||||
func (m *ThemeMutation) UUID() (r string, exists bool) {
|
||||
v := m.uuid
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldUUID returns the old "uuid" field's value of the Theme entity.
|
||||
// If the Theme object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *ThemeMutation) OldUUID(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldUUID is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldUUID requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldUUID: %w", err)
|
||||
}
|
||||
return oldValue.UUID, nil
|
||||
}
|
||||
|
||||
// ClearUUID clears the value of the "uuid" field.
|
||||
func (m *ThemeMutation) ClearUUID() {
|
||||
m.uuid = nil
|
||||
m.clearedFields[theme.FieldUUID] = struct{}{}
|
||||
}
|
||||
|
||||
// UUIDCleared returns if the "uuid" field was cleared in this mutation.
|
||||
func (m *ThemeMutation) UUIDCleared() bool {
|
||||
_, ok := m.clearedFields[theme.FieldUUID]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetUUID resets all changes to the "uuid" field.
|
||||
func (m *ThemeMutation) ResetUUID() {
|
||||
m.uuid = nil
|
||||
delete(m.clearedFields, theme.FieldUUID)
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (m *ThemeMutation) SetCreatedAt(s string) {
|
||||
m.created_at = &s
|
||||
@@ -2389,7 +2658,10 @@ func (m *ThemeMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *ThemeMutation) Fields() []string {
|
||||
fields := make([]string, 0, 6)
|
||||
fields := make([]string, 0, 7)
|
||||
if m.uuid != nil {
|
||||
fields = append(fields, theme.FieldUUID)
|
||||
}
|
||||
if m.created_at != nil {
|
||||
fields = append(fields, theme.FieldCreatedAt)
|
||||
}
|
||||
@@ -2416,6 +2688,8 @@ func (m *ThemeMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *ThemeMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case theme.FieldUUID:
|
||||
return m.UUID()
|
||||
case theme.FieldCreatedAt:
|
||||
return m.CreatedAt()
|
||||
case theme.FieldUpdatedAt:
|
||||
@@ -2437,6 +2711,8 @@ func (m *ThemeMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *ThemeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case theme.FieldUUID:
|
||||
return m.OldUUID(ctx)
|
||||
case theme.FieldCreatedAt:
|
||||
return m.OldCreatedAt(ctx)
|
||||
case theme.FieldUpdatedAt:
|
||||
@@ -2458,6 +2734,13 @@ func (m *ThemeMutation) OldField(ctx context.Context, name string) (ent.Value, e
|
||||
// type.
|
||||
func (m *ThemeMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case theme.FieldUUID:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetUUID(v)
|
||||
return nil
|
||||
case theme.FieldCreatedAt:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
@@ -2530,6 +2813,9 @@ func (m *ThemeMutation) AddField(name string, value ent.Value) error {
|
||||
// mutation.
|
||||
func (m *ThemeMutation) ClearedFields() []string {
|
||||
var fields []string
|
||||
if m.FieldCleared(theme.FieldUUID) {
|
||||
fields = append(fields, theme.FieldUUID)
|
||||
}
|
||||
if m.FieldCleared(theme.FieldDeletedAt) {
|
||||
fields = append(fields, theme.FieldDeletedAt)
|
||||
}
|
||||
@@ -2550,6 +2836,9 @@ func (m *ThemeMutation) FieldCleared(name string) bool {
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *ThemeMutation) ClearField(name string) error {
|
||||
switch name {
|
||||
case theme.FieldUUID:
|
||||
m.ClearUUID()
|
||||
return nil
|
||||
case theme.FieldDeletedAt:
|
||||
m.ClearDeletedAt()
|
||||
return nil
|
||||
@@ -2564,6 +2853,9 @@ func (m *ThemeMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *ThemeMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case theme.FieldUUID:
|
||||
m.ResetUUID()
|
||||
return nil
|
||||
case theme.FieldCreatedAt:
|
||||
m.ResetCreatedAt()
|
||||
return nil
|
||||
|
||||
@@ -15,22 +15,28 @@ import (
|
||||
// to their package variables.
|
||||
func init() {
|
||||
documentMixin := schema.Document{}.Mixin()
|
||||
documentMixinHooks0 := documentMixin[0].Hooks()
|
||||
documentMixinHooks1 := documentMixin[1].Hooks()
|
||||
document.Hooks[0] = documentMixinHooks0[0]
|
||||
document.Hooks[1] = documentMixinHooks1[0]
|
||||
documentMixinInters1 := documentMixin[1].Interceptors()
|
||||
document.Interceptors[0] = documentMixinInters1[0]
|
||||
documentMixinHooks2 := documentMixin[2].Hooks()
|
||||
document.Hooks[0] = documentMixinHooks1[0]
|
||||
document.Hooks[1] = documentMixinHooks2[0]
|
||||
documentMixinInters2 := documentMixin[2].Interceptors()
|
||||
document.Interceptors[0] = documentMixinInters2[0]
|
||||
documentMixinFields0 := documentMixin[0].Fields()
|
||||
_ = documentMixinFields0
|
||||
documentMixinFields1 := documentMixin[1].Fields()
|
||||
_ = documentMixinFields1
|
||||
documentFields := schema.Document{}.Fields()
|
||||
_ = documentFields
|
||||
// documentDescUUID is the schema descriptor for uuid field.
|
||||
documentDescUUID := documentMixinFields0[0].Descriptor()
|
||||
// document.DefaultUUID holds the default value on creation for the uuid field.
|
||||
document.DefaultUUID = documentDescUUID.Default.(func() string)
|
||||
// documentDescCreatedAt is the schema descriptor for created_at field.
|
||||
documentDescCreatedAt := documentMixinFields0[0].Descriptor()
|
||||
documentDescCreatedAt := documentMixinFields1[0].Descriptor()
|
||||
// document.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
document.DefaultCreatedAt = documentDescCreatedAt.Default.(func() string)
|
||||
// documentDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
documentDescUpdatedAt := documentMixinFields0[1].Descriptor()
|
||||
documentDescUpdatedAt := documentMixinFields1[1].Descriptor()
|
||||
// document.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
document.DefaultUpdatedAt = documentDescUpdatedAt.Default.(func() string)
|
||||
// documentDescTitle is the schema descriptor for title field.
|
||||
@@ -60,22 +66,28 @@ func init() {
|
||||
// document.DefaultLocked holds the default value on creation for the locked field.
|
||||
document.DefaultLocked = documentDescLocked.Default.(bool)
|
||||
extensionMixin := schema.Extension{}.Mixin()
|
||||
extensionMixinHooks0 := extensionMixin[0].Hooks()
|
||||
extensionMixinHooks1 := extensionMixin[1].Hooks()
|
||||
extension.Hooks[0] = extensionMixinHooks0[0]
|
||||
extension.Hooks[1] = extensionMixinHooks1[0]
|
||||
extensionMixinInters1 := extensionMixin[1].Interceptors()
|
||||
extension.Interceptors[0] = extensionMixinInters1[0]
|
||||
extensionMixinHooks2 := extensionMixin[2].Hooks()
|
||||
extension.Hooks[0] = extensionMixinHooks1[0]
|
||||
extension.Hooks[1] = extensionMixinHooks2[0]
|
||||
extensionMixinInters2 := extensionMixin[2].Interceptors()
|
||||
extension.Interceptors[0] = extensionMixinInters2[0]
|
||||
extensionMixinFields0 := extensionMixin[0].Fields()
|
||||
_ = extensionMixinFields0
|
||||
extensionMixinFields1 := extensionMixin[1].Fields()
|
||||
_ = extensionMixinFields1
|
||||
extensionFields := schema.Extension{}.Fields()
|
||||
_ = extensionFields
|
||||
// extensionDescUUID is the schema descriptor for uuid field.
|
||||
extensionDescUUID := extensionMixinFields0[0].Descriptor()
|
||||
// extension.DefaultUUID holds the default value on creation for the uuid field.
|
||||
extension.DefaultUUID = extensionDescUUID.Default.(func() string)
|
||||
// extensionDescCreatedAt is the schema descriptor for created_at field.
|
||||
extensionDescCreatedAt := extensionMixinFields0[0].Descriptor()
|
||||
extensionDescCreatedAt := extensionMixinFields1[0].Descriptor()
|
||||
// extension.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
extension.DefaultCreatedAt = extensionDescCreatedAt.Default.(func() string)
|
||||
// extensionDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
extensionDescUpdatedAt := extensionMixinFields0[1].Descriptor()
|
||||
extensionDescUpdatedAt := extensionMixinFields1[1].Descriptor()
|
||||
// extension.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
extension.DefaultUpdatedAt = extensionDescUpdatedAt.Default.(func() string)
|
||||
// extensionDescKey is the schema descriptor for key field.
|
||||
@@ -101,22 +113,28 @@ func init() {
|
||||
// extension.DefaultEnabled holds the default value on creation for the enabled field.
|
||||
extension.DefaultEnabled = extensionDescEnabled.Default.(bool)
|
||||
keybindingMixin := schema.KeyBinding{}.Mixin()
|
||||
keybindingMixinHooks0 := keybindingMixin[0].Hooks()
|
||||
keybindingMixinHooks1 := keybindingMixin[1].Hooks()
|
||||
keybinding.Hooks[0] = keybindingMixinHooks0[0]
|
||||
keybinding.Hooks[1] = keybindingMixinHooks1[0]
|
||||
keybindingMixinInters1 := keybindingMixin[1].Interceptors()
|
||||
keybinding.Interceptors[0] = keybindingMixinInters1[0]
|
||||
keybindingMixinHooks2 := keybindingMixin[2].Hooks()
|
||||
keybinding.Hooks[0] = keybindingMixinHooks1[0]
|
||||
keybinding.Hooks[1] = keybindingMixinHooks2[0]
|
||||
keybindingMixinInters2 := keybindingMixin[2].Interceptors()
|
||||
keybinding.Interceptors[0] = keybindingMixinInters2[0]
|
||||
keybindingMixinFields0 := keybindingMixin[0].Fields()
|
||||
_ = keybindingMixinFields0
|
||||
keybindingMixinFields1 := keybindingMixin[1].Fields()
|
||||
_ = keybindingMixinFields1
|
||||
keybindingFields := schema.KeyBinding{}.Fields()
|
||||
_ = keybindingFields
|
||||
// keybindingDescUUID is the schema descriptor for uuid field.
|
||||
keybindingDescUUID := keybindingMixinFields0[0].Descriptor()
|
||||
// keybinding.DefaultUUID holds the default value on creation for the uuid field.
|
||||
keybinding.DefaultUUID = keybindingDescUUID.Default.(func() string)
|
||||
// keybindingDescCreatedAt is the schema descriptor for created_at field.
|
||||
keybindingDescCreatedAt := keybindingMixinFields0[0].Descriptor()
|
||||
keybindingDescCreatedAt := keybindingMixinFields1[0].Descriptor()
|
||||
// keybinding.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
keybinding.DefaultCreatedAt = keybindingDescCreatedAt.Default.(func() string)
|
||||
// keybindingDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
keybindingDescUpdatedAt := keybindingMixinFields0[1].Descriptor()
|
||||
keybindingDescUpdatedAt := keybindingMixinFields1[1].Descriptor()
|
||||
// keybinding.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
keybinding.DefaultUpdatedAt = keybindingDescUpdatedAt.Default.(func() string)
|
||||
// keybindingDescKey is the schema descriptor for key field.
|
||||
@@ -164,22 +182,28 @@ func init() {
|
||||
// keybinding.DefaultEnabled holds the default value on creation for the enabled field.
|
||||
keybinding.DefaultEnabled = keybindingDescEnabled.Default.(bool)
|
||||
themeMixin := schema.Theme{}.Mixin()
|
||||
themeMixinHooks0 := themeMixin[0].Hooks()
|
||||
themeMixinHooks1 := themeMixin[1].Hooks()
|
||||
theme.Hooks[0] = themeMixinHooks0[0]
|
||||
theme.Hooks[1] = themeMixinHooks1[0]
|
||||
themeMixinInters1 := themeMixin[1].Interceptors()
|
||||
theme.Interceptors[0] = themeMixinInters1[0]
|
||||
themeMixinHooks2 := themeMixin[2].Hooks()
|
||||
theme.Hooks[0] = themeMixinHooks1[0]
|
||||
theme.Hooks[1] = themeMixinHooks2[0]
|
||||
themeMixinInters2 := themeMixin[2].Interceptors()
|
||||
theme.Interceptors[0] = themeMixinInters2[0]
|
||||
themeMixinFields0 := themeMixin[0].Fields()
|
||||
_ = themeMixinFields0
|
||||
themeMixinFields1 := themeMixin[1].Fields()
|
||||
_ = themeMixinFields1
|
||||
themeFields := schema.Theme{}.Fields()
|
||||
_ = themeFields
|
||||
// themeDescUUID is the schema descriptor for uuid field.
|
||||
themeDescUUID := themeMixinFields0[0].Descriptor()
|
||||
// theme.DefaultUUID holds the default value on creation for the uuid field.
|
||||
theme.DefaultUUID = themeDescUUID.Default.(func() string)
|
||||
// themeDescCreatedAt is the schema descriptor for created_at field.
|
||||
themeDescCreatedAt := themeMixinFields0[0].Descriptor()
|
||||
themeDescCreatedAt := themeMixinFields1[0].Descriptor()
|
||||
// theme.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
theme.DefaultCreatedAt = themeDescCreatedAt.Default.(func() string)
|
||||
// themeDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
themeDescUpdatedAt := themeMixinFields0[1].Descriptor()
|
||||
themeDescUpdatedAt := themeMixinFields1[1].Descriptor()
|
||||
// theme.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
theme.DefaultUpdatedAt = themeDescUpdatedAt.Default.(func() string)
|
||||
// themeDescKey is the schema descriptor for key field.
|
||||
|
||||
@@ -17,17 +17,19 @@ type Theme 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"`
|
||||
// 删除时间,NULL表示未删除
|
||||
// deleted at
|
||||
DeletedAt *string `json:"deleted_at,omitempty"`
|
||||
// 主题标识符
|
||||
// theme key
|
||||
Key string `json:"key"`
|
||||
// 主题类型
|
||||
// theme type
|
||||
Type theme.Type `json:"type"`
|
||||
// 主题颜色配置
|
||||
// theme colors
|
||||
Colors map[string]interface{} `json:"colors"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
@@ -41,7 +43,7 @@ func (*Theme) scanValues(columns []string) ([]any, error) {
|
||||
values[i] = new([]byte)
|
||||
case theme.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case theme.FieldCreatedAt, theme.FieldUpdatedAt, theme.FieldDeletedAt, theme.FieldKey, theme.FieldType:
|
||||
case theme.FieldUUID, theme.FieldCreatedAt, theme.FieldUpdatedAt, theme.FieldDeletedAt, theme.FieldKey, theme.FieldType:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -64,6 +66,12 @@ func (_m *Theme) assignValues(columns []string, values []any) error {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
_m.ID = int(value.Int64)
|
||||
case theme.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 theme.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
@@ -139,6 +147,9 @@ func (_m *Theme) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Theme(")
|
||||
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(", ")
|
||||
|
||||
@@ -14,6 +14,8 @@ const (
|
||||
Label = "theme"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldUUID holds the string denoting the uuid field in the database.
|
||||
FieldUUID = "uuid"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
@@ -33,6 +35,7 @@ const (
|
||||
// Columns holds all SQL columns for theme fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldUUID,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
FieldDeletedAt,
|
||||
@@ -59,6 +62,8 @@ func ValidColumn(column string) bool {
|
||||
var (
|
||||
Hooks [2]ent.Hook
|
||||
Interceptors [1]ent.Interceptor
|
||||
// DefaultUUID holds the default value on creation for the "uuid" field.
|
||||
DefaultUUID func() string
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() string
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
@@ -98,6 +103,11 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUUID orders the results by the uuid field.
|
||||
func ByUUID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUUID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
|
||||
@@ -53,6 +53,11 @@ func IDLTE(id int) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// UUID applies equality check predicate on the "uuid" field. It's identical to UUIDEQ.
|
||||
func UUID(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldEQ(FieldCreatedAt, v))
|
||||
@@ -73,6 +78,81 @@ func Key(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldEQ(FieldKey, v))
|
||||
}
|
||||
|
||||
// UUIDEQ applies the EQ predicate on the "uuid" field.
|
||||
func UUIDEQ(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDNEQ applies the NEQ predicate on the "uuid" field.
|
||||
func UUIDNEQ(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldNEQ(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDIn applies the In predicate on the "uuid" field.
|
||||
func UUIDIn(vs ...string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldIn(FieldUUID, vs...))
|
||||
}
|
||||
|
||||
// UUIDNotIn applies the NotIn predicate on the "uuid" field.
|
||||
func UUIDNotIn(vs ...string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldNotIn(FieldUUID, vs...))
|
||||
}
|
||||
|
||||
// UUIDGT applies the GT predicate on the "uuid" field.
|
||||
func UUIDGT(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldGT(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDGTE applies the GTE predicate on the "uuid" field.
|
||||
func UUIDGTE(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldGTE(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDLT applies the LT predicate on the "uuid" field.
|
||||
func UUIDLT(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldLT(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDLTE applies the LTE predicate on the "uuid" field.
|
||||
func UUIDLTE(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldLTE(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDContains applies the Contains predicate on the "uuid" field.
|
||||
func UUIDContains(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldContains(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDHasPrefix applies the HasPrefix predicate on the "uuid" field.
|
||||
func UUIDHasPrefix(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldHasPrefix(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDHasSuffix applies the HasSuffix predicate on the "uuid" field.
|
||||
func UUIDHasSuffix(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldHasSuffix(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDIsNil applies the IsNil predicate on the "uuid" field.
|
||||
func UUIDIsNil() predicate.Theme {
|
||||
return predicate.Theme(sql.FieldIsNull(FieldUUID))
|
||||
}
|
||||
|
||||
// UUIDNotNil applies the NotNil predicate on the "uuid" field.
|
||||
func UUIDNotNil() predicate.Theme {
|
||||
return predicate.Theme(sql.FieldNotNull(FieldUUID))
|
||||
}
|
||||
|
||||
// UUIDEqualFold applies the EqualFold predicate on the "uuid" field.
|
||||
func UUIDEqualFold(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldEqualFold(FieldUUID, v))
|
||||
}
|
||||
|
||||
// UUIDContainsFold applies the ContainsFold predicate on the "uuid" field.
|
||||
func UUIDContainsFold(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldContainsFold(FieldUUID, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v string) predicate.Theme {
|
||||
return predicate.Theme(sql.FieldEQ(FieldCreatedAt, v))
|
||||
|
||||
@@ -19,6 +19,20 @@ type ThemeCreate struct {
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetUUID sets the "uuid" field.
|
||||
func (_c *ThemeCreate) SetUUID(v string) *ThemeCreate {
|
||||
_c.mutation.SetUUID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUUID sets the "uuid" field if the given value is not nil.
|
||||
func (_c *ThemeCreate) SetNillableUUID(v *string) *ThemeCreate {
|
||||
if v != nil {
|
||||
_c.SetUUID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *ThemeCreate) SetCreatedAt(v string) *ThemeCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
@@ -116,6 +130,13 @@ func (_c *ThemeCreate) ExecX(ctx context.Context) {
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *ThemeCreate) defaults() error {
|
||||
if _, ok := _c.mutation.UUID(); !ok {
|
||||
if theme.DefaultUUID == nil {
|
||||
return fmt.Errorf("ent: uninitialized theme.DefaultUUID (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := theme.DefaultUUID()
|
||||
_c.mutation.SetUUID(v)
|
||||
}
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
if theme.DefaultCreatedAt == nil {
|
||||
return fmt.Errorf("ent: uninitialized theme.DefaultCreatedAt (forgotten import ent/runtime?)")
|
||||
@@ -183,6 +204,10 @@ func (_c *ThemeCreate) createSpec() (*Theme, *sqlgraph.CreateSpec) {
|
||||
_node = &Theme{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(theme.Table, sqlgraph.NewFieldSpec(theme.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := _c.mutation.UUID(); ok {
|
||||
_spec.SetField(theme.FieldUUID, field.TypeString, value)
|
||||
_node.UUID = value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(theme.FieldCreatedAt, field.TypeString, value)
|
||||
_node.CreatedAt = value
|
||||
|
||||
@@ -265,12 +265,12 @@ func (_q *ThemeQuery) Clone() *ThemeQuery {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt string `json:"created_at"`
|
||||
// UUID string `json:"uuid"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Theme.Query().
|
||||
// GroupBy(theme.FieldCreatedAt).
|
||||
// GroupBy(theme.FieldUUID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ThemeQuery) GroupBy(field string, fields ...string) *ThemeGroupBy {
|
||||
@@ -288,11 +288,11 @@ func (_q *ThemeQuery) GroupBy(field string, fields ...string) *ThemeGroupBy {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CreatedAt string `json:"created_at"`
|
||||
// UUID string `json:"uuid"`
|
||||
// }
|
||||
//
|
||||
// client.Theme.Query().
|
||||
// Select(theme.FieldCreatedAt).
|
||||
// Select(theme.FieldUUID).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *ThemeQuery) Select(fields ...string) *ThemeSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -167,6 +167,9 @@ func (_u *ThemeUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if _u.mutation.UUIDCleared() {
|
||||
_spec.ClearField(theme.FieldUUID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(theme.FieldUpdatedAt, field.TypeString, value)
|
||||
}
|
||||
@@ -379,6 +382,9 @@ func (_u *ThemeUpdateOne) sqlSave(ctx context.Context) (_node *Theme, err error)
|
||||
}
|
||||
}
|
||||
}
|
||||
if _u.mutation.UUIDCleared() {
|
||||
_spec.ClearField(theme.FieldUUID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(theme.FieldUpdatedAt, field.TypeString, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user