Some checks failed
CodeQL Advanced / Analyze (go) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (c-cpp) (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
CodeQL Advanced / Analyze (rust) (push) Has been cancelled
2928 lines
86 KiB
Go
2928 lines
86 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"sync"
|
|
"voidraft/internal/models/ent/document"
|
|
"voidraft/internal/models/ent/extension"
|
|
"voidraft/internal/models/ent/keybinding"
|
|
"voidraft/internal/models/ent/predicate"
|
|
"voidraft/internal/models/ent/theme"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
const (
|
|
// Operation types.
|
|
OpCreate = ent.OpCreate
|
|
OpDelete = ent.OpDelete
|
|
OpDeleteOne = ent.OpDeleteOne
|
|
OpUpdate = ent.OpUpdate
|
|
OpUpdateOne = ent.OpUpdateOne
|
|
|
|
// Node types.
|
|
TypeDocument = "Document"
|
|
TypeExtension = "Extension"
|
|
TypeKeyBinding = "KeyBinding"
|
|
TypeTheme = "Theme"
|
|
)
|
|
|
|
// DocumentMutation represents an operation that mutates the Document nodes in the graph.
|
|
type DocumentMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
uuid *string
|
|
created_at *string
|
|
updated_at *string
|
|
deleted_at *string
|
|
title *string
|
|
content *string
|
|
locked *bool
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Document, error)
|
|
predicates []predicate.Document
|
|
}
|
|
|
|
var _ ent.Mutation = (*DocumentMutation)(nil)
|
|
|
|
// documentOption allows management of the mutation configuration using functional options.
|
|
type documentOption func(*DocumentMutation)
|
|
|
|
// newDocumentMutation creates new mutation for the Document entity.
|
|
func newDocumentMutation(c config, op Op, opts ...documentOption) *DocumentMutation {
|
|
m := &DocumentMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeDocument,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withDocumentID sets the ID field of the mutation.
|
|
func withDocumentID(id int) documentOption {
|
|
return func(m *DocumentMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Document
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Document, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Document.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withDocument sets the old Document of the mutation.
|
|
func withDocument(node *Document) documentOption {
|
|
return func(m *DocumentMutation) {
|
|
m.oldValue = func(context.Context) (*Document, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m DocumentMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m DocumentMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *DocumentMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *DocumentMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Document.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
func (m *DocumentMutation) CreatedAt() (r string, exists bool) {
|
|
v := m.created_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCreatedAt returns the old "created_at" 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) OldCreatedAt(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
|
}
|
|
return oldValue.CreatedAt, nil
|
|
}
|
|
|
|
// ResetCreatedAt resets all changes to the "created_at" field.
|
|
func (m *DocumentMutation) ResetCreatedAt() {
|
|
m.created_at = nil
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (m *DocumentMutation) SetUpdatedAt(s string) {
|
|
m.updated_at = &s
|
|
}
|
|
|
|
// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
func (m *DocumentMutation) UpdatedAt() (r string, exists bool) {
|
|
v := m.updated_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUpdatedAt returns the old "updated_at" 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) OldUpdatedAt(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
|
}
|
|
return oldValue.UpdatedAt, nil
|
|
}
|
|
|
|
// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
func (m *DocumentMutation) ResetUpdatedAt() {
|
|
m.updated_at = nil
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (m *DocumentMutation) SetDeletedAt(s string) {
|
|
m.deleted_at = &s
|
|
}
|
|
|
|
// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
func (m *DocumentMutation) DeletedAt() (r string, exists bool) {
|
|
v := m.deleted_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDeletedAt returns the old "deleted_at" 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) OldDeletedAt(ctx context.Context) (v *string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
|
}
|
|
return oldValue.DeletedAt, nil
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (m *DocumentMutation) ClearDeletedAt() {
|
|
m.deleted_at = nil
|
|
m.clearedFields[document.FieldDeletedAt] = struct{}{}
|
|
}
|
|
|
|
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
func (m *DocumentMutation) DeletedAtCleared() bool {
|
|
_, ok := m.clearedFields[document.FieldDeletedAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
func (m *DocumentMutation) ResetDeletedAt() {
|
|
m.deleted_at = nil
|
|
delete(m.clearedFields, document.FieldDeletedAt)
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (m *DocumentMutation) SetTitle(s string) {
|
|
m.title = &s
|
|
}
|
|
|
|
// Title returns the value of the "title" field in the mutation.
|
|
func (m *DocumentMutation) Title() (r string, exists bool) {
|
|
v := m.title
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTitle returns the old "title" 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) OldTitle(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTitle is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTitle requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTitle: %w", err)
|
|
}
|
|
return oldValue.Title, nil
|
|
}
|
|
|
|
// ResetTitle resets all changes to the "title" field.
|
|
func (m *DocumentMutation) ResetTitle() {
|
|
m.title = nil
|
|
}
|
|
|
|
// SetContent sets the "content" field.
|
|
func (m *DocumentMutation) SetContent(s string) {
|
|
m.content = &s
|
|
}
|
|
|
|
// Content returns the value of the "content" field in the mutation.
|
|
func (m *DocumentMutation) Content() (r string, exists bool) {
|
|
v := m.content
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldContent returns the old "content" 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) OldContent(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldContent is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldContent requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldContent: %w", err)
|
|
}
|
|
return oldValue.Content, nil
|
|
}
|
|
|
|
// ClearContent clears the value of the "content" field.
|
|
func (m *DocumentMutation) ClearContent() {
|
|
m.content = nil
|
|
m.clearedFields[document.FieldContent] = struct{}{}
|
|
}
|
|
|
|
// ContentCleared returns if the "content" field was cleared in this mutation.
|
|
func (m *DocumentMutation) ContentCleared() bool {
|
|
_, ok := m.clearedFields[document.FieldContent]
|
|
return ok
|
|
}
|
|
|
|
// ResetContent resets all changes to the "content" field.
|
|
func (m *DocumentMutation) ResetContent() {
|
|
m.content = nil
|
|
delete(m.clearedFields, document.FieldContent)
|
|
}
|
|
|
|
// SetLocked sets the "locked" field.
|
|
func (m *DocumentMutation) SetLocked(b bool) {
|
|
m.locked = &b
|
|
}
|
|
|
|
// Locked returns the value of the "locked" field in the mutation.
|
|
func (m *DocumentMutation) Locked() (r bool, exists bool) {
|
|
v := m.locked
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldLocked returns the old "locked" 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) OldLocked(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldLocked is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldLocked requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldLocked: %w", err)
|
|
}
|
|
return oldValue.Locked, nil
|
|
}
|
|
|
|
// ResetLocked resets all changes to the "locked" field.
|
|
func (m *DocumentMutation) ResetLocked() {
|
|
m.locked = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the DocumentMutation builder.
|
|
func (m *DocumentMutation) Where(ps ...predicate.Document) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// WhereP appends storage-level predicates to the DocumentMutation builder. Using this method,
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
func (m *DocumentMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]predicate.Document, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
m.Where(p...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *DocumentMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
func (m *DocumentMutation) SetOp(op Op) {
|
|
m.op = op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Document).
|
|
func (m *DocumentMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *DocumentMutation) Fields() []string {
|
|
fields := make([]string, 0, 7)
|
|
if m.uuid != nil {
|
|
fields = append(fields, document.FieldUUID)
|
|
}
|
|
if m.created_at != nil {
|
|
fields = append(fields, document.FieldCreatedAt)
|
|
}
|
|
if m.updated_at != nil {
|
|
fields = append(fields, document.FieldUpdatedAt)
|
|
}
|
|
if m.deleted_at != nil {
|
|
fields = append(fields, document.FieldDeletedAt)
|
|
}
|
|
if m.title != nil {
|
|
fields = append(fields, document.FieldTitle)
|
|
}
|
|
if m.content != nil {
|
|
fields = append(fields, document.FieldContent)
|
|
}
|
|
if m.locked != nil {
|
|
fields = append(fields, document.FieldLocked)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// 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:
|
|
return m.UpdatedAt()
|
|
case document.FieldDeletedAt:
|
|
return m.DeletedAt()
|
|
case document.FieldTitle:
|
|
return m.Title()
|
|
case document.FieldContent:
|
|
return m.Content()
|
|
case document.FieldLocked:
|
|
return m.Locked()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// 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:
|
|
return m.OldUpdatedAt(ctx)
|
|
case document.FieldDeletedAt:
|
|
return m.OldDeletedAt(ctx)
|
|
case document.FieldTitle:
|
|
return m.OldTitle(ctx)
|
|
case document.FieldContent:
|
|
return m.OldContent(ctx)
|
|
case document.FieldLocked:
|
|
return m.OldLocked(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Document field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// 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 {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCreatedAt(v)
|
|
return nil
|
|
case document.FieldUpdatedAt:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUpdatedAt(v)
|
|
return nil
|
|
case document.FieldDeletedAt:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDeletedAt(v)
|
|
return nil
|
|
case document.FieldTitle:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTitle(v)
|
|
return nil
|
|
case document.FieldContent:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetContent(v)
|
|
return nil
|
|
case document.FieldLocked:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetLocked(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Document field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *DocumentMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *DocumentMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *DocumentMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Document numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// 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)
|
|
}
|
|
if m.FieldCleared(document.FieldContent) {
|
|
fields = append(fields, document.FieldContent)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *DocumentMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// 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
|
|
case document.FieldContent:
|
|
m.ClearContent()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Document nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// 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
|
|
case document.FieldUpdatedAt:
|
|
m.ResetUpdatedAt()
|
|
return nil
|
|
case document.FieldDeletedAt:
|
|
m.ResetDeletedAt()
|
|
return nil
|
|
case document.FieldTitle:
|
|
m.ResetTitle()
|
|
return nil
|
|
case document.FieldContent:
|
|
m.ResetContent()
|
|
return nil
|
|
case document.FieldLocked:
|
|
m.ResetLocked()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Document field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *DocumentMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *DocumentMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *DocumentMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *DocumentMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *DocumentMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *DocumentMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *DocumentMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Document unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *DocumentMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Document edge %s", name)
|
|
}
|
|
|
|
// ExtensionMutation represents an operation that mutates the Extension nodes in the graph.
|
|
type ExtensionMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
uuid *string
|
|
created_at *string
|
|
updated_at *string
|
|
deleted_at *string
|
|
key *string
|
|
enabled *bool
|
|
_config *map[string]interface{}
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Extension, error)
|
|
predicates []predicate.Extension
|
|
}
|
|
|
|
var _ ent.Mutation = (*ExtensionMutation)(nil)
|
|
|
|
// extensionOption allows management of the mutation configuration using functional options.
|
|
type extensionOption func(*ExtensionMutation)
|
|
|
|
// newExtensionMutation creates new mutation for the Extension entity.
|
|
func newExtensionMutation(c config, op Op, opts ...extensionOption) *ExtensionMutation {
|
|
m := &ExtensionMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeExtension,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withExtensionID sets the ID field of the mutation.
|
|
func withExtensionID(id int) extensionOption {
|
|
return func(m *ExtensionMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Extension
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Extension, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Extension.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withExtension sets the old Extension of the mutation.
|
|
func withExtension(node *Extension) extensionOption {
|
|
return func(m *ExtensionMutation) {
|
|
m.oldValue = func(context.Context) (*Extension, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m ExtensionMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m ExtensionMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *ExtensionMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *ExtensionMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Extension.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
func (m *ExtensionMutation) CreatedAt() (r string, exists bool) {
|
|
v := m.created_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCreatedAt returns the old "created_at" 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) OldCreatedAt(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
|
}
|
|
return oldValue.CreatedAt, nil
|
|
}
|
|
|
|
// ResetCreatedAt resets all changes to the "created_at" field.
|
|
func (m *ExtensionMutation) ResetCreatedAt() {
|
|
m.created_at = nil
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (m *ExtensionMutation) SetUpdatedAt(s string) {
|
|
m.updated_at = &s
|
|
}
|
|
|
|
// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
func (m *ExtensionMutation) UpdatedAt() (r string, exists bool) {
|
|
v := m.updated_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUpdatedAt returns the old "updated_at" 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) OldUpdatedAt(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
|
}
|
|
return oldValue.UpdatedAt, nil
|
|
}
|
|
|
|
// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
func (m *ExtensionMutation) ResetUpdatedAt() {
|
|
m.updated_at = nil
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (m *ExtensionMutation) SetDeletedAt(s string) {
|
|
m.deleted_at = &s
|
|
}
|
|
|
|
// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
func (m *ExtensionMutation) DeletedAt() (r string, exists bool) {
|
|
v := m.deleted_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDeletedAt returns the old "deleted_at" 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) OldDeletedAt(ctx context.Context) (v *string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
|
}
|
|
return oldValue.DeletedAt, nil
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (m *ExtensionMutation) ClearDeletedAt() {
|
|
m.deleted_at = nil
|
|
m.clearedFields[extension.FieldDeletedAt] = struct{}{}
|
|
}
|
|
|
|
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
func (m *ExtensionMutation) DeletedAtCleared() bool {
|
|
_, ok := m.clearedFields[extension.FieldDeletedAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
func (m *ExtensionMutation) ResetDeletedAt() {
|
|
m.deleted_at = nil
|
|
delete(m.clearedFields, extension.FieldDeletedAt)
|
|
}
|
|
|
|
// SetKey sets the "key" field.
|
|
func (m *ExtensionMutation) SetKey(s string) {
|
|
m.key = &s
|
|
}
|
|
|
|
// Key returns the value of the "key" field in the mutation.
|
|
func (m *ExtensionMutation) Key() (r string, exists bool) {
|
|
v := m.key
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldKey returns the old "key" 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) OldKey(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldKey is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldKey requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldKey: %w", err)
|
|
}
|
|
return oldValue.Key, nil
|
|
}
|
|
|
|
// ResetKey resets all changes to the "key" field.
|
|
func (m *ExtensionMutation) ResetKey() {
|
|
m.key = nil
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (m *ExtensionMutation) SetEnabled(b bool) {
|
|
m.enabled = &b
|
|
}
|
|
|
|
// Enabled returns the value of the "enabled" field in the mutation.
|
|
func (m *ExtensionMutation) Enabled() (r bool, exists bool) {
|
|
v := m.enabled
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldEnabled returns the old "enabled" 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) OldEnabled(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldEnabled requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
|
|
}
|
|
return oldValue.Enabled, nil
|
|
}
|
|
|
|
// ResetEnabled resets all changes to the "enabled" field.
|
|
func (m *ExtensionMutation) ResetEnabled() {
|
|
m.enabled = nil
|
|
}
|
|
|
|
// SetConfig sets the "config" field.
|
|
func (m *ExtensionMutation) SetConfig(value map[string]interface{}) {
|
|
m._config = &value
|
|
}
|
|
|
|
// Config returns the value of the "config" field in the mutation.
|
|
func (m *ExtensionMutation) Config() (r map[string]interface{}, exists bool) {
|
|
v := m._config
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldConfig returns the old "config" 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) OldConfig(ctx context.Context) (v map[string]interface{}, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldConfig is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldConfig requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldConfig: %w", err)
|
|
}
|
|
return oldValue.Config, nil
|
|
}
|
|
|
|
// ClearConfig clears the value of the "config" field.
|
|
func (m *ExtensionMutation) ClearConfig() {
|
|
m._config = nil
|
|
m.clearedFields[extension.FieldConfig] = struct{}{}
|
|
}
|
|
|
|
// ConfigCleared returns if the "config" field was cleared in this mutation.
|
|
func (m *ExtensionMutation) ConfigCleared() bool {
|
|
_, ok := m.clearedFields[extension.FieldConfig]
|
|
return ok
|
|
}
|
|
|
|
// ResetConfig resets all changes to the "config" field.
|
|
func (m *ExtensionMutation) ResetConfig() {
|
|
m._config = nil
|
|
delete(m.clearedFields, extension.FieldConfig)
|
|
}
|
|
|
|
// Where appends a list predicates to the ExtensionMutation builder.
|
|
func (m *ExtensionMutation) Where(ps ...predicate.Extension) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// WhereP appends storage-level predicates to the ExtensionMutation builder. Using this method,
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
func (m *ExtensionMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]predicate.Extension, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
m.Where(p...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *ExtensionMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
func (m *ExtensionMutation) SetOp(op Op) {
|
|
m.op = op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Extension).
|
|
func (m *ExtensionMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *ExtensionMutation) Fields() []string {
|
|
fields := make([]string, 0, 7)
|
|
if m.uuid != nil {
|
|
fields = append(fields, extension.FieldUUID)
|
|
}
|
|
if m.created_at != nil {
|
|
fields = append(fields, extension.FieldCreatedAt)
|
|
}
|
|
if m.updated_at != nil {
|
|
fields = append(fields, extension.FieldUpdatedAt)
|
|
}
|
|
if m.deleted_at != nil {
|
|
fields = append(fields, extension.FieldDeletedAt)
|
|
}
|
|
if m.key != nil {
|
|
fields = append(fields, extension.FieldKey)
|
|
}
|
|
if m.enabled != nil {
|
|
fields = append(fields, extension.FieldEnabled)
|
|
}
|
|
if m._config != nil {
|
|
fields = append(fields, extension.FieldConfig)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// 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:
|
|
return m.UpdatedAt()
|
|
case extension.FieldDeletedAt:
|
|
return m.DeletedAt()
|
|
case extension.FieldKey:
|
|
return m.Key()
|
|
case extension.FieldEnabled:
|
|
return m.Enabled()
|
|
case extension.FieldConfig:
|
|
return m.Config()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// 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:
|
|
return m.OldUpdatedAt(ctx)
|
|
case extension.FieldDeletedAt:
|
|
return m.OldDeletedAt(ctx)
|
|
case extension.FieldKey:
|
|
return m.OldKey(ctx)
|
|
case extension.FieldEnabled:
|
|
return m.OldEnabled(ctx)
|
|
case extension.FieldConfig:
|
|
return m.OldConfig(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Extension field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// 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 {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCreatedAt(v)
|
|
return nil
|
|
case extension.FieldUpdatedAt:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUpdatedAt(v)
|
|
return nil
|
|
case extension.FieldDeletedAt:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDeletedAt(v)
|
|
return nil
|
|
case extension.FieldKey:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetKey(v)
|
|
return nil
|
|
case extension.FieldEnabled:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetEnabled(v)
|
|
return nil
|
|
case extension.FieldConfig:
|
|
v, ok := value.(map[string]interface{})
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetConfig(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Extension field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *ExtensionMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *ExtensionMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *ExtensionMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Extension numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// 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)
|
|
}
|
|
if m.FieldCleared(extension.FieldConfig) {
|
|
fields = append(fields, extension.FieldConfig)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *ExtensionMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// 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
|
|
case extension.FieldConfig:
|
|
m.ClearConfig()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Extension nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// 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
|
|
case extension.FieldUpdatedAt:
|
|
m.ResetUpdatedAt()
|
|
return nil
|
|
case extension.FieldDeletedAt:
|
|
m.ResetDeletedAt()
|
|
return nil
|
|
case extension.FieldKey:
|
|
m.ResetKey()
|
|
return nil
|
|
case extension.FieldEnabled:
|
|
m.ResetEnabled()
|
|
return nil
|
|
case extension.FieldConfig:
|
|
m.ResetConfig()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Extension field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *ExtensionMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *ExtensionMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *ExtensionMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *ExtensionMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *ExtensionMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *ExtensionMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *ExtensionMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Extension unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *ExtensionMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Extension edge %s", name)
|
|
}
|
|
|
|
// KeyBindingMutation represents an operation that mutates the KeyBinding nodes in the graph.
|
|
type KeyBindingMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
uuid *string
|
|
created_at *string
|
|
updated_at *string
|
|
deleted_at *string
|
|
key *string
|
|
command *string
|
|
extension *string
|
|
enabled *bool
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*KeyBinding, error)
|
|
predicates []predicate.KeyBinding
|
|
}
|
|
|
|
var _ ent.Mutation = (*KeyBindingMutation)(nil)
|
|
|
|
// keybindingOption allows management of the mutation configuration using functional options.
|
|
type keybindingOption func(*KeyBindingMutation)
|
|
|
|
// newKeyBindingMutation creates new mutation for the KeyBinding entity.
|
|
func newKeyBindingMutation(c config, op Op, opts ...keybindingOption) *KeyBindingMutation {
|
|
m := &KeyBindingMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeKeyBinding,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withKeyBindingID sets the ID field of the mutation.
|
|
func withKeyBindingID(id int) keybindingOption {
|
|
return func(m *KeyBindingMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *KeyBinding
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*KeyBinding, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().KeyBinding.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withKeyBinding sets the old KeyBinding of the mutation.
|
|
func withKeyBinding(node *KeyBinding) keybindingOption {
|
|
return func(m *KeyBindingMutation) {
|
|
m.oldValue = func(context.Context) (*KeyBinding, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m KeyBindingMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m KeyBindingMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *KeyBindingMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *KeyBindingMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().KeyBinding.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
func (m *KeyBindingMutation) CreatedAt() (r string, exists bool) {
|
|
v := m.created_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCreatedAt returns the old "created_at" 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) OldCreatedAt(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
|
}
|
|
return oldValue.CreatedAt, nil
|
|
}
|
|
|
|
// ResetCreatedAt resets all changes to the "created_at" field.
|
|
func (m *KeyBindingMutation) ResetCreatedAt() {
|
|
m.created_at = nil
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (m *KeyBindingMutation) SetUpdatedAt(s string) {
|
|
m.updated_at = &s
|
|
}
|
|
|
|
// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
func (m *KeyBindingMutation) UpdatedAt() (r string, exists bool) {
|
|
v := m.updated_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUpdatedAt returns the old "updated_at" 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) OldUpdatedAt(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
|
}
|
|
return oldValue.UpdatedAt, nil
|
|
}
|
|
|
|
// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
func (m *KeyBindingMutation) ResetUpdatedAt() {
|
|
m.updated_at = nil
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (m *KeyBindingMutation) SetDeletedAt(s string) {
|
|
m.deleted_at = &s
|
|
}
|
|
|
|
// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
func (m *KeyBindingMutation) DeletedAt() (r string, exists bool) {
|
|
v := m.deleted_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDeletedAt returns the old "deleted_at" 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) OldDeletedAt(ctx context.Context) (v *string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
|
}
|
|
return oldValue.DeletedAt, nil
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (m *KeyBindingMutation) ClearDeletedAt() {
|
|
m.deleted_at = nil
|
|
m.clearedFields[keybinding.FieldDeletedAt] = struct{}{}
|
|
}
|
|
|
|
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
func (m *KeyBindingMutation) DeletedAtCleared() bool {
|
|
_, ok := m.clearedFields[keybinding.FieldDeletedAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
func (m *KeyBindingMutation) ResetDeletedAt() {
|
|
m.deleted_at = nil
|
|
delete(m.clearedFields, keybinding.FieldDeletedAt)
|
|
}
|
|
|
|
// SetKey sets the "key" field.
|
|
func (m *KeyBindingMutation) SetKey(s string) {
|
|
m.key = &s
|
|
}
|
|
|
|
// Key returns the value of the "key" field in the mutation.
|
|
func (m *KeyBindingMutation) Key() (r string, exists bool) {
|
|
v := m.key
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldKey returns the old "key" 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) OldKey(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldKey is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldKey requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldKey: %w", err)
|
|
}
|
|
return oldValue.Key, nil
|
|
}
|
|
|
|
// ResetKey resets all changes to the "key" field.
|
|
func (m *KeyBindingMutation) ResetKey() {
|
|
m.key = nil
|
|
}
|
|
|
|
// SetCommand sets the "command" field.
|
|
func (m *KeyBindingMutation) SetCommand(s string) {
|
|
m.command = &s
|
|
}
|
|
|
|
// Command returns the value of the "command" field in the mutation.
|
|
func (m *KeyBindingMutation) Command() (r string, exists bool) {
|
|
v := m.command
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCommand returns the old "command" 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) OldCommand(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCommand is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCommand requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCommand: %w", err)
|
|
}
|
|
return oldValue.Command, nil
|
|
}
|
|
|
|
// ResetCommand resets all changes to the "command" field.
|
|
func (m *KeyBindingMutation) ResetCommand() {
|
|
m.command = nil
|
|
}
|
|
|
|
// SetExtension sets the "extension" field.
|
|
func (m *KeyBindingMutation) SetExtension(s string) {
|
|
m.extension = &s
|
|
}
|
|
|
|
// Extension returns the value of the "extension" field in the mutation.
|
|
func (m *KeyBindingMutation) Extension() (r string, exists bool) {
|
|
v := m.extension
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldExtension returns the old "extension" 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) OldExtension(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldExtension is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldExtension requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldExtension: %w", err)
|
|
}
|
|
return oldValue.Extension, nil
|
|
}
|
|
|
|
// ClearExtension clears the value of the "extension" field.
|
|
func (m *KeyBindingMutation) ClearExtension() {
|
|
m.extension = nil
|
|
m.clearedFields[keybinding.FieldExtension] = struct{}{}
|
|
}
|
|
|
|
// ExtensionCleared returns if the "extension" field was cleared in this mutation.
|
|
func (m *KeyBindingMutation) ExtensionCleared() bool {
|
|
_, ok := m.clearedFields[keybinding.FieldExtension]
|
|
return ok
|
|
}
|
|
|
|
// ResetExtension resets all changes to the "extension" field.
|
|
func (m *KeyBindingMutation) ResetExtension() {
|
|
m.extension = nil
|
|
delete(m.clearedFields, keybinding.FieldExtension)
|
|
}
|
|
|
|
// SetEnabled sets the "enabled" field.
|
|
func (m *KeyBindingMutation) SetEnabled(b bool) {
|
|
m.enabled = &b
|
|
}
|
|
|
|
// Enabled returns the value of the "enabled" field in the mutation.
|
|
func (m *KeyBindingMutation) Enabled() (r bool, exists bool) {
|
|
v := m.enabled
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldEnabled returns the old "enabled" 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) OldEnabled(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldEnabled requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
|
|
}
|
|
return oldValue.Enabled, nil
|
|
}
|
|
|
|
// ResetEnabled resets all changes to the "enabled" field.
|
|
func (m *KeyBindingMutation) ResetEnabled() {
|
|
m.enabled = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the KeyBindingMutation builder.
|
|
func (m *KeyBindingMutation) Where(ps ...predicate.KeyBinding) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// WhereP appends storage-level predicates to the KeyBindingMutation builder. Using this method,
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
func (m *KeyBindingMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]predicate.KeyBinding, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
m.Where(p...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *KeyBindingMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
func (m *KeyBindingMutation) SetOp(op Op) {
|
|
m.op = op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (KeyBinding).
|
|
func (m *KeyBindingMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *KeyBindingMutation) Fields() []string {
|
|
fields := make([]string, 0, 8)
|
|
if m.uuid != nil {
|
|
fields = append(fields, keybinding.FieldUUID)
|
|
}
|
|
if m.created_at != nil {
|
|
fields = append(fields, keybinding.FieldCreatedAt)
|
|
}
|
|
if m.updated_at != nil {
|
|
fields = append(fields, keybinding.FieldUpdatedAt)
|
|
}
|
|
if m.deleted_at != nil {
|
|
fields = append(fields, keybinding.FieldDeletedAt)
|
|
}
|
|
if m.key != nil {
|
|
fields = append(fields, keybinding.FieldKey)
|
|
}
|
|
if m.command != nil {
|
|
fields = append(fields, keybinding.FieldCommand)
|
|
}
|
|
if m.extension != nil {
|
|
fields = append(fields, keybinding.FieldExtension)
|
|
}
|
|
if m.enabled != nil {
|
|
fields = append(fields, keybinding.FieldEnabled)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// 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:
|
|
return m.UpdatedAt()
|
|
case keybinding.FieldDeletedAt:
|
|
return m.DeletedAt()
|
|
case keybinding.FieldKey:
|
|
return m.Key()
|
|
case keybinding.FieldCommand:
|
|
return m.Command()
|
|
case keybinding.FieldExtension:
|
|
return m.Extension()
|
|
case keybinding.FieldEnabled:
|
|
return m.Enabled()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// 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:
|
|
return m.OldUpdatedAt(ctx)
|
|
case keybinding.FieldDeletedAt:
|
|
return m.OldDeletedAt(ctx)
|
|
case keybinding.FieldKey:
|
|
return m.OldKey(ctx)
|
|
case keybinding.FieldCommand:
|
|
return m.OldCommand(ctx)
|
|
case keybinding.FieldExtension:
|
|
return m.OldExtension(ctx)
|
|
case keybinding.FieldEnabled:
|
|
return m.OldEnabled(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown KeyBinding field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// 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 {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCreatedAt(v)
|
|
return nil
|
|
case keybinding.FieldUpdatedAt:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUpdatedAt(v)
|
|
return nil
|
|
case keybinding.FieldDeletedAt:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDeletedAt(v)
|
|
return nil
|
|
case keybinding.FieldKey:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetKey(v)
|
|
return nil
|
|
case keybinding.FieldCommand:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCommand(v)
|
|
return nil
|
|
case keybinding.FieldExtension:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetExtension(v)
|
|
return nil
|
|
case keybinding.FieldEnabled:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetEnabled(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown KeyBinding field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *KeyBindingMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *KeyBindingMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *KeyBindingMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown KeyBinding numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// 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)
|
|
}
|
|
if m.FieldCleared(keybinding.FieldExtension) {
|
|
fields = append(fields, keybinding.FieldExtension)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *KeyBindingMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// 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
|
|
case keybinding.FieldExtension:
|
|
m.ClearExtension()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown KeyBinding nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// 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
|
|
case keybinding.FieldUpdatedAt:
|
|
m.ResetUpdatedAt()
|
|
return nil
|
|
case keybinding.FieldDeletedAt:
|
|
m.ResetDeletedAt()
|
|
return nil
|
|
case keybinding.FieldKey:
|
|
m.ResetKey()
|
|
return nil
|
|
case keybinding.FieldCommand:
|
|
m.ResetCommand()
|
|
return nil
|
|
case keybinding.FieldExtension:
|
|
m.ResetExtension()
|
|
return nil
|
|
case keybinding.FieldEnabled:
|
|
m.ResetEnabled()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown KeyBinding field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *KeyBindingMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *KeyBindingMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *KeyBindingMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *KeyBindingMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *KeyBindingMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *KeyBindingMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *KeyBindingMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown KeyBinding unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *KeyBindingMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown KeyBinding edge %s", name)
|
|
}
|
|
|
|
// ThemeMutation represents an operation that mutates the Theme nodes in the graph.
|
|
type ThemeMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
uuid *string
|
|
created_at *string
|
|
updated_at *string
|
|
deleted_at *string
|
|
key *string
|
|
_type *theme.Type
|
|
colors *map[string]interface{}
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Theme, error)
|
|
predicates []predicate.Theme
|
|
}
|
|
|
|
var _ ent.Mutation = (*ThemeMutation)(nil)
|
|
|
|
// themeOption allows management of the mutation configuration using functional options.
|
|
type themeOption func(*ThemeMutation)
|
|
|
|
// newThemeMutation creates new mutation for the Theme entity.
|
|
func newThemeMutation(c config, op Op, opts ...themeOption) *ThemeMutation {
|
|
m := &ThemeMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeTheme,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withThemeID sets the ID field of the mutation.
|
|
func withThemeID(id int) themeOption {
|
|
return func(m *ThemeMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Theme
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Theme, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Theme.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withTheme sets the old Theme of the mutation.
|
|
func withTheme(node *Theme) themeOption {
|
|
return func(m *ThemeMutation) {
|
|
m.oldValue = func(context.Context) (*Theme, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m ThemeMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m ThemeMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *ThemeMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *ThemeMutation) IDs(ctx context.Context) ([]int, error) {
|
|
switch {
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
id, exists := m.ID()
|
|
if exists {
|
|
return []int{id}, nil
|
|
}
|
|
fallthrough
|
|
case m.op.Is(OpUpdate | OpDelete):
|
|
return m.Client().Theme.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
func (m *ThemeMutation) CreatedAt() (r string, exists bool) {
|
|
v := m.created_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCreatedAt returns the old "created_at" 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) OldCreatedAt(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
|
}
|
|
return oldValue.CreatedAt, nil
|
|
}
|
|
|
|
// ResetCreatedAt resets all changes to the "created_at" field.
|
|
func (m *ThemeMutation) ResetCreatedAt() {
|
|
m.created_at = nil
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (m *ThemeMutation) SetUpdatedAt(s string) {
|
|
m.updated_at = &s
|
|
}
|
|
|
|
// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
func (m *ThemeMutation) UpdatedAt() (r string, exists bool) {
|
|
v := m.updated_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUpdatedAt returns the old "updated_at" 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) OldUpdatedAt(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
|
}
|
|
return oldValue.UpdatedAt, nil
|
|
}
|
|
|
|
// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
func (m *ThemeMutation) ResetUpdatedAt() {
|
|
m.updated_at = nil
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (m *ThemeMutation) SetDeletedAt(s string) {
|
|
m.deleted_at = &s
|
|
}
|
|
|
|
// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
func (m *ThemeMutation) DeletedAt() (r string, exists bool) {
|
|
v := m.deleted_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDeletedAt returns the old "deleted_at" 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) OldDeletedAt(ctx context.Context) (v *string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
|
}
|
|
return oldValue.DeletedAt, nil
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (m *ThemeMutation) ClearDeletedAt() {
|
|
m.deleted_at = nil
|
|
m.clearedFields[theme.FieldDeletedAt] = struct{}{}
|
|
}
|
|
|
|
// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
func (m *ThemeMutation) DeletedAtCleared() bool {
|
|
_, ok := m.clearedFields[theme.FieldDeletedAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
func (m *ThemeMutation) ResetDeletedAt() {
|
|
m.deleted_at = nil
|
|
delete(m.clearedFields, theme.FieldDeletedAt)
|
|
}
|
|
|
|
// SetKey sets the "key" field.
|
|
func (m *ThemeMutation) SetKey(s string) {
|
|
m.key = &s
|
|
}
|
|
|
|
// Key returns the value of the "key" field in the mutation.
|
|
func (m *ThemeMutation) Key() (r string, exists bool) {
|
|
v := m.key
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldKey returns the old "key" 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) OldKey(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldKey is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldKey requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldKey: %w", err)
|
|
}
|
|
return oldValue.Key, nil
|
|
}
|
|
|
|
// ResetKey resets all changes to the "key" field.
|
|
func (m *ThemeMutation) ResetKey() {
|
|
m.key = nil
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (m *ThemeMutation) SetType(t theme.Type) {
|
|
m._type = &t
|
|
}
|
|
|
|
// GetType returns the value of the "type" field in the mutation.
|
|
func (m *ThemeMutation) GetType() (r theme.Type, exists bool) {
|
|
v := m._type
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldType returns the old "type" 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) OldType(ctx context.Context) (v theme.Type, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldType is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldType requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldType: %w", err)
|
|
}
|
|
return oldValue.Type, nil
|
|
}
|
|
|
|
// ResetType resets all changes to the "type" field.
|
|
func (m *ThemeMutation) ResetType() {
|
|
m._type = nil
|
|
}
|
|
|
|
// SetColors sets the "colors" field.
|
|
func (m *ThemeMutation) SetColors(value map[string]interface{}) {
|
|
m.colors = &value
|
|
}
|
|
|
|
// Colors returns the value of the "colors" field in the mutation.
|
|
func (m *ThemeMutation) Colors() (r map[string]interface{}, exists bool) {
|
|
v := m.colors
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldColors returns the old "colors" 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) OldColors(ctx context.Context) (v map[string]interface{}, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldColors is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldColors requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldColors: %w", err)
|
|
}
|
|
return oldValue.Colors, nil
|
|
}
|
|
|
|
// ClearColors clears the value of the "colors" field.
|
|
func (m *ThemeMutation) ClearColors() {
|
|
m.colors = nil
|
|
m.clearedFields[theme.FieldColors] = struct{}{}
|
|
}
|
|
|
|
// ColorsCleared returns if the "colors" field was cleared in this mutation.
|
|
func (m *ThemeMutation) ColorsCleared() bool {
|
|
_, ok := m.clearedFields[theme.FieldColors]
|
|
return ok
|
|
}
|
|
|
|
// ResetColors resets all changes to the "colors" field.
|
|
func (m *ThemeMutation) ResetColors() {
|
|
m.colors = nil
|
|
delete(m.clearedFields, theme.FieldColors)
|
|
}
|
|
|
|
// Where appends a list predicates to the ThemeMutation builder.
|
|
func (m *ThemeMutation) Where(ps ...predicate.Theme) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// WhereP appends storage-level predicates to the ThemeMutation builder. Using this method,
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
func (m *ThemeMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]predicate.Theme, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
m.Where(p...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *ThemeMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
func (m *ThemeMutation) SetOp(op Op) {
|
|
m.op = op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Theme).
|
|
func (m *ThemeMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *ThemeMutation) Fields() []string {
|
|
fields := make([]string, 0, 7)
|
|
if m.uuid != nil {
|
|
fields = append(fields, theme.FieldUUID)
|
|
}
|
|
if m.created_at != nil {
|
|
fields = append(fields, theme.FieldCreatedAt)
|
|
}
|
|
if m.updated_at != nil {
|
|
fields = append(fields, theme.FieldUpdatedAt)
|
|
}
|
|
if m.deleted_at != nil {
|
|
fields = append(fields, theme.FieldDeletedAt)
|
|
}
|
|
if m.key != nil {
|
|
fields = append(fields, theme.FieldKey)
|
|
}
|
|
if m._type != nil {
|
|
fields = append(fields, theme.FieldType)
|
|
}
|
|
if m.colors != nil {
|
|
fields = append(fields, theme.FieldColors)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// 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:
|
|
return m.UpdatedAt()
|
|
case theme.FieldDeletedAt:
|
|
return m.DeletedAt()
|
|
case theme.FieldKey:
|
|
return m.Key()
|
|
case theme.FieldType:
|
|
return m.GetType()
|
|
case theme.FieldColors:
|
|
return m.Colors()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// 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:
|
|
return m.OldUpdatedAt(ctx)
|
|
case theme.FieldDeletedAt:
|
|
return m.OldDeletedAt(ctx)
|
|
case theme.FieldKey:
|
|
return m.OldKey(ctx)
|
|
case theme.FieldType:
|
|
return m.OldType(ctx)
|
|
case theme.FieldColors:
|
|
return m.OldColors(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Theme field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// 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 {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCreatedAt(v)
|
|
return nil
|
|
case theme.FieldUpdatedAt:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUpdatedAt(v)
|
|
return nil
|
|
case theme.FieldDeletedAt:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDeletedAt(v)
|
|
return nil
|
|
case theme.FieldKey:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetKey(v)
|
|
return nil
|
|
case theme.FieldType:
|
|
v, ok := value.(theme.Type)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetType(v)
|
|
return nil
|
|
case theme.FieldColors:
|
|
v, ok := value.(map[string]interface{})
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetColors(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Theme field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *ThemeMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *ThemeMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *ThemeMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Theme numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// 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)
|
|
}
|
|
if m.FieldCleared(theme.FieldColors) {
|
|
fields = append(fields, theme.FieldColors)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *ThemeMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// 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
|
|
case theme.FieldColors:
|
|
m.ClearColors()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Theme nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// 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
|
|
case theme.FieldUpdatedAt:
|
|
m.ResetUpdatedAt()
|
|
return nil
|
|
case theme.FieldDeletedAt:
|
|
m.ResetDeletedAt()
|
|
return nil
|
|
case theme.FieldKey:
|
|
m.ResetKey()
|
|
return nil
|
|
case theme.FieldType:
|
|
m.ResetType()
|
|
return nil
|
|
case theme.FieldColors:
|
|
m.ResetColors()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Theme field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *ThemeMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *ThemeMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *ThemeMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *ThemeMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *ThemeMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *ThemeMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *ThemeMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Theme unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *ThemeMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Theme edge %s", name)
|
|
}
|