ent

package
v0.0.0-...-1d58815 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// Operation types.
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne

	// Node types.
	TypeKeyboard    = "Keyboard"
	TypeKeycapModel = "KeycapModel"
	TypeSwitchModel = "SwitchModel"
)

Variables

This section is empty.

Functions

func Asc

func Asc(fields ...string) func(*sql.Selector)

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) func(*sql.Selector)

Desc applies the given fields in DESC order.

func IsConstraintError

func IsConstraintError(err error) bool

IsConstraintError returns a boolean indicating whether the error is a constraint failure.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns a boolean indicating whether the error is a not found error.

func IsNotLoaded

func IsNotLoaded(err error) bool

IsNotLoaded returns a boolean indicating whether the error is a not loaded error.

func IsNotSingular

func IsNotSingular(err error) bool

IsNotSingular returns a boolean indicating whether the error is a not singular error.

func IsValidationError

func IsValidationError(err error) bool

IsValidationError returns a boolean indicating whether the error is a validation error.

func KeyboardSliceToOpenAPI

func KeyboardSliceToOpenAPI(s []*Keyboard) (_ []openapi.Keyboard, err error)

Following edges must be loaded:

switches
keycaps

func KeycapModelSliceToOpenAPI

func KeycapModelSliceToOpenAPI(s []*KeycapModel) (_ []openapi.Keycaps, err error)

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

func NewContext(parent context.Context, c *Client) context.Context

NewContext returns a new context with the given Client attached.

func NewTxContext

func NewTxContext(parent context.Context, tx *Tx) context.Context

NewTxContext returns a new context with the given Tx attached.

func SwitchModelSliceToOpenAPI

func SwitchModelSliceToOpenAPI(s []*SwitchModel) (_ []openapi.Switches, err error)

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

AggregateFunc applies an aggregation step on the group-by traversal/selector.

func As

As is a pseudo aggregation function for renaming another other functions with custom names. For example:

GroupBy(field1, field2).
Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
Scan(ctx, &v)

func Count

func Count() AggregateFunc

Count applies the "count" aggregation function on each group.

func Max

func Max(field string) AggregateFunc

Max applies the "max" aggregation function on the given field of each group.

func Mean

func Mean(field string) AggregateFunc

Mean applies the "mean" aggregation function on the given field of each group.

func Min

func Min(field string) AggregateFunc

Min applies the "min" aggregation function on the given field of each group.

func Sum

func Sum(field string) AggregateFunc

Sum applies the "sum" aggregation function on the given field of each group.

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Keyboard is the client for interacting with the Keyboard builders.
	Keyboard *KeyboardClient
	// KeycapModel is the client for interacting with the KeycapModel builders.
	KeycapModel *KeycapModelClient
	// SwitchModel is the client for interacting with the SwitchModel builders.
	SwitchModel *SwitchModelClient
	// contains filtered or unexported fields
}

Client is the client that holds all ent builders.

func FromContext

func FromContext(ctx context.Context) *Client

FromContext returns a Client stored inside a context, or nil if there isn't one.

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new client configured with the given options.

func Open

func Open(driverName, dataSourceName string, options ...Option) (*Client, error)

Open opens a database/sql.DB specified by the driver name and the data source name, and returns a new client attached to it. Optional parameters can be added for configuring the client.

func (*Client) BeginTx

func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

BeginTx returns a transactional client with specified options.

func (*Client) Close

func (c *Client) Close() error

Close closes the database connection and prevents new queries from starting.

func (*Client) Debug

func (c *Client) Debug() *Client

Debug returns a new debug-client. It's used to get verbose logging on specific operations.

client.Debug().
	Keyboard.
	Query().
	Count(ctx)

func (*Client) Intercept

func (c *Client) Intercept(interceptors ...Interceptor)

Intercept adds the query interceptors to all the entity clients. In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.

func (*Client) Mutate

func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error)

Mutate implements the ent.Mutator interface.

func (*Client) Tx

func (c *Client) Tx(ctx context.Context) (*Tx, error)

Tx returns a new transactional client. The provided context is used until the transaction is committed or rolled back.

func (*Client) Use

func (c *Client) Use(hooks ...Hook)

Use adds the mutation hooks to all the entity clients. In order to add hooks to a specific client, call: `client.Node.Use(...)`.

type CommitFunc

type CommitFunc func(context.Context, *Tx) error

The CommitFunc type is an adapter to allow the use of ordinary function as a Committer. If f is a function with the appropriate signature, CommitFunc(f) is a Committer that calls f.

func (CommitFunc) Commit

func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

CommitHook defines the "commit middleware". A function that gets a Committer and returns a Committer. For example:

hook := func(next ent.Committer) ent.Committer {
	return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error {
		// Do some stuff before.
		if err := next.Commit(ctx, tx); err != nil {
			return err
		}
		// Do some stuff after.
		return nil
	})
}

type Committer

type Committer interface {
	Commit(context.Context, *Tx) error
}

Committer is the interface that wraps the Commit method.

type ConstraintError

type ConstraintError struct {
	// contains filtered or unexported fields
}

ConstraintError returns when trying to create/update one or more entities and one or more of their constraints failed. For example, violation of edge or field uniqueness.

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

ent aliases to avoid import conflicts in user's code.

type InterceptFunc

type InterceptFunc = ent.InterceptFunc

ent aliases to avoid import conflicts in user's code.

type Interceptor

type Interceptor = ent.Interceptor

ent aliases to avoid import conflicts in user's code.

type Keyboard

type Keyboard struct {

	// ID of the ent.
	ID int64 `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Price holds the value of the "price" field.
	Price int64 `json:"price,omitempty"`
	// Discount holds the value of the "discount" field.
	Discount *int64 `json:"discount,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the KeyboardQuery when eager-loading is set.
	Edges KeyboardEdges `json:"edges"`
	// contains filtered or unexported fields
}

Keyboard is the model entity for the Keyboard schema.

func (*Keyboard) QueryKeycaps

func (k *Keyboard) QueryKeycaps() *KeycapModelQuery

QueryKeycaps queries the "keycaps" edge of the Keyboard entity.

func (*Keyboard) QuerySwitches

func (k *Keyboard) QuerySwitches() *SwitchModelQuery

QuerySwitches queries the "switches" edge of the Keyboard entity.

func (*Keyboard) String

func (k *Keyboard) String() string

String implements the fmt.Stringer.

func (*Keyboard) ToOpenAPI

func (e *Keyboard) ToOpenAPI() (*openapi.Keyboard, error)

Following edges must be loaded:

switches
keycaps

func (*Keyboard) Unwrap

func (k *Keyboard) Unwrap() *Keyboard

Unwrap unwraps the Keyboard entity that was returned from a transaction after it was closed, so that all future queries will be executed through the driver which created the transaction.

func (*Keyboard) Update

func (k *Keyboard) Update() *KeyboardUpdateOne

Update returns a builder for updating this Keyboard. Note that you need to call Keyboard.Unwrap() before calling this method if this Keyboard was returned from a transaction, and the transaction was committed or rolled back.

func (*Keyboard) Value

func (k *Keyboard) Value(name string) (ent.Value, error)

Value returns the ent.Value that was dynamically selected and assigned to the Keyboard. This includes values selected through modifiers, order, etc.

type KeyboardClient

type KeyboardClient struct {
	// contains filtered or unexported fields
}

KeyboardClient is a client for the Keyboard schema.

func NewKeyboardClient

func NewKeyboardClient(c config) *KeyboardClient

NewKeyboardClient returns a client for the Keyboard from the given config.

func (*KeyboardClient) Create

func (c *KeyboardClient) Create() *KeyboardCreate

Create returns a builder for creating a Keyboard entity.

func (*KeyboardClient) CreateBulk

func (c *KeyboardClient) CreateBulk(builders ...*KeyboardCreate) *KeyboardCreateBulk

CreateBulk returns a builder for creating a bulk of Keyboard entities.

func (*KeyboardClient) Delete

func (c *KeyboardClient) Delete() *KeyboardDelete

Delete returns a delete builder for Keyboard.

func (*KeyboardClient) DeleteOne

func (c *KeyboardClient) DeleteOne(k *Keyboard) *KeyboardDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*KeyboardClient) DeleteOneID

func (c *KeyboardClient) DeleteOneID(id int64) *KeyboardDeleteOne

DeleteOneID returns a builder for deleting the given entity by its id.

func (*KeyboardClient) Get

func (c *KeyboardClient) Get(ctx context.Context, id int64) (*Keyboard, error)

Get returns a Keyboard entity by its id.

func (*KeyboardClient) GetX

func (c *KeyboardClient) GetX(ctx context.Context, id int64) *Keyboard

GetX is like Get, but panics if an error occurs.

func (*KeyboardClient) Hooks

func (c *KeyboardClient) Hooks() []Hook

Hooks returns the client hooks.

func (*KeyboardClient) Intercept

func (c *KeyboardClient) Intercept(interceptors ...Interceptor)

Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `keyboard.Intercept(f(g(h())))`.

func (*KeyboardClient) Interceptors

func (c *KeyboardClient) Interceptors() []Interceptor

Interceptors returns the client interceptors.

func (*KeyboardClient) Query

func (c *KeyboardClient) Query() *KeyboardQuery

Query returns a query builder for Keyboard.

func (*KeyboardClient) QueryKeycaps

func (c *KeyboardClient) QueryKeycaps(k *Keyboard) *KeycapModelQuery

QueryKeycaps queries the keycaps edge of a Keyboard.

func (*KeyboardClient) QuerySwitches

func (c *KeyboardClient) QuerySwitches(k *Keyboard) *SwitchModelQuery

QuerySwitches queries the switches edge of a Keyboard.

func (*KeyboardClient) Update

func (c *KeyboardClient) Update() *KeyboardUpdate

Update returns an update builder for Keyboard.

func (*KeyboardClient) UpdateOne

func (c *KeyboardClient) UpdateOne(k *Keyboard) *KeyboardUpdateOne

UpdateOne returns an update builder for the given entity.

func (*KeyboardClient) UpdateOneID

func (c *KeyboardClient) UpdateOneID(id int64) *KeyboardUpdateOne

UpdateOneID returns an update builder for the given id.

func (*KeyboardClient) Use

func (c *KeyboardClient) Use(hooks ...Hook)

Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `keyboard.Hooks(f(g(h())))`.

type KeyboardCreate

type KeyboardCreate struct {
	// contains filtered or unexported fields
}

KeyboardCreate is the builder for creating a Keyboard entity.

func (*KeyboardCreate) Exec

func (kc *KeyboardCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*KeyboardCreate) ExecX

func (kc *KeyboardCreate) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*KeyboardCreate) Mutation

func (kc *KeyboardCreate) Mutation() *KeyboardMutation

Mutation returns the KeyboardMutation object of the builder.

func (*KeyboardCreate) Save

func (kc *KeyboardCreate) Save(ctx context.Context) (*Keyboard, error)

Save creates the Keyboard in the database.

func (*KeyboardCreate) SaveX

func (kc *KeyboardCreate) SaveX(ctx context.Context) *Keyboard

SaveX calls Save and panics if Save returns an error.

func (*KeyboardCreate) SetDiscount

func (kc *KeyboardCreate) SetDiscount(i int64) *KeyboardCreate

SetDiscount sets the "discount" field.

func (*KeyboardCreate) SetID

func (kc *KeyboardCreate) SetID(i int64) *KeyboardCreate

SetID sets the "id" field.

func (*KeyboardCreate) SetKeycaps

func (kc *KeyboardCreate) SetKeycaps(k *KeycapModel) *KeyboardCreate

SetKeycaps sets the "keycaps" edge to the KeycapModel entity.

func (*KeyboardCreate) SetKeycapsID

func (kc *KeyboardCreate) SetKeycapsID(id int64) *KeyboardCreate

SetKeycapsID sets the "keycaps" edge to the KeycapModel entity by ID.

func (*KeyboardCreate) SetName

func (kc *KeyboardCreate) SetName(s string) *KeyboardCreate

SetName sets the "name" field.

func (*KeyboardCreate) SetNillableDiscount

func (kc *KeyboardCreate) SetNillableDiscount(i *int64) *KeyboardCreate

SetNillableDiscount sets the "discount" field if the given value is not nil.

func (*KeyboardCreate) SetPrice

func (kc *KeyboardCreate) SetPrice(i int64) *KeyboardCreate

SetPrice sets the "price" field.

func (*KeyboardCreate) SetSwitches

func (kc *KeyboardCreate) SetSwitches(s *SwitchModel) *KeyboardCreate

SetSwitches sets the "switches" edge to the SwitchModel entity.

func (*KeyboardCreate) SetSwitchesID

func (kc *KeyboardCreate) SetSwitchesID(id int64) *KeyboardCreate

SetSwitchesID sets the "switches" edge to the SwitchModel entity by ID.

type KeyboardCreateBulk

type KeyboardCreateBulk struct {
	// contains filtered or unexported fields
}

KeyboardCreateBulk is the builder for creating many Keyboard entities in bulk.

func (*KeyboardCreateBulk) Exec

func (kcb *KeyboardCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*KeyboardCreateBulk) ExecX

func (kcb *KeyboardCreateBulk) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*KeyboardCreateBulk) Save

func (kcb *KeyboardCreateBulk) Save(ctx context.Context) ([]*Keyboard, error)

Save creates the Keyboard entities in the database.

func (*KeyboardCreateBulk) SaveX

func (kcb *KeyboardCreateBulk) SaveX(ctx context.Context) []*Keyboard

SaveX is like Save, but panics if an error occurs.

type KeyboardDelete

type KeyboardDelete struct {
	// contains filtered or unexported fields
}

KeyboardDelete is the builder for deleting a Keyboard entity.

func (*KeyboardDelete) Exec

func (kd *KeyboardDelete) Exec(ctx context.Context) (int, error)

Exec executes the deletion query and returns how many vertices were deleted.

func (*KeyboardDelete) ExecX

func (kd *KeyboardDelete) ExecX(ctx context.Context) int

ExecX is like Exec, but panics if an error occurs.

func (*KeyboardDelete) Where

func (kd *KeyboardDelete) Where(ps ...predicate.Keyboard) *KeyboardDelete

Where appends a list predicates to the KeyboardDelete builder.

type KeyboardDeleteOne

type KeyboardDeleteOne struct {
	// contains filtered or unexported fields
}

KeyboardDeleteOne is the builder for deleting a single Keyboard entity.

func (*KeyboardDeleteOne) Exec

func (kdo *KeyboardDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*KeyboardDeleteOne) ExecX

func (kdo *KeyboardDeleteOne) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*KeyboardDeleteOne) Where

Where appends a list predicates to the KeyboardDelete builder.

type KeyboardEdges

type KeyboardEdges struct {
	// Switches holds the value of the switches edge.
	Switches *SwitchModel `json:"switches,omitempty"`
	// Keycaps holds the value of the keycaps edge.
	Keycaps *KeycapModel `json:"keycaps,omitempty"`
	// contains filtered or unexported fields
}

KeyboardEdges holds the relations/edges for other nodes in the graph.

func (KeyboardEdges) KeycapsOrErr

func (e KeyboardEdges) KeycapsOrErr() (*KeycapModel, error)

KeycapsOrErr returns the Keycaps value or an error if the edge was not loaded in eager-loading, or loaded but was not found.

func (KeyboardEdges) SwitchesOrErr

func (e KeyboardEdges) SwitchesOrErr() (*SwitchModel, error)

SwitchesOrErr returns the Switches value or an error if the edge was not loaded in eager-loading, or loaded but was not found.

type KeyboardGroupBy

type KeyboardGroupBy struct {
	// contains filtered or unexported fields
}

KeyboardGroupBy is the group-by builder for Keyboard entities.

func (*KeyboardGroupBy) Aggregate

func (kgb *KeyboardGroupBy) Aggregate(fns ...AggregateFunc) *KeyboardGroupBy

Aggregate adds the given aggregation functions to the group-by query.

func (*KeyboardGroupBy) Bool

func (s *KeyboardGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a selector. It is only allowed when selecting one field.

func (*KeyboardGroupBy) BoolX

func (s *KeyboardGroupBy) BoolX(ctx context.Context) bool

BoolX is like Bool, but panics if an error occurs.

func (*KeyboardGroupBy) Bools

func (s *KeyboardGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from a selector. It is only allowed when selecting one field.

func (*KeyboardGroupBy) BoolsX

func (s *KeyboardGroupBy) BoolsX(ctx context.Context) []bool

BoolsX is like Bools, but panics if an error occurs.

func (*KeyboardGroupBy) Float64

func (s *KeyboardGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a selector. It is only allowed when selecting one field.

func (*KeyboardGroupBy) Float64X

func (s *KeyboardGroupBy) Float64X(ctx context.Context) float64

Float64X is like Float64, but panics if an error occurs.

func (*KeyboardGroupBy) Float64s

func (s *KeyboardGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from a selector. It is only allowed when selecting one field.

func (*KeyboardGroupBy) Float64sX

func (s *KeyboardGroupBy) Float64sX(ctx context.Context) []float64

Float64sX is like Float64s, but panics if an error occurs.

func (*KeyboardGroupBy) Int

func (s *KeyboardGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a selector. It is only allowed when selecting one field.

func (*KeyboardGroupBy) IntX

func (s *KeyboardGroupBy) IntX(ctx context.Context) int

IntX is like Int, but panics if an error occurs.

func (*KeyboardGroupBy) Ints

func (s *KeyboardGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from a selector. It is only allowed when selecting one field.

func (*KeyboardGroupBy) IntsX

func (s *KeyboardGroupBy) IntsX(ctx context.Context) []int

IntsX is like Ints, but panics if an error occurs.

func (*KeyboardGroupBy) Scan

func (kgb *KeyboardGroupBy) Scan(ctx context.Context, v any) error

Scan applies the selector query and scans the result into the given value.

func (*KeyboardGroupBy) ScanX

func (s *KeyboardGroupBy) ScanX(ctx context.Context, v any)

ScanX is like Scan, but panics if an error occurs.

func (*KeyboardGroupBy) String

func (s *KeyboardGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a selector. It is only allowed when selecting one field.

func (*KeyboardGroupBy) StringX

func (s *KeyboardGroupBy) StringX(ctx context.Context) string

StringX is like String, but panics if an error occurs.

func (*KeyboardGroupBy) Strings

func (s *KeyboardGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from a selector. It is only allowed when selecting one field.

func (*KeyboardGroupBy) StringsX

func (s *KeyboardGroupBy) StringsX(ctx context.Context) []string

StringsX is like Strings, but panics if an error occurs.

type KeyboardMutation

type KeyboardMutation struct {
	// contains filtered or unexported fields
}

KeyboardMutation represents an operation that mutates the Keyboard nodes in the graph.

func (*KeyboardMutation) AddDiscount

func (m *KeyboardMutation) AddDiscount(i int64)

AddDiscount adds i to the "discount" field.

func (*KeyboardMutation) AddField

func (m *KeyboardMutation) AddField(name string, value ent.Value) error

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 (*KeyboardMutation) AddPrice

func (m *KeyboardMutation) AddPrice(i int64)

AddPrice adds i to the "price" field.

func (*KeyboardMutation) AddedDiscount

func (m *KeyboardMutation) AddedDiscount() (r int64, exists bool)

AddedDiscount returns the value that was added to the "discount" field in this mutation.

func (*KeyboardMutation) AddedEdges

func (m *KeyboardMutation) AddedEdges() []string

AddedEdges returns all edge names that were set/added in this mutation.

func (*KeyboardMutation) AddedField

func (m *KeyboardMutation) AddedField(name string) (ent.Value, bool)

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 (*KeyboardMutation) AddedFields

func (m *KeyboardMutation) AddedFields() []string

AddedFields returns all numeric fields that were incremented/decremented during this mutation.

func (*KeyboardMutation) AddedIDs

func (m *KeyboardMutation) AddedIDs(name string) []ent.Value

AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.

func (*KeyboardMutation) AddedPrice

func (m *KeyboardMutation) AddedPrice() (r int64, exists bool)

AddedPrice returns the value that was added to the "price" field in this mutation.

func (*KeyboardMutation) ClearDiscount

func (m *KeyboardMutation) ClearDiscount()

ClearDiscount clears the value of the "discount" field.

func (*KeyboardMutation) ClearEdge

func (m *KeyboardMutation) ClearEdge(name string) error

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 (*KeyboardMutation) ClearField

func (m *KeyboardMutation) ClearField(name string) error

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 (*KeyboardMutation) ClearKeycaps

func (m *KeyboardMutation) ClearKeycaps()

ClearKeycaps clears the "keycaps" edge to the KeycapModel entity.

func (*KeyboardMutation) ClearSwitches

func (m *KeyboardMutation) ClearSwitches()

ClearSwitches clears the "switches" edge to the SwitchModel entity.

func (*KeyboardMutation) ClearedEdges

func (m *KeyboardMutation) ClearedEdges() []string

ClearedEdges returns all edge names that were cleared in this mutation.

func (*KeyboardMutation) ClearedFields

func (m *KeyboardMutation) ClearedFields() []string

ClearedFields returns all nullable fields that were cleared during this mutation.

func (KeyboardMutation) Client

func (m KeyboardMutation) Client() *Client

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 (*KeyboardMutation) Discount

func (m *KeyboardMutation) Discount() (r int64, exists bool)

Discount returns the value of the "discount" field in the mutation.

func (*KeyboardMutation) DiscountCleared

func (m *KeyboardMutation) DiscountCleared() bool

DiscountCleared returns if the "discount" field was cleared in this mutation.

func (*KeyboardMutation) EdgeCleared

func (m *KeyboardMutation) EdgeCleared(name string) bool

EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.

func (*KeyboardMutation) Field

func (m *KeyboardMutation) Field(name string) (ent.Value, bool)

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 (*KeyboardMutation) FieldCleared

func (m *KeyboardMutation) FieldCleared(name string) bool

FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.

func (*KeyboardMutation) Fields

func (m *KeyboardMutation) Fields() []string

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 (*KeyboardMutation) ID

func (m *KeyboardMutation) ID() (id int64, exists bool)

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 (*KeyboardMutation) IDs

func (m *KeyboardMutation) IDs(ctx context.Context) ([]int64, error)

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 (*KeyboardMutation) KeycapsCleared

func (m *KeyboardMutation) KeycapsCleared() bool

KeycapsCleared reports if the "keycaps" edge to the KeycapModel entity was cleared.

func (*KeyboardMutation) KeycapsID

func (m *KeyboardMutation) KeycapsID() (id int64, exists bool)

KeycapsID returns the "keycaps" edge ID in the mutation.

func (*KeyboardMutation) KeycapsIDs

func (m *KeyboardMutation) KeycapsIDs() (ids []int64)

KeycapsIDs returns the "keycaps" edge IDs in the mutation. Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use KeycapsID instead. It exists only for internal usage by the builders.

func (*KeyboardMutation) Name

func (m *KeyboardMutation) Name() (r string, exists bool)

Name returns the value of the "name" field in the mutation.

func (*KeyboardMutation) OldDiscount

func (m *KeyboardMutation) OldDiscount(ctx context.Context) (v *int64, err error)

OldDiscount returns the old "discount" field's value of the Keyboard entity. If the Keyboard 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 (*KeyboardMutation) OldField

func (m *KeyboardMutation) OldField(ctx context.Context, name string) (ent.Value, error)

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 (*KeyboardMutation) OldName

func (m *KeyboardMutation) OldName(ctx context.Context) (v string, err error)

OldName returns the old "name" field's value of the Keyboard entity. If the Keyboard 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 (*KeyboardMutation) OldPrice

func (m *KeyboardMutation) OldPrice(ctx context.Context) (v int64, err error)

OldPrice returns the old "price" field's value of the Keyboard entity. If the Keyboard 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 (*KeyboardMutation) Op

func (m *KeyboardMutation) Op() Op

Op returns the operation name.

func (*KeyboardMutation) Price

func (m *KeyboardMutation) Price() (r int64, exists bool)

Price returns the value of the "price" field in the mutation.

func (*KeyboardMutation) RemovedEdges

func (m *KeyboardMutation) RemovedEdges() []string

RemovedEdges returns all edge names that were removed in this mutation.

func (*KeyboardMutation) RemovedIDs

func (m *KeyboardMutation) RemovedIDs(name string) []ent.Value

RemovedIDs returns all IDs (to other nodes) that were removed for the edge with the given name in this mutation.

func (*KeyboardMutation) ResetDiscount

func (m *KeyboardMutation) ResetDiscount()

ResetDiscount resets all changes to the "discount" field.

func (*KeyboardMutation) ResetEdge

func (m *KeyboardMutation) ResetEdge(name string) error

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 (*KeyboardMutation) ResetField

func (m *KeyboardMutation) ResetField(name string) error

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 (*KeyboardMutation) ResetKeycaps

func (m *KeyboardMutation) ResetKeycaps()

ResetKeycaps resets all changes to the "keycaps" edge.

func (*KeyboardMutation) ResetName

func (m *KeyboardMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*KeyboardMutation) ResetPrice

func (m *KeyboardMutation) ResetPrice()

ResetPrice resets all changes to the "price" field.

func (*KeyboardMutation) ResetSwitches

func (m *KeyboardMutation) ResetSwitches()

ResetSwitches resets all changes to the "switches" edge.

func (*KeyboardMutation) SetDiscount

func (m *KeyboardMutation) SetDiscount(i int64)

SetDiscount sets the "discount" field.

func (*KeyboardMutation) SetField

func (m *KeyboardMutation) SetField(name string, value ent.Value) error

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 (*KeyboardMutation) SetID

func (m *KeyboardMutation) SetID(id int64)

SetID sets the value of the id field. Note that this operation is only accepted on creation of Keyboard entities.

func (*KeyboardMutation) SetKeycapsID

func (m *KeyboardMutation) SetKeycapsID(id int64)

SetKeycapsID sets the "keycaps" edge to the KeycapModel entity by id.

func (*KeyboardMutation) SetName

func (m *KeyboardMutation) SetName(s string)

SetName sets the "name" field.

func (*KeyboardMutation) SetOp

func (m *KeyboardMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*KeyboardMutation) SetPrice

func (m *KeyboardMutation) SetPrice(i int64)

SetPrice sets the "price" field.

func (*KeyboardMutation) SetSwitchesID

func (m *KeyboardMutation) SetSwitchesID(id int64)

SetSwitchesID sets the "switches" edge to the SwitchModel entity by id.

func (*KeyboardMutation) SwitchesCleared

func (m *KeyboardMutation) SwitchesCleared() bool

SwitchesCleared reports if the "switches" edge to the SwitchModel entity was cleared.

func (*KeyboardMutation) SwitchesID

func (m *KeyboardMutation) SwitchesID() (id int64, exists bool)

SwitchesID returns the "switches" edge ID in the mutation.

func (*KeyboardMutation) SwitchesIDs

func (m *KeyboardMutation) SwitchesIDs() (ids []int64)

SwitchesIDs returns the "switches" edge IDs in the mutation. Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use SwitchesID instead. It exists only for internal usage by the builders.

func (KeyboardMutation) Tx

func (m KeyboardMutation) Tx() (*Tx, error)

Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.

func (*KeyboardMutation) Type

func (m *KeyboardMutation) Type() string

Type returns the node type of this mutation (Keyboard).

func (*KeyboardMutation) Where

func (m *KeyboardMutation) Where(ps ...predicate.Keyboard)

Where appends a list predicates to the KeyboardMutation builder.

func (*KeyboardMutation) WhereP

func (m *KeyboardMutation) WhereP(ps ...func(*sql.Selector))

WhereP appends storage-level predicates to the KeyboardMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.

type KeyboardQuery

type KeyboardQuery struct {
	// contains filtered or unexported fields
}

KeyboardQuery is the builder for querying Keyboard entities.

func (*KeyboardQuery) Aggregate

func (kq *KeyboardQuery) Aggregate(fns ...AggregateFunc) *KeyboardSelect

Aggregate returns a KeyboardSelect configured with the given aggregations.

func (*KeyboardQuery) All

func (kq *KeyboardQuery) All(ctx context.Context) ([]*Keyboard, error)

All executes the query and returns a list of Keyboards.

func (*KeyboardQuery) AllX

func (kq *KeyboardQuery) AllX(ctx context.Context) []*Keyboard

AllX is like All, but panics if an error occurs.

func (*KeyboardQuery) Clone

func (kq *KeyboardQuery) Clone() *KeyboardQuery

Clone returns a duplicate of the KeyboardQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.

func (*KeyboardQuery) Count

func (kq *KeyboardQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*KeyboardQuery) CountX

func (kq *KeyboardQuery) CountX(ctx context.Context) int

CountX is like Count, but panics if an error occurs.

func (*KeyboardQuery) Exist

func (kq *KeyboardQuery) Exist(ctx context.Context) (bool, error)

Exist returns true if the query has elements in the graph.

func (*KeyboardQuery) ExistX

func (kq *KeyboardQuery) ExistX(ctx context.Context) bool

ExistX is like Exist, but panics if an error occurs.

func (*KeyboardQuery) First

func (kq *KeyboardQuery) First(ctx context.Context) (*Keyboard, error)

First returns the first Keyboard entity from the query. Returns a *NotFoundError when no Keyboard was found.

func (*KeyboardQuery) FirstID

func (kq *KeyboardQuery) FirstID(ctx context.Context) (id int64, err error)

FirstID returns the first Keyboard ID from the query. Returns a *NotFoundError when no Keyboard ID was found.

func (*KeyboardQuery) FirstIDX

func (kq *KeyboardQuery) FirstIDX(ctx context.Context) int64

FirstIDX is like FirstID, but panics if an error occurs.

func (*KeyboardQuery) FirstX

func (kq *KeyboardQuery) FirstX(ctx context.Context) *Keyboard

FirstX is like First, but panics if an error occurs.

func (*KeyboardQuery) GroupBy

func (kq *KeyboardQuery) GroupBy(field string, fields ...string) *KeyboardGroupBy

GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Keyboard.Query().
	GroupBy(keyboard.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*KeyboardQuery) IDs

func (kq *KeyboardQuery) IDs(ctx context.Context) (ids []int64, err error)

IDs executes the query and returns a list of Keyboard IDs.

func (*KeyboardQuery) IDsX

func (kq *KeyboardQuery) IDsX(ctx context.Context) []int64

IDsX is like IDs, but panics if an error occurs.

func (*KeyboardQuery) Limit

func (kq *KeyboardQuery) Limit(limit int) *KeyboardQuery

Limit the number of records to be returned by this query.

func (*KeyboardQuery) Offset

func (kq *KeyboardQuery) Offset(offset int) *KeyboardQuery

Offset to start from.

func (*KeyboardQuery) Only

func (kq *KeyboardQuery) Only(ctx context.Context) (*Keyboard, error)

Only returns a single Keyboard entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Keyboard entity is found. Returns a *NotFoundError when no Keyboard entities are found.

func (*KeyboardQuery) OnlyID

func (kq *KeyboardQuery) OnlyID(ctx context.Context) (id int64, err error)

OnlyID is like Only, but returns the only Keyboard ID in the query. Returns a *NotSingularError when more than one Keyboard ID is found. Returns a *NotFoundError when no entities are found.

func (*KeyboardQuery) OnlyIDX

func (kq *KeyboardQuery) OnlyIDX(ctx context.Context) int64

OnlyIDX is like OnlyID, but panics if an error occurs.

func (*KeyboardQuery) OnlyX

func (kq *KeyboardQuery) OnlyX(ctx context.Context) *Keyboard

OnlyX is like Only, but panics if an error occurs.

func (*KeyboardQuery) Order

Order specifies how the records should be ordered.

func (*KeyboardQuery) QueryKeycaps

func (kq *KeyboardQuery) QueryKeycaps() *KeycapModelQuery

QueryKeycaps chains the current query on the "keycaps" edge.

func (*KeyboardQuery) QuerySwitches

func (kq *KeyboardQuery) QuerySwitches() *SwitchModelQuery

QuerySwitches chains the current query on the "switches" edge.

func (*KeyboardQuery) Select

func (kq *KeyboardQuery) Select(fields ...string) *KeyboardSelect

Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
}

client.Keyboard.Query().
	Select(keyboard.FieldName).
	Scan(ctx, &v)

func (*KeyboardQuery) Unique

func (kq *KeyboardQuery) Unique(unique bool) *KeyboardQuery

Unique configures the query builder to filter duplicate records on query. By default, unique is set to true, and can be disabled using this method.

func (*KeyboardQuery) Where

func (kq *KeyboardQuery) Where(ps ...predicate.Keyboard) *KeyboardQuery

Where adds a new predicate for the KeyboardQuery builder.

func (*KeyboardQuery) WithKeycaps

func (kq *KeyboardQuery) WithKeycaps(opts ...func(*KeycapModelQuery)) *KeyboardQuery

WithKeycaps tells the query-builder to eager-load the nodes that are connected to the "keycaps" edge. The optional arguments are used to configure the query builder of the edge.

func (*KeyboardQuery) WithSwitches

func (kq *KeyboardQuery) WithSwitches(opts ...func(*SwitchModelQuery)) *KeyboardQuery

WithSwitches tells the query-builder to eager-load the nodes that are connected to the "switches" edge. The optional arguments are used to configure the query builder of the edge.

type KeyboardSelect

type KeyboardSelect struct {
	*KeyboardQuery
	// contains filtered or unexported fields
}

KeyboardSelect is the builder for selecting fields of Keyboard entities.

func (*KeyboardSelect) Aggregate

func (ks *KeyboardSelect) Aggregate(fns ...AggregateFunc) *KeyboardSelect

Aggregate adds the given aggregation functions to the selector query.

func (*KeyboardSelect) Bool

func (s *KeyboardSelect) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a selector. It is only allowed when selecting one field.

func (*KeyboardSelect) BoolX

func (s *KeyboardSelect) BoolX(ctx context.Context) bool

BoolX is like Bool, but panics if an error occurs.

func (*KeyboardSelect) Bools

func (s *KeyboardSelect) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from a selector. It is only allowed when selecting one field.

func (*KeyboardSelect) BoolsX

func (s *KeyboardSelect) BoolsX(ctx context.Context) []bool

BoolsX is like Bools, but panics if an error occurs.

func (*KeyboardSelect) Float64

func (s *KeyboardSelect) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a selector. It is only allowed when selecting one field.

func (*KeyboardSelect) Float64X

func (s *KeyboardSelect) Float64X(ctx context.Context) float64

Float64X is like Float64, but panics if an error occurs.

func (*KeyboardSelect) Float64s

func (s *KeyboardSelect) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from a selector. It is only allowed when selecting one field.

func (*KeyboardSelect) Float64sX

func (s *KeyboardSelect) Float64sX(ctx context.Context) []float64

Float64sX is like Float64s, but panics if an error occurs.

func (*KeyboardSelect) Int

func (s *KeyboardSelect) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a selector. It is only allowed when selecting one field.

func (*KeyboardSelect) IntX

func (s *KeyboardSelect) IntX(ctx context.Context) int

IntX is like Int, but panics if an error occurs.

func (*KeyboardSelect) Ints

func (s *KeyboardSelect) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from a selector. It is only allowed when selecting one field.

func (*KeyboardSelect) IntsX

func (s *KeyboardSelect) IntsX(ctx context.Context) []int

IntsX is like Ints, but panics if an error occurs.

func (*KeyboardSelect) Scan

func (ks *KeyboardSelect) Scan(ctx context.Context, v any) error

Scan applies the selector query and scans the result into the given value.

func (*KeyboardSelect) ScanX

func (s *KeyboardSelect) ScanX(ctx context.Context, v any)

ScanX is like Scan, but panics if an error occurs.

func (*KeyboardSelect) String

func (s *KeyboardSelect) String(ctx context.Context) (_ string, err error)

String returns a single string from a selector. It is only allowed when selecting one field.

func (*KeyboardSelect) StringX

func (s *KeyboardSelect) StringX(ctx context.Context) string

StringX is like String, but panics if an error occurs.

func (*KeyboardSelect) Strings

func (s *KeyboardSelect) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from a selector. It is only allowed when selecting one field.

func (*KeyboardSelect) StringsX

func (s *KeyboardSelect) StringsX(ctx context.Context) []string

StringsX is like Strings, but panics if an error occurs.

type KeyboardUpdate

type KeyboardUpdate struct {
	// contains filtered or unexported fields
}

KeyboardUpdate is the builder for updating Keyboard entities.

func (*KeyboardUpdate) AddDiscount

func (ku *KeyboardUpdate) AddDiscount(i int64) *KeyboardUpdate

AddDiscount adds i to the "discount" field.

func (*KeyboardUpdate) AddPrice

func (ku *KeyboardUpdate) AddPrice(i int64) *KeyboardUpdate

AddPrice adds i to the "price" field.

func (*KeyboardUpdate) ClearDiscount

func (ku *KeyboardUpdate) ClearDiscount() *KeyboardUpdate

ClearDiscount clears the value of the "discount" field.

func (*KeyboardUpdate) ClearKeycaps

func (ku *KeyboardUpdate) ClearKeycaps() *KeyboardUpdate

ClearKeycaps clears the "keycaps" edge to the KeycapModel entity.

func (*KeyboardUpdate) ClearSwitches

func (ku *KeyboardUpdate) ClearSwitches() *KeyboardUpdate

ClearSwitches clears the "switches" edge to the SwitchModel entity.

func (*KeyboardUpdate) Exec

func (ku *KeyboardUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*KeyboardUpdate) ExecX

func (ku *KeyboardUpdate) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*KeyboardUpdate) Mutation

func (ku *KeyboardUpdate) Mutation() *KeyboardMutation

Mutation returns the KeyboardMutation object of the builder.

func (*KeyboardUpdate) Save

func (ku *KeyboardUpdate) Save(ctx context.Context) (int, error)

Save executes the query and returns the number of nodes affected by the update operation.

func (*KeyboardUpdate) SaveX

func (ku *KeyboardUpdate) SaveX(ctx context.Context) int

SaveX is like Save, but panics if an error occurs.

func (*KeyboardUpdate) SetDiscount

func (ku *KeyboardUpdate) SetDiscount(i int64) *KeyboardUpdate

SetDiscount sets the "discount" field.

func (*KeyboardUpdate) SetKeycaps

func (ku *KeyboardUpdate) SetKeycaps(k *KeycapModel) *KeyboardUpdate

SetKeycaps sets the "keycaps" edge to the KeycapModel entity.

func (*KeyboardUpdate) SetKeycapsID

func (ku *KeyboardUpdate) SetKeycapsID(id int64) *KeyboardUpdate

SetKeycapsID sets the "keycaps" edge to the KeycapModel entity by ID.

func (*KeyboardUpdate) SetName

func (ku *KeyboardUpdate) SetName(s string) *KeyboardUpdate

SetName sets the "name" field.

func (*KeyboardUpdate) SetNillableDiscount

func (ku *KeyboardUpdate) SetNillableDiscount(i *int64) *KeyboardUpdate

SetNillableDiscount sets the "discount" field if the given value is not nil.

func (*KeyboardUpdate) SetPrice

func (ku *KeyboardUpdate) SetPrice(i int64) *KeyboardUpdate

SetPrice sets the "price" field.

func (*KeyboardUpdate) SetSwitches

func (ku *KeyboardUpdate) SetSwitches(s *SwitchModel) *KeyboardUpdate

SetSwitches sets the "switches" edge to the SwitchModel entity.

func (*KeyboardUpdate) SetSwitchesID

func (ku *KeyboardUpdate) SetSwitchesID(id int64) *KeyboardUpdate

SetSwitchesID sets the "switches" edge to the SwitchModel entity by ID.

func (*KeyboardUpdate) Where

func (ku *KeyboardUpdate) Where(ps ...predicate.Keyboard) *KeyboardUpdate

Where appends a list predicates to the KeyboardUpdate builder.

type KeyboardUpdateOne

type KeyboardUpdateOne struct {
	// contains filtered or unexported fields
}

KeyboardUpdateOne is the builder for updating a single Keyboard entity.

func (*KeyboardUpdateOne) AddDiscount

func (kuo *KeyboardUpdateOne) AddDiscount(i int64) *KeyboardUpdateOne

AddDiscount adds i to the "discount" field.

func (*KeyboardUpdateOne) AddPrice

func (kuo *KeyboardUpdateOne) AddPrice(i int64) *KeyboardUpdateOne

AddPrice adds i to the "price" field.

func (*KeyboardUpdateOne) ClearDiscount

func (kuo *KeyboardUpdateOne) ClearDiscount() *KeyboardUpdateOne

ClearDiscount clears the value of the "discount" field.

func (*KeyboardUpdateOne) ClearKeycaps

func (kuo *KeyboardUpdateOne) ClearKeycaps() *KeyboardUpdateOne

ClearKeycaps clears the "keycaps" edge to the KeycapModel entity.

func (*KeyboardUpdateOne) ClearSwitches

func (kuo *KeyboardUpdateOne) ClearSwitches() *KeyboardUpdateOne

ClearSwitches clears the "switches" edge to the SwitchModel entity.

func (*KeyboardUpdateOne) Exec

func (kuo *KeyboardUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*KeyboardUpdateOne) ExecX

func (kuo *KeyboardUpdateOne) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*KeyboardUpdateOne) Mutation

func (kuo *KeyboardUpdateOne) Mutation() *KeyboardMutation

Mutation returns the KeyboardMutation object of the builder.

func (*KeyboardUpdateOne) Save

func (kuo *KeyboardUpdateOne) Save(ctx context.Context) (*Keyboard, error)

Save executes the query and returns the updated Keyboard entity.

func (*KeyboardUpdateOne) SaveX

func (kuo *KeyboardUpdateOne) SaveX(ctx context.Context) *Keyboard

SaveX is like Save, but panics if an error occurs.

func (*KeyboardUpdateOne) Select

func (kuo *KeyboardUpdateOne) Select(field string, fields ...string) *KeyboardUpdateOne

Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.

func (*KeyboardUpdateOne) SetDiscount

func (kuo *KeyboardUpdateOne) SetDiscount(i int64) *KeyboardUpdateOne

SetDiscount sets the "discount" field.

func (*KeyboardUpdateOne) SetKeycaps

func (kuo *KeyboardUpdateOne) SetKeycaps(k *KeycapModel) *KeyboardUpdateOne

SetKeycaps sets the "keycaps" edge to the KeycapModel entity.

func (*KeyboardUpdateOne) SetKeycapsID

func (kuo *KeyboardUpdateOne) SetKeycapsID(id int64) *KeyboardUpdateOne

SetKeycapsID sets the "keycaps" edge to the KeycapModel entity by ID.

func (*KeyboardUpdateOne) SetName

func (kuo *KeyboardUpdateOne) SetName(s string) *KeyboardUpdateOne

SetName sets the "name" field.

func (*KeyboardUpdateOne) SetNillableDiscount

func (kuo *KeyboardUpdateOne) SetNillableDiscount(i *int64) *KeyboardUpdateOne

SetNillableDiscount sets the "discount" field if the given value is not nil.

func (*KeyboardUpdateOne) SetPrice

func (kuo *KeyboardUpdateOne) SetPrice(i int64) *KeyboardUpdateOne

SetPrice sets the "price" field.

func (*KeyboardUpdateOne) SetSwitches

func (kuo *KeyboardUpdateOne) SetSwitches(s *SwitchModel) *KeyboardUpdateOne

SetSwitches sets the "switches" edge to the SwitchModel entity.

func (*KeyboardUpdateOne) SetSwitchesID

func (kuo *KeyboardUpdateOne) SetSwitchesID(id int64) *KeyboardUpdateOne

SetSwitchesID sets the "switches" edge to the SwitchModel entity by ID.

func (*KeyboardUpdateOne) Where

Where appends a list predicates to the KeyboardUpdate builder.

type Keyboards

type Keyboards []*Keyboard

Keyboards is a parsable slice of Keyboard.

type KeycapModel

type KeycapModel struct {

	// ID of the ent.
	ID int64 `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Profile holds the value of the "profile" field.
	Profile string `json:"profile,omitempty"`
	// Material holds the value of the "material" field.
	Material keycapmodel.Material `json:"material,omitempty"`
	// contains filtered or unexported fields
}

KeycapModel is the model entity for the KeycapModel schema.

func (*KeycapModel) String

func (km *KeycapModel) String() string

String implements the fmt.Stringer.

func (*KeycapModel) ToOpenAPI

func (e *KeycapModel) ToOpenAPI() (*openapi.Keycaps, error)

func (*KeycapModel) Unwrap

func (km *KeycapModel) Unwrap() *KeycapModel

Unwrap unwraps the KeycapModel entity that was returned from a transaction after it was closed, so that all future queries will be executed through the driver which created the transaction.

func (*KeycapModel) Update

func (km *KeycapModel) Update() *KeycapModelUpdateOne

Update returns a builder for updating this KeycapModel. Note that you need to call KeycapModel.Unwrap() before calling this method if this KeycapModel was returned from a transaction, and the transaction was committed or rolled back.

func (*KeycapModel) Value

func (km *KeycapModel) Value(name string) (ent.Value, error)

Value returns the ent.Value that was dynamically selected and assigned to the KeycapModel. This includes values selected through modifiers, order, etc.

type KeycapModelClient

type KeycapModelClient struct {
	// contains filtered or unexported fields
}

KeycapModelClient is a client for the KeycapModel schema.

func NewKeycapModelClient

func NewKeycapModelClient(c config) *KeycapModelClient

NewKeycapModelClient returns a client for the KeycapModel from the given config.

func (*KeycapModelClient) Create

func (c *KeycapModelClient) Create() *KeycapModelCreate

Create returns a builder for creating a KeycapModel entity.

func (*KeycapModelClient) CreateBulk

func (c *KeycapModelClient) CreateBulk(builders ...*KeycapModelCreate) *KeycapModelCreateBulk

CreateBulk returns a builder for creating a bulk of KeycapModel entities.

func (*KeycapModelClient) Delete

func (c *KeycapModelClient) Delete() *KeycapModelDelete

Delete returns a delete builder for KeycapModel.

func (*KeycapModelClient) DeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*KeycapModelClient) DeleteOneID

func (c *KeycapModelClient) DeleteOneID(id int64) *KeycapModelDeleteOne

DeleteOneID returns a builder for deleting the given entity by its id.

func (*KeycapModelClient) Get

Get returns a KeycapModel entity by its id.

func (*KeycapModelClient) GetX

GetX is like Get, but panics if an error occurs.

func (*KeycapModelClient) Hooks

func (c *KeycapModelClient) Hooks() []Hook

Hooks returns the client hooks.

func (*KeycapModelClient) Intercept

func (c *KeycapModelClient) Intercept(interceptors ...Interceptor)

Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `keycapmodel.Intercept(f(g(h())))`.

func (*KeycapModelClient) Interceptors

func (c *KeycapModelClient) Interceptors() []Interceptor

Interceptors returns the client interceptors.

func (*KeycapModelClient) Query

func (c *KeycapModelClient) Query() *KeycapModelQuery

Query returns a query builder for KeycapModel.

func (*KeycapModelClient) Update

func (c *KeycapModelClient) Update() *KeycapModelUpdate

Update returns an update builder for KeycapModel.

func (*KeycapModelClient) UpdateOne

UpdateOne returns an update builder for the given entity.

func (*KeycapModelClient) UpdateOneID

func (c *KeycapModelClient) UpdateOneID(id int64) *KeycapModelUpdateOne

UpdateOneID returns an update builder for the given id.

func (*KeycapModelClient) Use

func (c *KeycapModelClient) Use(hooks ...Hook)

Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `keycapmodel.Hooks(f(g(h())))`.

type KeycapModelCreate

type KeycapModelCreate struct {
	// contains filtered or unexported fields
}

KeycapModelCreate is the builder for creating a KeycapModel entity.

func (*KeycapModelCreate) Exec

func (kmc *KeycapModelCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*KeycapModelCreate) ExecX

func (kmc *KeycapModelCreate) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*KeycapModelCreate) Mutation

func (kmc *KeycapModelCreate) Mutation() *KeycapModelMutation

Mutation returns the KeycapModelMutation object of the builder.

func (*KeycapModelCreate) Save

func (kmc *KeycapModelCreate) Save(ctx context.Context) (*KeycapModel, error)

Save creates the KeycapModel in the database.

func (*KeycapModelCreate) SaveX

func (kmc *KeycapModelCreate) SaveX(ctx context.Context) *KeycapModel

SaveX calls Save and panics if Save returns an error.

func (*KeycapModelCreate) SetID

func (kmc *KeycapModelCreate) SetID(i int64) *KeycapModelCreate

SetID sets the "id" field.

func (*KeycapModelCreate) SetMaterial

SetMaterial sets the "material" field.

func (*KeycapModelCreate) SetName

func (kmc *KeycapModelCreate) SetName(s string) *KeycapModelCreate

SetName sets the "name" field.

func (*KeycapModelCreate) SetProfile

func (kmc *KeycapModelCreate) SetProfile(s string) *KeycapModelCreate

SetProfile sets the "profile" field.

type KeycapModelCreateBulk

type KeycapModelCreateBulk struct {
	// contains filtered or unexported fields
}

KeycapModelCreateBulk is the builder for creating many KeycapModel entities in bulk.

func (*KeycapModelCreateBulk) Exec

func (kmcb *KeycapModelCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*KeycapModelCreateBulk) ExecX

func (kmcb *KeycapModelCreateBulk) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*KeycapModelCreateBulk) Save

func (kmcb *KeycapModelCreateBulk) Save(ctx context.Context) ([]*KeycapModel, error)

Save creates the KeycapModel entities in the database.

func (*KeycapModelCreateBulk) SaveX

func (kmcb *KeycapModelCreateBulk) SaveX(ctx context.Context) []*KeycapModel

SaveX is like Save, but panics if an error occurs.

type KeycapModelDelete

type KeycapModelDelete struct {
	// contains filtered or unexported fields
}

KeycapModelDelete is the builder for deleting a KeycapModel entity.

func (*KeycapModelDelete) Exec

func (kmd *KeycapModelDelete) Exec(ctx context.Context) (int, error)

Exec executes the deletion query and returns how many vertices were deleted.

func (*KeycapModelDelete) ExecX

func (kmd *KeycapModelDelete) ExecX(ctx context.Context) int

ExecX is like Exec, but panics if an error occurs.

func (*KeycapModelDelete) Where

Where appends a list predicates to the KeycapModelDelete builder.

type KeycapModelDeleteOne

type KeycapModelDeleteOne struct {
	// contains filtered or unexported fields
}

KeycapModelDeleteOne is the builder for deleting a single KeycapModel entity.

func (*KeycapModelDeleteOne) Exec

func (kmdo *KeycapModelDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*KeycapModelDeleteOne) ExecX

func (kmdo *KeycapModelDeleteOne) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*KeycapModelDeleteOne) Where

Where appends a list predicates to the KeycapModelDelete builder.

type KeycapModelGroupBy

type KeycapModelGroupBy struct {
	// contains filtered or unexported fields
}

KeycapModelGroupBy is the group-by builder for KeycapModel entities.

func (*KeycapModelGroupBy) Aggregate

func (kmgb *KeycapModelGroupBy) Aggregate(fns ...AggregateFunc) *KeycapModelGroupBy

Aggregate adds the given aggregation functions to the group-by query.

func (*KeycapModelGroupBy) Bool

func (s *KeycapModelGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a selector. It is only allowed when selecting one field.

func (*KeycapModelGroupBy) BoolX

func (s *KeycapModelGroupBy) BoolX(ctx context.Context) bool

BoolX is like Bool, but panics if an error occurs.

func (*KeycapModelGroupBy) Bools

func (s *KeycapModelGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from a selector. It is only allowed when selecting one field.

func (*KeycapModelGroupBy) BoolsX

func (s *KeycapModelGroupBy) BoolsX(ctx context.Context) []bool

BoolsX is like Bools, but panics if an error occurs.

func (*KeycapModelGroupBy) Float64

func (s *KeycapModelGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a selector. It is only allowed when selecting one field.

func (*KeycapModelGroupBy) Float64X

func (s *KeycapModelGroupBy) Float64X(ctx context.Context) float64

Float64X is like Float64, but panics if an error occurs.

func (*KeycapModelGroupBy) Float64s

func (s *KeycapModelGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from a selector. It is only allowed when selecting one field.

func (*KeycapModelGroupBy) Float64sX

func (s *KeycapModelGroupBy) Float64sX(ctx context.Context) []float64

Float64sX is like Float64s, but panics if an error occurs.

func (*KeycapModelGroupBy) Int

func (s *KeycapModelGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a selector. It is only allowed when selecting one field.

func (*KeycapModelGroupBy) IntX

func (s *KeycapModelGroupBy) IntX(ctx context.Context) int

IntX is like Int, but panics if an error occurs.

func (*KeycapModelGroupBy) Ints

func (s *KeycapModelGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from a selector. It is only allowed when selecting one field.

func (*KeycapModelGroupBy) IntsX

func (s *KeycapModelGroupBy) IntsX(ctx context.Context) []int

IntsX is like Ints, but panics if an error occurs.

func (*KeycapModelGroupBy) Scan

func (kmgb *KeycapModelGroupBy) Scan(ctx context.Context, v any) error

Scan applies the selector query and scans the result into the given value.

func (*KeycapModelGroupBy) ScanX

func (s *KeycapModelGroupBy) ScanX(ctx context.Context, v any)

ScanX is like Scan, but panics if an error occurs.

func (*KeycapModelGroupBy) String

func (s *KeycapModelGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a selector. It is only allowed when selecting one field.

func (*KeycapModelGroupBy) StringX

func (s *KeycapModelGroupBy) StringX(ctx context.Context) string

StringX is like String, but panics if an error occurs.

func (*KeycapModelGroupBy) Strings

func (s *KeycapModelGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from a selector. It is only allowed when selecting one field.

func (*KeycapModelGroupBy) StringsX

func (s *KeycapModelGroupBy) StringsX(ctx context.Context) []string

StringsX is like Strings, but panics if an error occurs.

type KeycapModelMutation

type KeycapModelMutation struct {
	// contains filtered or unexported fields
}

KeycapModelMutation represents an operation that mutates the KeycapModel nodes in the graph.

func (*KeycapModelMutation) AddField

func (m *KeycapModelMutation) AddField(name string, value ent.Value) error

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 (*KeycapModelMutation) AddedEdges

func (m *KeycapModelMutation) AddedEdges() []string

AddedEdges returns all edge names that were set/added in this mutation.

func (*KeycapModelMutation) AddedField

func (m *KeycapModelMutation) AddedField(name string) (ent.Value, bool)

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 (*KeycapModelMutation) AddedFields

func (m *KeycapModelMutation) AddedFields() []string

AddedFields returns all numeric fields that were incremented/decremented during this mutation.

func (*KeycapModelMutation) AddedIDs

func (m *KeycapModelMutation) AddedIDs(name string) []ent.Value

AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.

func (*KeycapModelMutation) ClearEdge

func (m *KeycapModelMutation) ClearEdge(name string) error

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 (*KeycapModelMutation) ClearField

func (m *KeycapModelMutation) ClearField(name string) error

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 (*KeycapModelMutation) ClearedEdges

func (m *KeycapModelMutation) ClearedEdges() []string

ClearedEdges returns all edge names that were cleared in this mutation.

func (*KeycapModelMutation) ClearedFields

func (m *KeycapModelMutation) ClearedFields() []string

ClearedFields returns all nullable fields that were cleared during this mutation.

func (KeycapModelMutation) Client

func (m KeycapModelMutation) Client() *Client

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 (*KeycapModelMutation) EdgeCleared

func (m *KeycapModelMutation) EdgeCleared(name string) bool

EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.

func (*KeycapModelMutation) Field

func (m *KeycapModelMutation) Field(name string) (ent.Value, bool)

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 (*KeycapModelMutation) FieldCleared

func (m *KeycapModelMutation) FieldCleared(name string) bool

FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.

func (*KeycapModelMutation) Fields

func (m *KeycapModelMutation) Fields() []string

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 (*KeycapModelMutation) ID

func (m *KeycapModelMutation) ID() (id int64, exists bool)

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 (*KeycapModelMutation) IDs

func (m *KeycapModelMutation) IDs(ctx context.Context) ([]int64, error)

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 (*KeycapModelMutation) Material

func (m *KeycapModelMutation) Material() (r keycapmodel.Material, exists bool)

Material returns the value of the "material" field in the mutation.

func (*KeycapModelMutation) Name

func (m *KeycapModelMutation) Name() (r string, exists bool)

Name returns the value of the "name" field in the mutation.

func (*KeycapModelMutation) OldField

func (m *KeycapModelMutation) OldField(ctx context.Context, name string) (ent.Value, error)

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 (*KeycapModelMutation) OldMaterial

func (m *KeycapModelMutation) OldMaterial(ctx context.Context) (v keycapmodel.Material, err error)

OldMaterial returns the old "material" field's value of the KeycapModel entity. If the KeycapModel 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 (*KeycapModelMutation) OldName

func (m *KeycapModelMutation) OldName(ctx context.Context) (v string, err error)

OldName returns the old "name" field's value of the KeycapModel entity. If the KeycapModel 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 (*KeycapModelMutation) OldProfile

func (m *KeycapModelMutation) OldProfile(ctx context.Context) (v string, err error)

OldProfile returns the old "profile" field's value of the KeycapModel entity. If the KeycapModel 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 (*KeycapModelMutation) Op

func (m *KeycapModelMutation) Op() Op

Op returns the operation name.

func (*KeycapModelMutation) Profile

func (m *KeycapModelMutation) Profile() (r string, exists bool)

Profile returns the value of the "profile" field in the mutation.

func (*KeycapModelMutation) RemovedEdges

func (m *KeycapModelMutation) RemovedEdges() []string

RemovedEdges returns all edge names that were removed in this mutation.

func (*KeycapModelMutation) RemovedIDs

func (m *KeycapModelMutation) RemovedIDs(name string) []ent.Value

RemovedIDs returns all IDs (to other nodes) that were removed for the edge with the given name in this mutation.

func (*KeycapModelMutation) ResetEdge

func (m *KeycapModelMutation) ResetEdge(name string) error

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 (*KeycapModelMutation) ResetField

func (m *KeycapModelMutation) ResetField(name string) error

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 (*KeycapModelMutation) ResetMaterial

func (m *KeycapModelMutation) ResetMaterial()

ResetMaterial resets all changes to the "material" field.

func (*KeycapModelMutation) ResetName

func (m *KeycapModelMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*KeycapModelMutation) ResetProfile

func (m *KeycapModelMutation) ResetProfile()

ResetProfile resets all changes to the "profile" field.

func (*KeycapModelMutation) SetField

func (m *KeycapModelMutation) SetField(name string, value ent.Value) error

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 (*KeycapModelMutation) SetID

func (m *KeycapModelMutation) SetID(id int64)

SetID sets the value of the id field. Note that this operation is only accepted on creation of KeycapModel entities.

func (*KeycapModelMutation) SetMaterial

func (m *KeycapModelMutation) SetMaterial(k keycapmodel.Material)

SetMaterial sets the "material" field.

func (*KeycapModelMutation) SetName

func (m *KeycapModelMutation) SetName(s string)

SetName sets the "name" field.

func (*KeycapModelMutation) SetOp

func (m *KeycapModelMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*KeycapModelMutation) SetProfile

func (m *KeycapModelMutation) SetProfile(s string)

SetProfile sets the "profile" field.

func (KeycapModelMutation) Tx

func (m KeycapModelMutation) Tx() (*Tx, error)

Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.

func (*KeycapModelMutation) Type

func (m *KeycapModelMutation) Type() string

Type returns the node type of this mutation (KeycapModel).

func (*KeycapModelMutation) Where

func (m *KeycapModelMutation) Where(ps ...predicate.KeycapModel)

Where appends a list predicates to the KeycapModelMutation builder.

func (*KeycapModelMutation) WhereP

func (m *KeycapModelMutation) WhereP(ps ...func(*sql.Selector))

WhereP appends storage-level predicates to the KeycapModelMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.

type KeycapModelQuery

type KeycapModelQuery struct {
	// contains filtered or unexported fields
}

KeycapModelQuery is the builder for querying KeycapModel entities.

func (*KeycapModelQuery) Aggregate

func (kmq *KeycapModelQuery) Aggregate(fns ...AggregateFunc) *KeycapModelSelect

Aggregate returns a KeycapModelSelect configured with the given aggregations.

func (*KeycapModelQuery) All

func (kmq *KeycapModelQuery) All(ctx context.Context) ([]*KeycapModel, error)

All executes the query and returns a list of KeycapModels.

func (*KeycapModelQuery) AllX

func (kmq *KeycapModelQuery) AllX(ctx context.Context) []*KeycapModel

AllX is like All, but panics if an error occurs.

func (*KeycapModelQuery) Clone

func (kmq *KeycapModelQuery) Clone() *KeycapModelQuery

Clone returns a duplicate of the KeycapModelQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.

func (*KeycapModelQuery) Count

func (kmq *KeycapModelQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*KeycapModelQuery) CountX

func (kmq *KeycapModelQuery) CountX(ctx context.Context) int

CountX is like Count, but panics if an error occurs.

func (*KeycapModelQuery) Exist

func (kmq *KeycapModelQuery) Exist(ctx context.Context) (bool, error)

Exist returns true if the query has elements in the graph.

func (*KeycapModelQuery) ExistX

func (kmq *KeycapModelQuery) ExistX(ctx context.Context) bool

ExistX is like Exist, but panics if an error occurs.

func (*KeycapModelQuery) First

func (kmq *KeycapModelQuery) First(ctx context.Context) (*KeycapModel, error)

First returns the first KeycapModel entity from the query. Returns a *NotFoundError when no KeycapModel was found.

func (*KeycapModelQuery) FirstID

func (kmq *KeycapModelQuery) FirstID(ctx context.Context) (id int64, err error)

FirstID returns the first KeycapModel ID from the query. Returns a *NotFoundError when no KeycapModel ID was found.

func (*KeycapModelQuery) FirstIDX

func (kmq *KeycapModelQuery) FirstIDX(ctx context.Context) int64

FirstIDX is like FirstID, but panics if an error occurs.

func (*KeycapModelQuery) FirstX

func (kmq *KeycapModelQuery) FirstX(ctx context.Context) *KeycapModel

FirstX is like First, but panics if an error occurs.

func (*KeycapModelQuery) GroupBy

func (kmq *KeycapModelQuery) GroupBy(field string, fields ...string) *KeycapModelGroupBy

GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
	Count int `json:"count,omitempty"`
}

client.KeycapModel.Query().
	GroupBy(keycapmodel.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*KeycapModelQuery) IDs

func (kmq *KeycapModelQuery) IDs(ctx context.Context) (ids []int64, err error)

IDs executes the query and returns a list of KeycapModel IDs.

func (*KeycapModelQuery) IDsX

func (kmq *KeycapModelQuery) IDsX(ctx context.Context) []int64

IDsX is like IDs, but panics if an error occurs.

func (*KeycapModelQuery) Limit

func (kmq *KeycapModelQuery) Limit(limit int) *KeycapModelQuery

Limit the number of records to be returned by this query.

func (*KeycapModelQuery) Offset

func (kmq *KeycapModelQuery) Offset(offset int) *KeycapModelQuery

Offset to start from.

func (*KeycapModelQuery) Only

func (kmq *KeycapModelQuery) Only(ctx context.Context) (*KeycapModel, error)

Only returns a single KeycapModel entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one KeycapModel entity is found. Returns a *NotFoundError when no KeycapModel entities are found.

func (*KeycapModelQuery) OnlyID

func (kmq *KeycapModelQuery) OnlyID(ctx context.Context) (id int64, err error)

OnlyID is like Only, but returns the only KeycapModel ID in the query. Returns a *NotSingularError when more than one KeycapModel ID is found. Returns a *NotFoundError when no entities are found.

func (*KeycapModelQuery) OnlyIDX

func (kmq *KeycapModelQuery) OnlyIDX(ctx context.Context) int64

OnlyIDX is like OnlyID, but panics if an error occurs.

func (*KeycapModelQuery) OnlyX

func (kmq *KeycapModelQuery) OnlyX(ctx context.Context) *KeycapModel

OnlyX is like Only, but panics if an error occurs.

func (*KeycapModelQuery) Order

Order specifies how the records should be ordered.

func (*KeycapModelQuery) Select

func (kmq *KeycapModelQuery) Select(fields ...string) *KeycapModelSelect

Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
}

client.KeycapModel.Query().
	Select(keycapmodel.FieldName).
	Scan(ctx, &v)

func (*KeycapModelQuery) Unique

func (kmq *KeycapModelQuery) Unique(unique bool) *KeycapModelQuery

Unique configures the query builder to filter duplicate records on query. By default, unique is set to true, and can be disabled using this method.

func (*KeycapModelQuery) Where

Where adds a new predicate for the KeycapModelQuery builder.

type KeycapModelSelect

type KeycapModelSelect struct {
	*KeycapModelQuery
	// contains filtered or unexported fields
}

KeycapModelSelect is the builder for selecting fields of KeycapModel entities.

func (*KeycapModelSelect) Aggregate

func (kms *KeycapModelSelect) Aggregate(fns ...AggregateFunc) *KeycapModelSelect

Aggregate adds the given aggregation functions to the selector query.

func (*KeycapModelSelect) Bool

func (s *KeycapModelSelect) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a selector. It is only allowed when selecting one field.

func (*KeycapModelSelect) BoolX

func (s *KeycapModelSelect) BoolX(ctx context.Context) bool

BoolX is like Bool, but panics if an error occurs.

func (*KeycapModelSelect) Bools

func (s *KeycapModelSelect) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from a selector. It is only allowed when selecting one field.

func (*KeycapModelSelect) BoolsX

func (s *KeycapModelSelect) BoolsX(ctx context.Context) []bool

BoolsX is like Bools, but panics if an error occurs.

func (*KeycapModelSelect) Float64

func (s *KeycapModelSelect) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a selector. It is only allowed when selecting one field.

func (*KeycapModelSelect) Float64X

func (s *KeycapModelSelect) Float64X(ctx context.Context) float64

Float64X is like Float64, but panics if an error occurs.

func (*KeycapModelSelect) Float64s

func (s *KeycapModelSelect) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from a selector. It is only allowed when selecting one field.

func (*KeycapModelSelect) Float64sX

func (s *KeycapModelSelect) Float64sX(ctx context.Context) []float64

Float64sX is like Float64s, but panics if an error occurs.

func (*KeycapModelSelect) Int

func (s *KeycapModelSelect) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a selector. It is only allowed when selecting one field.

func (*KeycapModelSelect) IntX

func (s *KeycapModelSelect) IntX(ctx context.Context) int

IntX is like Int, but panics if an error occurs.

func (*KeycapModelSelect) Ints

func (s *KeycapModelSelect) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from a selector. It is only allowed when selecting one field.

func (*KeycapModelSelect) IntsX

func (s *KeycapModelSelect) IntsX(ctx context.Context) []int

IntsX is like Ints, but panics if an error occurs.

func (*KeycapModelSelect) Scan

func (kms *KeycapModelSelect) Scan(ctx context.Context, v any) error

Scan applies the selector query and scans the result into the given value.

func (*KeycapModelSelect) ScanX

func (s *KeycapModelSelect) ScanX(ctx context.Context, v any)

ScanX is like Scan, but panics if an error occurs.

func (*KeycapModelSelect) String

func (s *KeycapModelSelect) String(ctx context.Context) (_ string, err error)

String returns a single string from a selector. It is only allowed when selecting one field.

func (*KeycapModelSelect) StringX

func (s *KeycapModelSelect) StringX(ctx context.Context) string

StringX is like String, but panics if an error occurs.

func (*KeycapModelSelect) Strings

func (s *KeycapModelSelect) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from a selector. It is only allowed when selecting one field.

func (*KeycapModelSelect) StringsX

func (s *KeycapModelSelect) StringsX(ctx context.Context) []string

StringsX is like Strings, but panics if an error occurs.

type KeycapModelUpdate

type KeycapModelUpdate struct {
	// contains filtered or unexported fields
}

KeycapModelUpdate is the builder for updating KeycapModel entities.

func (*KeycapModelUpdate) Exec

func (kmu *KeycapModelUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*KeycapModelUpdate) ExecX

func (kmu *KeycapModelUpdate) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*KeycapModelUpdate) Mutation

func (kmu *KeycapModelUpdate) Mutation() *KeycapModelMutation

Mutation returns the KeycapModelMutation object of the builder.

func (*KeycapModelUpdate) Save

func (kmu *KeycapModelUpdate) Save(ctx context.Context) (int, error)

Save executes the query and returns the number of nodes affected by the update operation.

func (*KeycapModelUpdate) SaveX

func (kmu *KeycapModelUpdate) SaveX(ctx context.Context) int

SaveX is like Save, but panics if an error occurs.

func (*KeycapModelUpdate) SetMaterial

SetMaterial sets the "material" field.

func (*KeycapModelUpdate) SetName

func (kmu *KeycapModelUpdate) SetName(s string) *KeycapModelUpdate

SetName sets the "name" field.

func (*KeycapModelUpdate) SetProfile

func (kmu *KeycapModelUpdate) SetProfile(s string) *KeycapModelUpdate

SetProfile sets the "profile" field.

func (*KeycapModelUpdate) Where

Where appends a list predicates to the KeycapModelUpdate builder.

type KeycapModelUpdateOne

type KeycapModelUpdateOne struct {
	// contains filtered or unexported fields
}

KeycapModelUpdateOne is the builder for updating a single KeycapModel entity.

func (*KeycapModelUpdateOne) Exec

func (kmuo *KeycapModelUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*KeycapModelUpdateOne) ExecX

func (kmuo *KeycapModelUpdateOne) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*KeycapModelUpdateOne) Mutation

func (kmuo *KeycapModelUpdateOne) Mutation() *KeycapModelMutation

Mutation returns the KeycapModelMutation object of the builder.

func (*KeycapModelUpdateOne) Save

Save executes the query and returns the updated KeycapModel entity.

func (*KeycapModelUpdateOne) SaveX

func (kmuo *KeycapModelUpdateOne) SaveX(ctx context.Context) *KeycapModel

SaveX is like Save, but panics if an error occurs.

func (*KeycapModelUpdateOne) Select

func (kmuo *KeycapModelUpdateOne) Select(field string, fields ...string) *KeycapModelUpdateOne

Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.

func (*KeycapModelUpdateOne) SetMaterial

SetMaterial sets the "material" field.

func (*KeycapModelUpdateOne) SetName

SetName sets the "name" field.

func (*KeycapModelUpdateOne) SetProfile

func (kmuo *KeycapModelUpdateOne) SetProfile(s string) *KeycapModelUpdateOne

SetProfile sets the "profile" field.

func (*KeycapModelUpdateOne) Where

Where appends a list predicates to the KeycapModelUpdate builder.

type KeycapModels

type KeycapModels []*KeycapModel

KeycapModels is a parsable slice of KeycapModel.

type MutateFunc

type MutateFunc = ent.MutateFunc

ent aliases to avoid import conflicts in user's code.

type Mutation

type Mutation = ent.Mutation

ent aliases to avoid import conflicts in user's code.

type Mutator

type Mutator = ent.Mutator

ent aliases to avoid import conflicts in user's code.

type NotFoundError

type NotFoundError struct {
	// contains filtered or unexported fields
}

NotFoundError returns when trying to fetch a specific entity and it was not found in the database.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

type NotLoadedError struct {
	// contains filtered or unexported fields
}

NotLoadedError returns when trying to get a node that was not loaded by the query.

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

type NotSingularError struct {
	// contains filtered or unexported fields
}

NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

ent aliases to avoid import conflicts in user's code.

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

func Log(fn func(...any)) Option

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

OrderFunc applies an ordering on the sql selector. Deprecated: Use Asc/Desc functions or the package builders instead.

type Policy

type Policy = ent.Policy

ent aliases to avoid import conflicts in user's code.

type Querier

type Querier = ent.Querier

ent aliases to avoid import conflicts in user's code.

type QuerierFunc

type QuerierFunc = ent.QuerierFunc

ent aliases to avoid import conflicts in user's code.

type Query

type Query = ent.Query

ent aliases to avoid import conflicts in user's code.

type QueryContext

type QueryContext = ent.QueryContext

ent aliases to avoid import conflicts in user's code.

type RollbackFunc

type RollbackFunc func(context.Context, *Tx) error

The RollbackFunc type is an adapter to allow the use of ordinary function as a Rollbacker. If f is a function with the appropriate signature, RollbackFunc(f) is a Rollbacker that calls f.

func (RollbackFunc) Rollback

func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

RollbackHook defines the "rollback middleware". A function that gets a Rollbacker and returns a Rollbacker. For example:

hook := func(next ent.Rollbacker) ent.Rollbacker {
	return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error {
		// Do some stuff before.
		if err := next.Rollback(ctx, tx); err != nil {
			return err
		}
		// Do some stuff after.
		return nil
	})
}

type Rollbacker

type Rollbacker interface {
	Rollback(context.Context, *Tx) error
}

Rollbacker is the interface that wraps the Rollback method.

type SwitchModel

type SwitchModel struct {

	// ID of the ent.
	ID int64 `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// SwitchType holds the value of the "switch_type" field.
	SwitchType switchmodel.SwitchType `json:"switch_type,omitempty"`
	// contains filtered or unexported fields
}

SwitchModel is the model entity for the SwitchModel schema.

func (*SwitchModel) String

func (sm *SwitchModel) String() string

String implements the fmt.Stringer.

func (*SwitchModel) ToOpenAPI

func (e *SwitchModel) ToOpenAPI() (*openapi.Switches, error)

func (*SwitchModel) Unwrap

func (sm *SwitchModel) Unwrap() *SwitchModel

Unwrap unwraps the SwitchModel entity that was returned from a transaction after it was closed, so that all future queries will be executed through the driver which created the transaction.

func (*SwitchModel) Update

func (sm *SwitchModel) Update() *SwitchModelUpdateOne

Update returns a builder for updating this SwitchModel. Note that you need to call SwitchModel.Unwrap() before calling this method if this SwitchModel was returned from a transaction, and the transaction was committed or rolled back.

func (*SwitchModel) Value

func (sm *SwitchModel) Value(name string) (ent.Value, error)

Value returns the ent.Value that was dynamically selected and assigned to the SwitchModel. This includes values selected through modifiers, order, etc.

type SwitchModelClient

type SwitchModelClient struct {
	// contains filtered or unexported fields
}

SwitchModelClient is a client for the SwitchModel schema.

func NewSwitchModelClient

func NewSwitchModelClient(c config) *SwitchModelClient

NewSwitchModelClient returns a client for the SwitchModel from the given config.

func (*SwitchModelClient) Create

func (c *SwitchModelClient) Create() *SwitchModelCreate

Create returns a builder for creating a SwitchModel entity.

func (*SwitchModelClient) CreateBulk

func (c *SwitchModelClient) CreateBulk(builders ...*SwitchModelCreate) *SwitchModelCreateBulk

CreateBulk returns a builder for creating a bulk of SwitchModel entities.

func (*SwitchModelClient) Delete

func (c *SwitchModelClient) Delete() *SwitchModelDelete

Delete returns a delete builder for SwitchModel.

func (*SwitchModelClient) DeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*SwitchModelClient) DeleteOneID

func (c *SwitchModelClient) DeleteOneID(id int64) *SwitchModelDeleteOne

DeleteOneID returns a builder for deleting the given entity by its id.

func (*SwitchModelClient) Get

Get returns a SwitchModel entity by its id.

func (*SwitchModelClient) GetX

GetX is like Get, but panics if an error occurs.

func (*SwitchModelClient) Hooks

func (c *SwitchModelClient) Hooks() []Hook

Hooks returns the client hooks.

func (*SwitchModelClient) Intercept

func (c *SwitchModelClient) Intercept(interceptors ...Interceptor)

Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `switchmodel.Intercept(f(g(h())))`.

func (*SwitchModelClient) Interceptors

func (c *SwitchModelClient) Interceptors() []Interceptor

Interceptors returns the client interceptors.

func (*SwitchModelClient) Query

func (c *SwitchModelClient) Query() *SwitchModelQuery

Query returns a query builder for SwitchModel.

func (*SwitchModelClient) Update

func (c *SwitchModelClient) Update() *SwitchModelUpdate

Update returns an update builder for SwitchModel.

func (*SwitchModelClient) UpdateOne

UpdateOne returns an update builder for the given entity.

func (*SwitchModelClient) UpdateOneID

func (c *SwitchModelClient) UpdateOneID(id int64) *SwitchModelUpdateOne

UpdateOneID returns an update builder for the given id.

func (*SwitchModelClient) Use

func (c *SwitchModelClient) Use(hooks ...Hook)

Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `switchmodel.Hooks(f(g(h())))`.

type SwitchModelCreate

type SwitchModelCreate struct {
	// contains filtered or unexported fields
}

SwitchModelCreate is the builder for creating a SwitchModel entity.

func (*SwitchModelCreate) Exec

func (smc *SwitchModelCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*SwitchModelCreate) ExecX

func (smc *SwitchModelCreate) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*SwitchModelCreate) Mutation

func (smc *SwitchModelCreate) Mutation() *SwitchModelMutation

Mutation returns the SwitchModelMutation object of the builder.

func (*SwitchModelCreate) Save

func (smc *SwitchModelCreate) Save(ctx context.Context) (*SwitchModel, error)

Save creates the SwitchModel in the database.

func (*SwitchModelCreate) SaveX

func (smc *SwitchModelCreate) SaveX(ctx context.Context) *SwitchModel

SaveX calls Save and panics if Save returns an error.

func (*SwitchModelCreate) SetID

func (smc *SwitchModelCreate) SetID(i int64) *SwitchModelCreate

SetID sets the "id" field.

func (*SwitchModelCreate) SetName

func (smc *SwitchModelCreate) SetName(s string) *SwitchModelCreate

SetName sets the "name" field.

func (*SwitchModelCreate) SetSwitchType

SetSwitchType sets the "switch_type" field.

type SwitchModelCreateBulk

type SwitchModelCreateBulk struct {
	// contains filtered or unexported fields
}

SwitchModelCreateBulk is the builder for creating many SwitchModel entities in bulk.

func (*SwitchModelCreateBulk) Exec

func (smcb *SwitchModelCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*SwitchModelCreateBulk) ExecX

func (smcb *SwitchModelCreateBulk) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*SwitchModelCreateBulk) Save

func (smcb *SwitchModelCreateBulk) Save(ctx context.Context) ([]*SwitchModel, error)

Save creates the SwitchModel entities in the database.

func (*SwitchModelCreateBulk) SaveX

func (smcb *SwitchModelCreateBulk) SaveX(ctx context.Context) []*SwitchModel

SaveX is like Save, but panics if an error occurs.

type SwitchModelDelete

type SwitchModelDelete struct {
	// contains filtered or unexported fields
}

SwitchModelDelete is the builder for deleting a SwitchModel entity.

func (*SwitchModelDelete) Exec

func (smd *SwitchModelDelete) Exec(ctx context.Context) (int, error)

Exec executes the deletion query and returns how many vertices were deleted.

func (*SwitchModelDelete) ExecX

func (smd *SwitchModelDelete) ExecX(ctx context.Context) int

ExecX is like Exec, but panics if an error occurs.

func (*SwitchModelDelete) Where

Where appends a list predicates to the SwitchModelDelete builder.

type SwitchModelDeleteOne

type SwitchModelDeleteOne struct {
	// contains filtered or unexported fields
}

SwitchModelDeleteOne is the builder for deleting a single SwitchModel entity.

func (*SwitchModelDeleteOne) Exec

func (smdo *SwitchModelDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*SwitchModelDeleteOne) ExecX

func (smdo *SwitchModelDeleteOne) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*SwitchModelDeleteOne) Where

Where appends a list predicates to the SwitchModelDelete builder.

type SwitchModelGroupBy

type SwitchModelGroupBy struct {
	// contains filtered or unexported fields
}

SwitchModelGroupBy is the group-by builder for SwitchModel entities.

func (*SwitchModelGroupBy) Aggregate

func (smgb *SwitchModelGroupBy) Aggregate(fns ...AggregateFunc) *SwitchModelGroupBy

Aggregate adds the given aggregation functions to the group-by query.

func (*SwitchModelGroupBy) Bool

func (s *SwitchModelGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a selector. It is only allowed when selecting one field.

func (*SwitchModelGroupBy) BoolX

func (s *SwitchModelGroupBy) BoolX(ctx context.Context) bool

BoolX is like Bool, but panics if an error occurs.

func (*SwitchModelGroupBy) Bools

func (s *SwitchModelGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from a selector. It is only allowed when selecting one field.

func (*SwitchModelGroupBy) BoolsX

func (s *SwitchModelGroupBy) BoolsX(ctx context.Context) []bool

BoolsX is like Bools, but panics if an error occurs.

func (*SwitchModelGroupBy) Float64

func (s *SwitchModelGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a selector. It is only allowed when selecting one field.

func (*SwitchModelGroupBy) Float64X

func (s *SwitchModelGroupBy) Float64X(ctx context.Context) float64

Float64X is like Float64, but panics if an error occurs.

func (*SwitchModelGroupBy) Float64s

func (s *SwitchModelGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from a selector. It is only allowed when selecting one field.

func (*SwitchModelGroupBy) Float64sX

func (s *SwitchModelGroupBy) Float64sX(ctx context.Context) []float64

Float64sX is like Float64s, but panics if an error occurs.

func (*SwitchModelGroupBy) Int

func (s *SwitchModelGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a selector. It is only allowed when selecting one field.

func (*SwitchModelGroupBy) IntX

func (s *SwitchModelGroupBy) IntX(ctx context.Context) int

IntX is like Int, but panics if an error occurs.

func (*SwitchModelGroupBy) Ints

func (s *SwitchModelGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from a selector. It is only allowed when selecting one field.

func (*SwitchModelGroupBy) IntsX

func (s *SwitchModelGroupBy) IntsX(ctx context.Context) []int

IntsX is like Ints, but panics if an error occurs.

func (*SwitchModelGroupBy) Scan

func (smgb *SwitchModelGroupBy) Scan(ctx context.Context, v any) error

Scan applies the selector query and scans the result into the given value.

func (*SwitchModelGroupBy) ScanX

func (s *SwitchModelGroupBy) ScanX(ctx context.Context, v any)

ScanX is like Scan, but panics if an error occurs.

func (*SwitchModelGroupBy) String

func (s *SwitchModelGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a selector. It is only allowed when selecting one field.

func (*SwitchModelGroupBy) StringX

func (s *SwitchModelGroupBy) StringX(ctx context.Context) string

StringX is like String, but panics if an error occurs.

func (*SwitchModelGroupBy) Strings

func (s *SwitchModelGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from a selector. It is only allowed when selecting one field.

func (*SwitchModelGroupBy) StringsX

func (s *SwitchModelGroupBy) StringsX(ctx context.Context) []string

StringsX is like Strings, but panics if an error occurs.

type SwitchModelMutation

type SwitchModelMutation struct {
	// contains filtered or unexported fields
}

SwitchModelMutation represents an operation that mutates the SwitchModel nodes in the graph.

func (*SwitchModelMutation) AddField

func (m *SwitchModelMutation) AddField(name string, value ent.Value) error

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 (*SwitchModelMutation) AddedEdges

func (m *SwitchModelMutation) AddedEdges() []string

AddedEdges returns all edge names that were set/added in this mutation.

func (*SwitchModelMutation) AddedField

func (m *SwitchModelMutation) AddedField(name string) (ent.Value, bool)

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 (*SwitchModelMutation) AddedFields

func (m *SwitchModelMutation) AddedFields() []string

AddedFields returns all numeric fields that were incremented/decremented during this mutation.

func (*SwitchModelMutation) AddedIDs

func (m *SwitchModelMutation) AddedIDs(name string) []ent.Value

AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.

func (*SwitchModelMutation) ClearEdge

func (m *SwitchModelMutation) ClearEdge(name string) error

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 (*SwitchModelMutation) ClearField

func (m *SwitchModelMutation) ClearField(name string) error

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 (*SwitchModelMutation) ClearedEdges

func (m *SwitchModelMutation) ClearedEdges() []string

ClearedEdges returns all edge names that were cleared in this mutation.

func (*SwitchModelMutation) ClearedFields

func (m *SwitchModelMutation) ClearedFields() []string

ClearedFields returns all nullable fields that were cleared during this mutation.

func (SwitchModelMutation) Client

func (m SwitchModelMutation) Client() *Client

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 (*SwitchModelMutation) EdgeCleared

func (m *SwitchModelMutation) EdgeCleared(name string) bool

EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.

func (*SwitchModelMutation) Field

func (m *SwitchModelMutation) Field(name string) (ent.Value, bool)

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 (*SwitchModelMutation) FieldCleared

func (m *SwitchModelMutation) FieldCleared(name string) bool

FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.

func (*SwitchModelMutation) Fields

func (m *SwitchModelMutation) Fields() []string

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 (*SwitchModelMutation) ID

func (m *SwitchModelMutation) ID() (id int64, exists bool)

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 (*SwitchModelMutation) IDs

func (m *SwitchModelMutation) IDs(ctx context.Context) ([]int64, error)

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 (*SwitchModelMutation) Name

func (m *SwitchModelMutation) Name() (r string, exists bool)

Name returns the value of the "name" field in the mutation.

func (*SwitchModelMutation) OldField

func (m *SwitchModelMutation) OldField(ctx context.Context, name string) (ent.Value, error)

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 (*SwitchModelMutation) OldName

func (m *SwitchModelMutation) OldName(ctx context.Context) (v string, err error)

OldName returns the old "name" field's value of the SwitchModel entity. If the SwitchModel 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 (*SwitchModelMutation) OldSwitchType

func (m *SwitchModelMutation) OldSwitchType(ctx context.Context) (v switchmodel.SwitchType, err error)

OldSwitchType returns the old "switch_type" field's value of the SwitchModel entity. If the SwitchModel 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 (*SwitchModelMutation) Op

func (m *SwitchModelMutation) Op() Op

Op returns the operation name.

func (*SwitchModelMutation) RemovedEdges

func (m *SwitchModelMutation) RemovedEdges() []string

RemovedEdges returns all edge names that were removed in this mutation.

func (*SwitchModelMutation) RemovedIDs

func (m *SwitchModelMutation) RemovedIDs(name string) []ent.Value

RemovedIDs returns all IDs (to other nodes) that were removed for the edge with the given name in this mutation.

func (*SwitchModelMutation) ResetEdge

func (m *SwitchModelMutation) ResetEdge(name string) error

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 (*SwitchModelMutation) ResetField

func (m *SwitchModelMutation) ResetField(name string) error

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 (*SwitchModelMutation) ResetName

func (m *SwitchModelMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*SwitchModelMutation) ResetSwitchType

func (m *SwitchModelMutation) ResetSwitchType()

ResetSwitchType resets all changes to the "switch_type" field.

func (*SwitchModelMutation) SetField

func (m *SwitchModelMutation) SetField(name string, value ent.Value) error

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 (*SwitchModelMutation) SetID

func (m *SwitchModelMutation) SetID(id int64)

SetID sets the value of the id field. Note that this operation is only accepted on creation of SwitchModel entities.

func (*SwitchModelMutation) SetName

func (m *SwitchModelMutation) SetName(s string)

SetName sets the "name" field.

func (*SwitchModelMutation) SetOp

func (m *SwitchModelMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*SwitchModelMutation) SetSwitchType

func (m *SwitchModelMutation) SetSwitchType(st switchmodel.SwitchType)

SetSwitchType sets the "switch_type" field.

func (*SwitchModelMutation) SwitchType

func (m *SwitchModelMutation) SwitchType() (r switchmodel.SwitchType, exists bool)

SwitchType returns the value of the "switch_type" field in the mutation.

func (SwitchModelMutation) Tx

func (m SwitchModelMutation) Tx() (*Tx, error)

Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.

func (*SwitchModelMutation) Type

func (m *SwitchModelMutation) Type() string

Type returns the node type of this mutation (SwitchModel).

func (*SwitchModelMutation) Where

func (m *SwitchModelMutation) Where(ps ...predicate.SwitchModel)

Where appends a list predicates to the SwitchModelMutation builder.

func (*SwitchModelMutation) WhereP

func (m *SwitchModelMutation) WhereP(ps ...func(*sql.Selector))

WhereP appends storage-level predicates to the SwitchModelMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.

type SwitchModelQuery

type SwitchModelQuery struct {
	// contains filtered or unexported fields
}

SwitchModelQuery is the builder for querying SwitchModel entities.

func (*SwitchModelQuery) Aggregate

func (smq *SwitchModelQuery) Aggregate(fns ...AggregateFunc) *SwitchModelSelect

Aggregate returns a SwitchModelSelect configured with the given aggregations.

func (*SwitchModelQuery) All

func (smq *SwitchModelQuery) All(ctx context.Context) ([]*SwitchModel, error)

All executes the query and returns a list of SwitchModels.

func (*SwitchModelQuery) AllX

func (smq *SwitchModelQuery) AllX(ctx context.Context) []*SwitchModel

AllX is like All, but panics if an error occurs.

func (*SwitchModelQuery) Clone

func (smq *SwitchModelQuery) Clone() *SwitchModelQuery

Clone returns a duplicate of the SwitchModelQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.

func (*SwitchModelQuery) Count

func (smq *SwitchModelQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*SwitchModelQuery) CountX

func (smq *SwitchModelQuery) CountX(ctx context.Context) int

CountX is like Count, but panics if an error occurs.

func (*SwitchModelQuery) Exist

func (smq *SwitchModelQuery) Exist(ctx context.Context) (bool, error)

Exist returns true if the query has elements in the graph.

func (*SwitchModelQuery) ExistX

func (smq *SwitchModelQuery) ExistX(ctx context.Context) bool

ExistX is like Exist, but panics if an error occurs.

func (*SwitchModelQuery) First

func (smq *SwitchModelQuery) First(ctx context.Context) (*SwitchModel, error)

First returns the first SwitchModel entity from the query. Returns a *NotFoundError when no SwitchModel was found.

func (*SwitchModelQuery) FirstID

func (smq *SwitchModelQuery) FirstID(ctx context.Context) (id int64, err error)

FirstID returns the first SwitchModel ID from the query. Returns a *NotFoundError when no SwitchModel ID was found.

func (*SwitchModelQuery) FirstIDX

func (smq *SwitchModelQuery) FirstIDX(ctx context.Context) int64

FirstIDX is like FirstID, but panics if an error occurs.

func (*SwitchModelQuery) FirstX

func (smq *SwitchModelQuery) FirstX(ctx context.Context) *SwitchModel

FirstX is like First, but panics if an error occurs.

func (*SwitchModelQuery) GroupBy

func (smq *SwitchModelQuery) GroupBy(field string, fields ...string) *SwitchModelGroupBy

GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
	Count int `json:"count,omitempty"`
}

client.SwitchModel.Query().
	GroupBy(switchmodel.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*SwitchModelQuery) IDs

func (smq *SwitchModelQuery) IDs(ctx context.Context) (ids []int64, err error)

IDs executes the query and returns a list of SwitchModel IDs.

func (*SwitchModelQuery) IDsX

func (smq *SwitchModelQuery) IDsX(ctx context.Context) []int64

IDsX is like IDs, but panics if an error occurs.

func (*SwitchModelQuery) Limit

func (smq *SwitchModelQuery) Limit(limit int) *SwitchModelQuery

Limit the number of records to be returned by this query.

func (*SwitchModelQuery) Offset

func (smq *SwitchModelQuery) Offset(offset int) *SwitchModelQuery

Offset to start from.

func (*SwitchModelQuery) Only

func (smq *SwitchModelQuery) Only(ctx context.Context) (*SwitchModel, error)

Only returns a single SwitchModel entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one SwitchModel entity is found. Returns a *NotFoundError when no SwitchModel entities are found.

func (*SwitchModelQuery) OnlyID

func (smq *SwitchModelQuery) OnlyID(ctx context.Context) (id int64, err error)

OnlyID is like Only, but returns the only SwitchModel ID in the query. Returns a *NotSingularError when more than one SwitchModel ID is found. Returns a *NotFoundError when no entities are found.

func (*SwitchModelQuery) OnlyIDX

func (smq *SwitchModelQuery) OnlyIDX(ctx context.Context) int64

OnlyIDX is like OnlyID, but panics if an error occurs.

func (*SwitchModelQuery) OnlyX

func (smq *SwitchModelQuery) OnlyX(ctx context.Context) *SwitchModel

OnlyX is like Only, but panics if an error occurs.

func (*SwitchModelQuery) Order

Order specifies how the records should be ordered.

func (*SwitchModelQuery) Select

func (smq *SwitchModelQuery) Select(fields ...string) *SwitchModelSelect

Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
}

client.SwitchModel.Query().
	Select(switchmodel.FieldName).
	Scan(ctx, &v)

func (*SwitchModelQuery) Unique

func (smq *SwitchModelQuery) Unique(unique bool) *SwitchModelQuery

Unique configures the query builder to filter duplicate records on query. By default, unique is set to true, and can be disabled using this method.

func (*SwitchModelQuery) Where

Where adds a new predicate for the SwitchModelQuery builder.

type SwitchModelSelect

type SwitchModelSelect struct {
	*SwitchModelQuery
	// contains filtered or unexported fields
}

SwitchModelSelect is the builder for selecting fields of SwitchModel entities.

func (*SwitchModelSelect) Aggregate

func (sms *SwitchModelSelect) Aggregate(fns ...AggregateFunc) *SwitchModelSelect

Aggregate adds the given aggregation functions to the selector query.

func (*SwitchModelSelect) Bool

func (s *SwitchModelSelect) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a selector. It is only allowed when selecting one field.

func (*SwitchModelSelect) BoolX

func (s *SwitchModelSelect) BoolX(ctx context.Context) bool

BoolX is like Bool, but panics if an error occurs.

func (*SwitchModelSelect) Bools

func (s *SwitchModelSelect) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from a selector. It is only allowed when selecting one field.

func (*SwitchModelSelect) BoolsX

func (s *SwitchModelSelect) BoolsX(ctx context.Context) []bool

BoolsX is like Bools, but panics if an error occurs.

func (*SwitchModelSelect) Float64

func (s *SwitchModelSelect) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a selector. It is only allowed when selecting one field.

func (*SwitchModelSelect) Float64X

func (s *SwitchModelSelect) Float64X(ctx context.Context) float64

Float64X is like Float64, but panics if an error occurs.

func (*SwitchModelSelect) Float64s

func (s *SwitchModelSelect) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from a selector. It is only allowed when selecting one field.

func (*SwitchModelSelect) Float64sX

func (s *SwitchModelSelect) Float64sX(ctx context.Context) []float64

Float64sX is like Float64s, but panics if an error occurs.

func (*SwitchModelSelect) Int

func (s *SwitchModelSelect) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a selector. It is only allowed when selecting one field.

func (*SwitchModelSelect) IntX

func (s *SwitchModelSelect) IntX(ctx context.Context) int

IntX is like Int, but panics if an error occurs.

func (*SwitchModelSelect) Ints

func (s *SwitchModelSelect) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from a selector. It is only allowed when selecting one field.

func (*SwitchModelSelect) IntsX

func (s *SwitchModelSelect) IntsX(ctx context.Context) []int

IntsX is like Ints, but panics if an error occurs.

func (*SwitchModelSelect) Scan

func (sms *SwitchModelSelect) Scan(ctx context.Context, v any) error

Scan applies the selector query and scans the result into the given value.

func (*SwitchModelSelect) ScanX

func (s *SwitchModelSelect) ScanX(ctx context.Context, v any)

ScanX is like Scan, but panics if an error occurs.

func (*SwitchModelSelect) String

func (s *SwitchModelSelect) String(ctx context.Context) (_ string, err error)

String returns a single string from a selector. It is only allowed when selecting one field.

func (*SwitchModelSelect) StringX

func (s *SwitchModelSelect) StringX(ctx context.Context) string

StringX is like String, but panics if an error occurs.

func (*SwitchModelSelect) Strings

func (s *SwitchModelSelect) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from a selector. It is only allowed when selecting one field.

func (*SwitchModelSelect) StringsX

func (s *SwitchModelSelect) StringsX(ctx context.Context) []string

StringsX is like Strings, but panics if an error occurs.

type SwitchModelUpdate

type SwitchModelUpdate struct {
	// contains filtered or unexported fields
}

SwitchModelUpdate is the builder for updating SwitchModel entities.

func (*SwitchModelUpdate) Exec

func (smu *SwitchModelUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*SwitchModelUpdate) ExecX

func (smu *SwitchModelUpdate) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*SwitchModelUpdate) Mutation

func (smu *SwitchModelUpdate) Mutation() *SwitchModelMutation

Mutation returns the SwitchModelMutation object of the builder.

func (*SwitchModelUpdate) Save

func (smu *SwitchModelUpdate) Save(ctx context.Context) (int, error)

Save executes the query and returns the number of nodes affected by the update operation.

func (*SwitchModelUpdate) SaveX

func (smu *SwitchModelUpdate) SaveX(ctx context.Context) int

SaveX is like Save, but panics if an error occurs.

func (*SwitchModelUpdate) SetName

func (smu *SwitchModelUpdate) SetName(s string) *SwitchModelUpdate

SetName sets the "name" field.

func (*SwitchModelUpdate) SetSwitchType

SetSwitchType sets the "switch_type" field.

func (*SwitchModelUpdate) Where

Where appends a list predicates to the SwitchModelUpdate builder.

type SwitchModelUpdateOne

type SwitchModelUpdateOne struct {
	// contains filtered or unexported fields
}

SwitchModelUpdateOne is the builder for updating a single SwitchModel entity.

func (*SwitchModelUpdateOne) Exec

func (smuo *SwitchModelUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*SwitchModelUpdateOne) ExecX

func (smuo *SwitchModelUpdateOne) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*SwitchModelUpdateOne) Mutation

func (smuo *SwitchModelUpdateOne) Mutation() *SwitchModelMutation

Mutation returns the SwitchModelMutation object of the builder.

func (*SwitchModelUpdateOne) Save

Save executes the query and returns the updated SwitchModel entity.

func (*SwitchModelUpdateOne) SaveX

func (smuo *SwitchModelUpdateOne) SaveX(ctx context.Context) *SwitchModel

SaveX is like Save, but panics if an error occurs.

func (*SwitchModelUpdateOne) Select

func (smuo *SwitchModelUpdateOne) Select(field string, fields ...string) *SwitchModelUpdateOne

Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.

func (*SwitchModelUpdateOne) SetName

SetName sets the "name" field.

func (*SwitchModelUpdateOne) SetSwitchType

SetSwitchType sets the "switch_type" field.

func (*SwitchModelUpdateOne) Where

Where appends a list predicates to the SwitchModelUpdate builder.

type SwitchModels

type SwitchModels []*SwitchModel

SwitchModels is a parsable slice of SwitchModel.

type TraverseFunc

type TraverseFunc = ent.TraverseFunc

ent aliases to avoid import conflicts in user's code.

type Traverser

type Traverser = ent.Traverser

ent aliases to avoid import conflicts in user's code.

type Tx

type Tx struct {

	// Keyboard is the client for interacting with the Keyboard builders.
	Keyboard *KeyboardClient
	// KeycapModel is the client for interacting with the KeycapModel builders.
	KeycapModel *KeycapModelClient
	// SwitchModel is the client for interacting with the SwitchModel builders.
	SwitchModel *SwitchModelClient
	// contains filtered or unexported fields
}

Tx is a transactional client that is created by calling Client.Tx().

func TxFromContext

func TxFromContext(ctx context.Context) *Tx

TxFromContext returns a Tx stored inside a context, or nil if there isn't one.

func (*Tx) Client

func (tx *Tx) Client() *Client

Client returns a Client that binds to current transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) OnCommit

func (tx *Tx) OnCommit(f CommitHook)

OnCommit adds a hook to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f RollbackHook)

OnRollback adds a hook to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

type ValidationError

type ValidationError struct {
	Name string // Field or edge name.
	// contains filtered or unexported fields
}

ValidationError returns when validating a field or edge fails.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Value

type Value = ent.Value

ent aliases to avoid import conflicts in user's code.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL