ent

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 18 Imported by: 0

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.
	TypeCompartment = "Compartment"
	TypeFridge      = "Fridge"
	TypeItem        = "Item"
)

Variables

This section is empty.

Functions

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 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.

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
	// Compartment is the client for interacting with the Compartment builders.
	Compartment *CompartmentClient
	// Fridge is the client for interacting with the Fridge builders.
	Fridge *FridgeClient
	// Item is the client for interacting with the Item builders.
	Item *ItemClient
	// 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().
	Compartment.
	Query().
	Count(ctx)

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(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 Committer method.

type Compartment

type Compartment struct {

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

Compartment is the model entity for the Compartment schema.

func (*Compartment) QueryContents

func (c *Compartment) QueryContents() *ItemQuery

QueryContents queries the "contents" edge of the Compartment entity.

func (*Compartment) QueryFridge

func (c *Compartment) QueryFridge() *FridgeQuery

QueryFridge queries the "fridge" edge of the Compartment entity.

func (*Compartment) String

func (c *Compartment) String() string

String implements the fmt.Stringer.

func (*Compartment) Unwrap

func (c *Compartment) Unwrap() *Compartment

Unwrap unwraps the Compartment 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 (*Compartment) Update

func (c *Compartment) Update() *CompartmentUpdateOne

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

type CompartmentClient

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

CompartmentClient is a client for the Compartment schema.

func NewCompartmentClient

func NewCompartmentClient(c config) *CompartmentClient

NewCompartmentClient returns a client for the Compartment from the given config.

func (*CompartmentClient) Create

func (c *CompartmentClient) Create() *CompartmentCreate

Create returns a create builder for Compartment.

func (*CompartmentClient) CreateBulk

func (c *CompartmentClient) CreateBulk(builders ...*CompartmentCreate) *CompartmentCreateBulk

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

func (*CompartmentClient) Delete

func (c *CompartmentClient) Delete() *CompartmentDelete

Delete returns a delete builder for Compartment.

func (*CompartmentClient) DeleteOne

DeleteOne returns a delete builder for the given entity.

func (*CompartmentClient) DeleteOneID

func (c *CompartmentClient) DeleteOneID(id int) *CompartmentDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*CompartmentClient) Get

func (c *CompartmentClient) Get(ctx context.Context, id int) (*Compartment, error)

Get returns a Compartment entity by its id.

func (*CompartmentClient) GetX

func (c *CompartmentClient) GetX(ctx context.Context, id int) *Compartment

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

func (*CompartmentClient) Hooks

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

Hooks returns the client hooks.

func (*CompartmentClient) Query

func (c *CompartmentClient) Query() *CompartmentQuery

Query returns a query builder for Compartment.

func (*CompartmentClient) QueryContents

func (c *CompartmentClient) QueryContents(co *Compartment) *ItemQuery

QueryContents queries the contents edge of a Compartment.

func (*CompartmentClient) QueryFridge

func (c *CompartmentClient) QueryFridge(co *Compartment) *FridgeQuery

QueryFridge queries the fridge edge of a Compartment.

func (*CompartmentClient) Update

func (c *CompartmentClient) Update() *CompartmentUpdate

Update returns an update builder for Compartment.

func (*CompartmentClient) UpdateOne

UpdateOne returns an update builder for the given entity.

func (*CompartmentClient) UpdateOneID

func (c *CompartmentClient) UpdateOneID(id int) *CompartmentUpdateOne

UpdateOneID returns an update builder for the given id.

func (*CompartmentClient) Use

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

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

type CompartmentCreate

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

CompartmentCreate is the builder for creating a Compartment entity.

func (*CompartmentCreate) AddContentIDs

func (cc *CompartmentCreate) AddContentIDs(ids ...int) *CompartmentCreate

AddContentIDs adds the "contents" edge to the Item entity by IDs.

func (*CompartmentCreate) AddContents

func (cc *CompartmentCreate) AddContents(i ...*Item) *CompartmentCreate

AddContents adds the "contents" edges to the Item entity.

func (*CompartmentCreate) Exec

func (cc *CompartmentCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*CompartmentCreate) ExecX

func (cc *CompartmentCreate) ExecX(ctx context.Context)

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

func (*CompartmentCreate) Mutation

func (cc *CompartmentCreate) Mutation() *CompartmentMutation

Mutation returns the CompartmentMutation object of the builder.

func (*CompartmentCreate) Save

Save creates the Compartment in the database.

func (*CompartmentCreate) SaveX

func (cc *CompartmentCreate) SaveX(ctx context.Context) *Compartment

SaveX calls Save and panics if Save returns an error.

func (*CompartmentCreate) SetFridge

func (cc *CompartmentCreate) SetFridge(f *Fridge) *CompartmentCreate

SetFridge sets the "fridge" edge to the Fridge entity.

func (*CompartmentCreate) SetFridgeID

func (cc *CompartmentCreate) SetFridgeID(id int) *CompartmentCreate

SetFridgeID sets the "fridge" edge to the Fridge entity by ID.

func (*CompartmentCreate) SetName

func (cc *CompartmentCreate) SetName(s string) *CompartmentCreate

SetName sets the "name" field.

func (*CompartmentCreate) SetNillableFridgeID

func (cc *CompartmentCreate) SetNillableFridgeID(id *int) *CompartmentCreate

SetNillableFridgeID sets the "fridge" edge to the Fridge entity by ID if the given value is not nil.

type CompartmentCreateBulk

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

CompartmentCreateBulk is the builder for creating many Compartment entities in bulk.

func (*CompartmentCreateBulk) Exec

func (ccb *CompartmentCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*CompartmentCreateBulk) ExecX

func (ccb *CompartmentCreateBulk) ExecX(ctx context.Context)

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

func (*CompartmentCreateBulk) Save

func (ccb *CompartmentCreateBulk) Save(ctx context.Context) ([]*Compartment, error)

Save creates the Compartment entities in the database.

func (*CompartmentCreateBulk) SaveX

func (ccb *CompartmentCreateBulk) SaveX(ctx context.Context) []*Compartment

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

type CompartmentDelete

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

CompartmentDelete is the builder for deleting a Compartment entity.

func (*CompartmentDelete) Exec

func (cd *CompartmentDelete) Exec(ctx context.Context) (int, error)

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

func (*CompartmentDelete) ExecX

func (cd *CompartmentDelete) ExecX(ctx context.Context) int

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

func (*CompartmentDelete) Where

Where appends a list predicates to the CompartmentDelete builder.

type CompartmentDeleteOne

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

CompartmentDeleteOne is the builder for deleting a single Compartment entity.

func (*CompartmentDeleteOne) Exec

func (cdo *CompartmentDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*CompartmentDeleteOne) ExecX

func (cdo *CompartmentDeleteOne) ExecX(ctx context.Context)

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

type CompartmentEdges

type CompartmentEdges struct {
	// Fridge holds the value of the fridge edge.
	Fridge *Fridge `json:"fridge,omitempty"`
	// Contents holds the value of the contents edge.
	Contents []*Item `json:"contents,omitempty"`
	// contains filtered or unexported fields
}

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

func (CompartmentEdges) ContentsOrErr

func (e CompartmentEdges) ContentsOrErr() ([]*Item, error)

ContentsOrErr returns the Contents value or an error if the edge was not loaded in eager-loading.

func (CompartmentEdges) FridgeOrErr

func (e CompartmentEdges) FridgeOrErr() (*Fridge, error)

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

type CompartmentGroupBy

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

CompartmentGroupBy is the group-by builder for Compartment entities.

func (*CompartmentGroupBy) Aggregate

func (cgb *CompartmentGroupBy) Aggregate(fns ...AggregateFunc) *CompartmentGroupBy

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

func (*CompartmentGroupBy) Bool

func (cgb *CompartmentGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.

func (*CompartmentGroupBy) BoolX

func (cgb *CompartmentGroupBy) BoolX(ctx context.Context) bool

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

func (*CompartmentGroupBy) Bools

func (cgb *CompartmentGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from group-by. It is only allowed when executing a group-by query with one field.

func (*CompartmentGroupBy) BoolsX

func (cgb *CompartmentGroupBy) BoolsX(ctx context.Context) []bool

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

func (*CompartmentGroupBy) Float64

func (cgb *CompartmentGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.

func (*CompartmentGroupBy) Float64X

func (cgb *CompartmentGroupBy) Float64X(ctx context.Context) float64

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

func (*CompartmentGroupBy) Float64s

func (cgb *CompartmentGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from group-by. It is only allowed when executing a group-by query with one field.

func (*CompartmentGroupBy) Float64sX

func (cgb *CompartmentGroupBy) Float64sX(ctx context.Context) []float64

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

func (*CompartmentGroupBy) Int

func (cgb *CompartmentGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.

func (*CompartmentGroupBy) IntX

func (cgb *CompartmentGroupBy) IntX(ctx context.Context) int

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

func (*CompartmentGroupBy) Ints

func (cgb *CompartmentGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from group-by. It is only allowed when executing a group-by query with one field.

func (*CompartmentGroupBy) IntsX

func (cgb *CompartmentGroupBy) IntsX(ctx context.Context) []int

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

func (*CompartmentGroupBy) Scan

func (cgb *CompartmentGroupBy) Scan(ctx context.Context, v interface{}) error

Scan applies the group-by query and scans the result into the given value.

func (*CompartmentGroupBy) ScanX

func (cgb *CompartmentGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*CompartmentGroupBy) String

func (cgb *CompartmentGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.

func (*CompartmentGroupBy) StringX

func (cgb *CompartmentGroupBy) StringX(ctx context.Context) string

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

func (*CompartmentGroupBy) Strings

func (cgb *CompartmentGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from group-by. It is only allowed when executing a group-by query with one field.

func (*CompartmentGroupBy) StringsX

func (cgb *CompartmentGroupBy) StringsX(ctx context.Context) []string

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

type CompartmentMutation

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

CompartmentMutation represents an operation that mutates the Compartment nodes in the graph.

func (*CompartmentMutation) AddContentIDs

func (m *CompartmentMutation) AddContentIDs(ids ...int)

AddContentIDs adds the "contents" edge to the Item entity by ids.

func (*CompartmentMutation) AddField

func (m *CompartmentMutation) 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 (*CompartmentMutation) AddedEdges

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

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

func (*CompartmentMutation) AddedField

func (m *CompartmentMutation) 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 (*CompartmentMutation) AddedFields

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

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

func (*CompartmentMutation) AddedIDs

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

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

func (*CompartmentMutation) ClearContents

func (m *CompartmentMutation) ClearContents()

ClearContents clears the "contents" edge to the Item entity.

func (*CompartmentMutation) ClearEdge

func (m *CompartmentMutation) 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 (*CompartmentMutation) ClearField

func (m *CompartmentMutation) 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 (*CompartmentMutation) ClearFridge

func (m *CompartmentMutation) ClearFridge()

ClearFridge clears the "fridge" edge to the Fridge entity.

func (*CompartmentMutation) ClearedEdges

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

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

func (*CompartmentMutation) ClearedFields

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

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

func (CompartmentMutation) Client

func (m CompartmentMutation) 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 (*CompartmentMutation) ContentsCleared

func (m *CompartmentMutation) ContentsCleared() bool

ContentsCleared reports if the "contents" edge to the Item entity was cleared.

func (*CompartmentMutation) ContentsIDs

func (m *CompartmentMutation) ContentsIDs() (ids []int)

ContentsIDs returns the "contents" edge IDs in the mutation.

func (*CompartmentMutation) EdgeCleared

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

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

func (*CompartmentMutation) Field

func (m *CompartmentMutation) 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 (*CompartmentMutation) FieldCleared

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

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

func (*CompartmentMutation) Fields

func (m *CompartmentMutation) 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 (*CompartmentMutation) FridgeCleared

func (m *CompartmentMutation) FridgeCleared() bool

FridgeCleared reports if the "fridge" edge to the Fridge entity was cleared.

func (*CompartmentMutation) FridgeID

func (m *CompartmentMutation) FridgeID() (id int, exists bool)

FridgeID returns the "fridge" edge ID in the mutation.

func (*CompartmentMutation) FridgeIDs

func (m *CompartmentMutation) FridgeIDs() (ids []int)

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

func (*CompartmentMutation) ID

func (m *CompartmentMutation) ID() (id int, 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 (*CompartmentMutation) Name

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

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

func (*CompartmentMutation) OldField

func (m *CompartmentMutation) 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 (*CompartmentMutation) OldName

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

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

func (m *CompartmentMutation) Op() Op

Op returns the operation name.

func (*CompartmentMutation) RemoveContentIDs

func (m *CompartmentMutation) RemoveContentIDs(ids ...int)

RemoveContentIDs removes the "contents" edge to the Item entity by IDs.

func (*CompartmentMutation) RemovedContentsIDs

func (m *CompartmentMutation) RemovedContentsIDs() (ids []int)

RemovedContents returns the removed IDs of the "contents" edge to the Item entity.

func (*CompartmentMutation) RemovedEdges

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

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

func (*CompartmentMutation) RemovedIDs

func (m *CompartmentMutation) 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 (*CompartmentMutation) ResetContents

func (m *CompartmentMutation) ResetContents()

ResetContents resets all changes to the "contents" edge.

func (*CompartmentMutation) ResetEdge

func (m *CompartmentMutation) 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 (*CompartmentMutation) ResetField

func (m *CompartmentMutation) 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 (*CompartmentMutation) ResetFridge

func (m *CompartmentMutation) ResetFridge()

ResetFridge resets all changes to the "fridge" edge.

func (*CompartmentMutation) ResetName

func (m *CompartmentMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*CompartmentMutation) SetField

func (m *CompartmentMutation) 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 (*CompartmentMutation) SetFridgeID

func (m *CompartmentMutation) SetFridgeID(id int)

SetFridgeID sets the "fridge" edge to the Fridge entity by id.

func (*CompartmentMutation) SetName

func (m *CompartmentMutation) SetName(s string)

SetName sets the "name" field.

func (CompartmentMutation) Tx

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

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

func (*CompartmentMutation) Type

func (m *CompartmentMutation) Type() string

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

func (*CompartmentMutation) Where

func (m *CompartmentMutation) Where(ps ...predicate.Compartment)

Where appends a list predicates to the CompartmentMutation builder.

type CompartmentQuery

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

CompartmentQuery is the builder for querying Compartment entities.

func (*CompartmentQuery) All

func (cq *CompartmentQuery) All(ctx context.Context) ([]*Compartment, error)

All executes the query and returns a list of Compartments.

func (*CompartmentQuery) AllX

func (cq *CompartmentQuery) AllX(ctx context.Context) []*Compartment

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

func (*CompartmentQuery) Clone

func (cq *CompartmentQuery) Clone() *CompartmentQuery

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

func (*CompartmentQuery) Count

func (cq *CompartmentQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*CompartmentQuery) CountX

func (cq *CompartmentQuery) CountX(ctx context.Context) int

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

func (*CompartmentQuery) Exist

func (cq *CompartmentQuery) Exist(ctx context.Context) (bool, error)

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

func (*CompartmentQuery) ExistX

func (cq *CompartmentQuery) ExistX(ctx context.Context) bool

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

func (*CompartmentQuery) First

func (cq *CompartmentQuery) First(ctx context.Context) (*Compartment, error)

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

func (*CompartmentQuery) FirstID

func (cq *CompartmentQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*CompartmentQuery) FirstIDX

func (cq *CompartmentQuery) FirstIDX(ctx context.Context) int

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

func (*CompartmentQuery) FirstX

func (cq *CompartmentQuery) FirstX(ctx context.Context) *Compartment

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

func (*CompartmentQuery) GroupBy

func (cq *CompartmentQuery) GroupBy(field string, fields ...string) *CompartmentGroupBy

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.Compartment.Query().
	GroupBy(compartment.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*CompartmentQuery) IDs

func (cq *CompartmentQuery) IDs(ctx context.Context) ([]int, error)

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

func (*CompartmentQuery) IDsX

func (cq *CompartmentQuery) IDsX(ctx context.Context) []int

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

func (*CompartmentQuery) Limit

func (cq *CompartmentQuery) Limit(limit int) *CompartmentQuery

Limit adds a limit step to the query.

func (*CompartmentQuery) Offset

func (cq *CompartmentQuery) Offset(offset int) *CompartmentQuery

Offset adds an offset step to the query.

func (*CompartmentQuery) Only

func (cq *CompartmentQuery) Only(ctx context.Context) (*Compartment, error)

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

func (*CompartmentQuery) OnlyID

func (cq *CompartmentQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*CompartmentQuery) OnlyIDX

func (cq *CompartmentQuery) OnlyIDX(ctx context.Context) int

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

func (*CompartmentQuery) OnlyX

func (cq *CompartmentQuery) OnlyX(ctx context.Context) *Compartment

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

func (*CompartmentQuery) Order

func (cq *CompartmentQuery) Order(o ...OrderFunc) *CompartmentQuery

Order adds an order step to the query.

func (*CompartmentQuery) QueryContents

func (cq *CompartmentQuery) QueryContents() *ItemQuery

QueryContents chains the current query on the "contents" edge.

func (*CompartmentQuery) QueryFridge

func (cq *CompartmentQuery) QueryFridge() *FridgeQuery

QueryFridge chains the current query on the "fridge" edge.

func (*CompartmentQuery) Select

func (cq *CompartmentQuery) Select(fields ...string) *CompartmentSelect

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.Compartment.Query().
	Select(compartment.FieldName).
	Scan(ctx, &v)

func (*CompartmentQuery) Unique

func (cq *CompartmentQuery) Unique(unique bool) *CompartmentQuery

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 (*CompartmentQuery) Where

Where adds a new predicate for the CompartmentQuery builder.

func (*CompartmentQuery) WithContents

func (cq *CompartmentQuery) WithContents(opts ...func(*ItemQuery)) *CompartmentQuery

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

func (*CompartmentQuery) WithFridge

func (cq *CompartmentQuery) WithFridge(opts ...func(*FridgeQuery)) *CompartmentQuery

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

type CompartmentSelect

type CompartmentSelect struct {
	*CompartmentQuery
	// contains filtered or unexported fields
}

CompartmentSelect is the builder for selecting fields of Compartment entities.

func (*CompartmentSelect) Bool

func (cs *CompartmentSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*CompartmentSelect) BoolX

func (cs *CompartmentSelect) BoolX(ctx context.Context) bool

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

func (*CompartmentSelect) Bools

func (cs *CompartmentSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*CompartmentSelect) BoolsX

func (cs *CompartmentSelect) BoolsX(ctx context.Context) []bool

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

func (*CompartmentSelect) Float64

func (cs *CompartmentSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*CompartmentSelect) Float64X

func (cs *CompartmentSelect) Float64X(ctx context.Context) float64

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

func (*CompartmentSelect) Float64s

func (cs *CompartmentSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*CompartmentSelect) Float64sX

func (cs *CompartmentSelect) Float64sX(ctx context.Context) []float64

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

func (*CompartmentSelect) Int

func (cs *CompartmentSelect) Int(ctx context.Context) (_ int, err error)

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

func (*CompartmentSelect) IntX

func (cs *CompartmentSelect) IntX(ctx context.Context) int

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

func (*CompartmentSelect) Ints

func (cs *CompartmentSelect) Ints(ctx context.Context) ([]int, error)

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

func (*CompartmentSelect) IntsX

func (cs *CompartmentSelect) IntsX(ctx context.Context) []int

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

func (*CompartmentSelect) Scan

func (cs *CompartmentSelect) Scan(ctx context.Context, v interface{}) error

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

func (*CompartmentSelect) ScanX

func (cs *CompartmentSelect) ScanX(ctx context.Context, v interface{})

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

func (*CompartmentSelect) String

func (cs *CompartmentSelect) String(ctx context.Context) (_ string, err error)

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

func (*CompartmentSelect) StringX

func (cs *CompartmentSelect) StringX(ctx context.Context) string

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

func (*CompartmentSelect) Strings

func (cs *CompartmentSelect) Strings(ctx context.Context) ([]string, error)

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

func (*CompartmentSelect) StringsX

func (cs *CompartmentSelect) StringsX(ctx context.Context) []string

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

type CompartmentUpdate

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

CompartmentUpdate is the builder for updating Compartment entities.

func (*CompartmentUpdate) AddContentIDs

func (cu *CompartmentUpdate) AddContentIDs(ids ...int) *CompartmentUpdate

AddContentIDs adds the "contents" edge to the Item entity by IDs.

func (*CompartmentUpdate) AddContents

func (cu *CompartmentUpdate) AddContents(i ...*Item) *CompartmentUpdate

AddContents adds the "contents" edges to the Item entity.

func (*CompartmentUpdate) ClearContents

func (cu *CompartmentUpdate) ClearContents() *CompartmentUpdate

ClearContents clears all "contents" edges to the Item entity.

func (*CompartmentUpdate) ClearFridge

func (cu *CompartmentUpdate) ClearFridge() *CompartmentUpdate

ClearFridge clears the "fridge" edge to the Fridge entity.

func (*CompartmentUpdate) Exec

func (cu *CompartmentUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*CompartmentUpdate) ExecX

func (cu *CompartmentUpdate) ExecX(ctx context.Context)

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

func (*CompartmentUpdate) Mutation

func (cu *CompartmentUpdate) Mutation() *CompartmentMutation

Mutation returns the CompartmentMutation object of the builder.

func (*CompartmentUpdate) RemoveContentIDs

func (cu *CompartmentUpdate) RemoveContentIDs(ids ...int) *CompartmentUpdate

RemoveContentIDs removes the "contents" edge to Item entities by IDs.

func (*CompartmentUpdate) RemoveContents

func (cu *CompartmentUpdate) RemoveContents(i ...*Item) *CompartmentUpdate

RemoveContents removes "contents" edges to Item entities.

func (*CompartmentUpdate) Save

func (cu *CompartmentUpdate) Save(ctx context.Context) (int, error)

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

func (*CompartmentUpdate) SaveX

func (cu *CompartmentUpdate) SaveX(ctx context.Context) int

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

func (*CompartmentUpdate) SetFridge

func (cu *CompartmentUpdate) SetFridge(f *Fridge) *CompartmentUpdate

SetFridge sets the "fridge" edge to the Fridge entity.

func (*CompartmentUpdate) SetFridgeID

func (cu *CompartmentUpdate) SetFridgeID(id int) *CompartmentUpdate

SetFridgeID sets the "fridge" edge to the Fridge entity by ID.

func (*CompartmentUpdate) SetName

func (cu *CompartmentUpdate) SetName(s string) *CompartmentUpdate

SetName sets the "name" field.

func (*CompartmentUpdate) SetNillableFridgeID

func (cu *CompartmentUpdate) SetNillableFridgeID(id *int) *CompartmentUpdate

SetNillableFridgeID sets the "fridge" edge to the Fridge entity by ID if the given value is not nil.

func (*CompartmentUpdate) Where

Where appends a list predicates to the CompartmentUpdate builder.

type CompartmentUpdateOne

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

CompartmentUpdateOne is the builder for updating a single Compartment entity.

func (*CompartmentUpdateOne) AddContentIDs

func (cuo *CompartmentUpdateOne) AddContentIDs(ids ...int) *CompartmentUpdateOne

AddContentIDs adds the "contents" edge to the Item entity by IDs.

func (*CompartmentUpdateOne) AddContents

func (cuo *CompartmentUpdateOne) AddContents(i ...*Item) *CompartmentUpdateOne

AddContents adds the "contents" edges to the Item entity.

func (*CompartmentUpdateOne) ClearContents

func (cuo *CompartmentUpdateOne) ClearContents() *CompartmentUpdateOne

ClearContents clears all "contents" edges to the Item entity.

func (*CompartmentUpdateOne) ClearFridge

func (cuo *CompartmentUpdateOne) ClearFridge() *CompartmentUpdateOne

ClearFridge clears the "fridge" edge to the Fridge entity.

func (*CompartmentUpdateOne) Exec

func (cuo *CompartmentUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*CompartmentUpdateOne) ExecX

func (cuo *CompartmentUpdateOne) ExecX(ctx context.Context)

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

func (*CompartmentUpdateOne) Mutation

func (cuo *CompartmentUpdateOne) Mutation() *CompartmentMutation

Mutation returns the CompartmentMutation object of the builder.

func (*CompartmentUpdateOne) RemoveContentIDs

func (cuo *CompartmentUpdateOne) RemoveContentIDs(ids ...int) *CompartmentUpdateOne

RemoveContentIDs removes the "contents" edge to Item entities by IDs.

func (*CompartmentUpdateOne) RemoveContents

func (cuo *CompartmentUpdateOne) RemoveContents(i ...*Item) *CompartmentUpdateOne

RemoveContents removes "contents" edges to Item entities.

func (*CompartmentUpdateOne) Save

Save executes the query and returns the updated Compartment entity.

func (*CompartmentUpdateOne) SaveX

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

func (*CompartmentUpdateOne) Select

func (cuo *CompartmentUpdateOne) Select(field string, fields ...string) *CompartmentUpdateOne

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

func (*CompartmentUpdateOne) SetFridge

func (cuo *CompartmentUpdateOne) SetFridge(f *Fridge) *CompartmentUpdateOne

SetFridge sets the "fridge" edge to the Fridge entity.

func (*CompartmentUpdateOne) SetFridgeID

func (cuo *CompartmentUpdateOne) SetFridgeID(id int) *CompartmentUpdateOne

SetFridgeID sets the "fridge" edge to the Fridge entity by ID.

func (*CompartmentUpdateOne) SetName

SetName sets the "name" field.

func (*CompartmentUpdateOne) SetNillableFridgeID

func (cuo *CompartmentUpdateOne) SetNillableFridgeID(id *int) *CompartmentUpdateOne

SetNillableFridgeID sets the "fridge" edge to the Fridge entity by ID if the given value is not nil.

type Compartments

type Compartments []*Compartment

Compartments is a parsable slice of Compartment.

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 Fridge

type Fridge struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Title holds the value of the "title" field.
	Title string `json:"title,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the FridgeQuery when eager-loading is set.
	Edges FridgeEdges `json:"edges"`
	// contains filtered or unexported fields
}

Fridge is the model entity for the Fridge schema.

func (*Fridge) QueryCompartments

func (f *Fridge) QueryCompartments() *CompartmentQuery

QueryCompartments queries the "compartments" edge of the Fridge entity.

func (*Fridge) String

func (f *Fridge) String() string

String implements the fmt.Stringer.

func (*Fridge) Unwrap

func (f *Fridge) Unwrap() *Fridge

Unwrap unwraps the Fridge 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 (*Fridge) Update

func (f *Fridge) Update() *FridgeUpdateOne

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

type FridgeClient

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

FridgeClient is a client for the Fridge schema.

func NewFridgeClient

func NewFridgeClient(c config) *FridgeClient

NewFridgeClient returns a client for the Fridge from the given config.

func (*FridgeClient) Create

func (c *FridgeClient) Create() *FridgeCreate

Create returns a create builder for Fridge.

func (*FridgeClient) CreateBulk

func (c *FridgeClient) CreateBulk(builders ...*FridgeCreate) *FridgeCreateBulk

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

func (*FridgeClient) Delete

func (c *FridgeClient) Delete() *FridgeDelete

Delete returns a delete builder for Fridge.

func (*FridgeClient) DeleteOne

func (c *FridgeClient) DeleteOne(f *Fridge) *FridgeDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*FridgeClient) DeleteOneID

func (c *FridgeClient) DeleteOneID(id int) *FridgeDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*FridgeClient) Get

func (c *FridgeClient) Get(ctx context.Context, id int) (*Fridge, error)

Get returns a Fridge entity by its id.

func (*FridgeClient) GetX

func (c *FridgeClient) GetX(ctx context.Context, id int) *Fridge

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

func (*FridgeClient) Hooks

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

Hooks returns the client hooks.

func (*FridgeClient) Query

func (c *FridgeClient) Query() *FridgeQuery

Query returns a query builder for Fridge.

func (*FridgeClient) QueryCompartments

func (c *FridgeClient) QueryCompartments(f *Fridge) *CompartmentQuery

QueryCompartments queries the compartments edge of a Fridge.

func (*FridgeClient) Update

func (c *FridgeClient) Update() *FridgeUpdate

Update returns an update builder for Fridge.

func (*FridgeClient) UpdateOne

func (c *FridgeClient) UpdateOne(f *Fridge) *FridgeUpdateOne

UpdateOne returns an update builder for the given entity.

func (*FridgeClient) UpdateOneID

func (c *FridgeClient) UpdateOneID(id int) *FridgeUpdateOne

UpdateOneID returns an update builder for the given id.

func (*FridgeClient) Use

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

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

type FridgeCreate

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

FridgeCreate is the builder for creating a Fridge entity.

func (*FridgeCreate) AddCompartmentIDs

func (fc *FridgeCreate) AddCompartmentIDs(ids ...int) *FridgeCreate

AddCompartmentIDs adds the "compartments" edge to the Compartment entity by IDs.

func (*FridgeCreate) AddCompartments

func (fc *FridgeCreate) AddCompartments(c ...*Compartment) *FridgeCreate

AddCompartments adds the "compartments" edges to the Compartment entity.

func (*FridgeCreate) Exec

func (fc *FridgeCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*FridgeCreate) ExecX

func (fc *FridgeCreate) ExecX(ctx context.Context)

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

func (*FridgeCreate) Mutation

func (fc *FridgeCreate) Mutation() *FridgeMutation

Mutation returns the FridgeMutation object of the builder.

func (*FridgeCreate) Save

func (fc *FridgeCreate) Save(ctx context.Context) (*Fridge, error)

Save creates the Fridge in the database.

func (*FridgeCreate) SaveX

func (fc *FridgeCreate) SaveX(ctx context.Context) *Fridge

SaveX calls Save and panics if Save returns an error.

func (*FridgeCreate) SetTitle

func (fc *FridgeCreate) SetTitle(s string) *FridgeCreate

SetTitle sets the "title" field.

type FridgeCreateBulk

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

FridgeCreateBulk is the builder for creating many Fridge entities in bulk.

func (*FridgeCreateBulk) Exec

func (fcb *FridgeCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*FridgeCreateBulk) ExecX

func (fcb *FridgeCreateBulk) ExecX(ctx context.Context)

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

func (*FridgeCreateBulk) Save

func (fcb *FridgeCreateBulk) Save(ctx context.Context) ([]*Fridge, error)

Save creates the Fridge entities in the database.

func (*FridgeCreateBulk) SaveX

func (fcb *FridgeCreateBulk) SaveX(ctx context.Context) []*Fridge

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

type FridgeDelete

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

FridgeDelete is the builder for deleting a Fridge entity.

func (*FridgeDelete) Exec

func (fd *FridgeDelete) Exec(ctx context.Context) (int, error)

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

func (*FridgeDelete) ExecX

func (fd *FridgeDelete) ExecX(ctx context.Context) int

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

func (*FridgeDelete) Where

func (fd *FridgeDelete) Where(ps ...predicate.Fridge) *FridgeDelete

Where appends a list predicates to the FridgeDelete builder.

type FridgeDeleteOne

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

FridgeDeleteOne is the builder for deleting a single Fridge entity.

func (*FridgeDeleteOne) Exec

func (fdo *FridgeDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*FridgeDeleteOne) ExecX

func (fdo *FridgeDeleteOne) ExecX(ctx context.Context)

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

type FridgeEdges

type FridgeEdges struct {
	// Compartments holds the value of the compartments edge.
	Compartments []*Compartment `json:"compartments,omitempty"`
	// contains filtered or unexported fields
}

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

func (FridgeEdges) CompartmentsOrErr

func (e FridgeEdges) CompartmentsOrErr() ([]*Compartment, error)

CompartmentsOrErr returns the Compartments value or an error if the edge was not loaded in eager-loading.

type FridgeGroupBy

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

FridgeGroupBy is the group-by builder for Fridge entities.

func (*FridgeGroupBy) Aggregate

func (fgb *FridgeGroupBy) Aggregate(fns ...AggregateFunc) *FridgeGroupBy

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

func (*FridgeGroupBy) Bool

func (fgb *FridgeGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.

func (*FridgeGroupBy) BoolX

func (fgb *FridgeGroupBy) BoolX(ctx context.Context) bool

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

func (*FridgeGroupBy) Bools

func (fgb *FridgeGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from group-by. It is only allowed when executing a group-by query with one field.

func (*FridgeGroupBy) BoolsX

func (fgb *FridgeGroupBy) BoolsX(ctx context.Context) []bool

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

func (*FridgeGroupBy) Float64

func (fgb *FridgeGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.

func (*FridgeGroupBy) Float64X

func (fgb *FridgeGroupBy) Float64X(ctx context.Context) float64

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

func (*FridgeGroupBy) Float64s

func (fgb *FridgeGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from group-by. It is only allowed when executing a group-by query with one field.

func (*FridgeGroupBy) Float64sX

func (fgb *FridgeGroupBy) Float64sX(ctx context.Context) []float64

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

func (*FridgeGroupBy) Int

func (fgb *FridgeGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.

func (*FridgeGroupBy) IntX

func (fgb *FridgeGroupBy) IntX(ctx context.Context) int

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

func (*FridgeGroupBy) Ints

func (fgb *FridgeGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from group-by. It is only allowed when executing a group-by query with one field.

func (*FridgeGroupBy) IntsX

func (fgb *FridgeGroupBy) IntsX(ctx context.Context) []int

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

func (*FridgeGroupBy) Scan

func (fgb *FridgeGroupBy) Scan(ctx context.Context, v interface{}) error

Scan applies the group-by query and scans the result into the given value.

func (*FridgeGroupBy) ScanX

func (fgb *FridgeGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*FridgeGroupBy) String

func (fgb *FridgeGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.

func (*FridgeGroupBy) StringX

func (fgb *FridgeGroupBy) StringX(ctx context.Context) string

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

func (*FridgeGroupBy) Strings

func (fgb *FridgeGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from group-by. It is only allowed when executing a group-by query with one field.

func (*FridgeGroupBy) StringsX

func (fgb *FridgeGroupBy) StringsX(ctx context.Context) []string

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

type FridgeMutation

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

FridgeMutation represents an operation that mutates the Fridge nodes in the graph.

func (*FridgeMutation) AddCompartmentIDs

func (m *FridgeMutation) AddCompartmentIDs(ids ...int)

AddCompartmentIDs adds the "compartments" edge to the Compartment entity by ids.

func (*FridgeMutation) AddField

func (m *FridgeMutation) 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 (*FridgeMutation) AddedEdges

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

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

func (*FridgeMutation) AddedField

func (m *FridgeMutation) 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 (*FridgeMutation) AddedFields

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

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

func (*FridgeMutation) AddedIDs

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

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

func (*FridgeMutation) ClearCompartments

func (m *FridgeMutation) ClearCompartments()

ClearCompartments clears the "compartments" edge to the Compartment entity.

func (*FridgeMutation) ClearEdge

func (m *FridgeMutation) 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 (*FridgeMutation) ClearField

func (m *FridgeMutation) 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 (*FridgeMutation) ClearedEdges

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

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

func (*FridgeMutation) ClearedFields

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

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

func (FridgeMutation) Client

func (m FridgeMutation) 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 (*FridgeMutation) CompartmentsCleared

func (m *FridgeMutation) CompartmentsCleared() bool

CompartmentsCleared reports if the "compartments" edge to the Compartment entity was cleared.

func (*FridgeMutation) CompartmentsIDs

func (m *FridgeMutation) CompartmentsIDs() (ids []int)

CompartmentsIDs returns the "compartments" edge IDs in the mutation.

func (*FridgeMutation) EdgeCleared

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

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

func (*FridgeMutation) Field

func (m *FridgeMutation) 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 (*FridgeMutation) FieldCleared

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

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

func (*FridgeMutation) Fields

func (m *FridgeMutation) 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 (*FridgeMutation) ID

func (m *FridgeMutation) ID() (id int, 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 (*FridgeMutation) OldField

func (m *FridgeMutation) 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 (*FridgeMutation) OldTitle

func (m *FridgeMutation) OldTitle(ctx context.Context) (v string, err error)

OldTitle returns the old "title" field's value of the Fridge entity. If the Fridge 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 (*FridgeMutation) Op

func (m *FridgeMutation) Op() Op

Op returns the operation name.

func (*FridgeMutation) RemoveCompartmentIDs

func (m *FridgeMutation) RemoveCompartmentIDs(ids ...int)

RemoveCompartmentIDs removes the "compartments" edge to the Compartment entity by IDs.

func (*FridgeMutation) RemovedCompartmentsIDs

func (m *FridgeMutation) RemovedCompartmentsIDs() (ids []int)

RemovedCompartments returns the removed IDs of the "compartments" edge to the Compartment entity.

func (*FridgeMutation) RemovedEdges

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

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

func (*FridgeMutation) RemovedIDs

func (m *FridgeMutation) 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 (*FridgeMutation) ResetCompartments

func (m *FridgeMutation) ResetCompartments()

ResetCompartments resets all changes to the "compartments" edge.

func (*FridgeMutation) ResetEdge

func (m *FridgeMutation) 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 (*FridgeMutation) ResetField

func (m *FridgeMutation) 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 (*FridgeMutation) ResetTitle

func (m *FridgeMutation) ResetTitle()

ResetTitle resets all changes to the "title" field.

func (*FridgeMutation) SetField

func (m *FridgeMutation) 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 (*FridgeMutation) SetTitle

func (m *FridgeMutation) SetTitle(s string)

SetTitle sets the "title" field.

func (*FridgeMutation) Title

func (m *FridgeMutation) Title() (r string, exists bool)

Title returns the value of the "title" field in the mutation.

func (FridgeMutation) Tx

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

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

func (*FridgeMutation) Type

func (m *FridgeMutation) Type() string

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

func (*FridgeMutation) Where

func (m *FridgeMutation) Where(ps ...predicate.Fridge)

Where appends a list predicates to the FridgeMutation builder.

type FridgeQuery

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

FridgeQuery is the builder for querying Fridge entities.

func (*FridgeQuery) All

func (fq *FridgeQuery) All(ctx context.Context) ([]*Fridge, error)

All executes the query and returns a list of Fridges.

func (*FridgeQuery) AllX

func (fq *FridgeQuery) AllX(ctx context.Context) []*Fridge

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

func (*FridgeQuery) Clone

func (fq *FridgeQuery) Clone() *FridgeQuery

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

func (*FridgeQuery) Count

func (fq *FridgeQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*FridgeQuery) CountX

func (fq *FridgeQuery) CountX(ctx context.Context) int

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

func (*FridgeQuery) Exist

func (fq *FridgeQuery) Exist(ctx context.Context) (bool, error)

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

func (*FridgeQuery) ExistX

func (fq *FridgeQuery) ExistX(ctx context.Context) bool

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

func (*FridgeQuery) First

func (fq *FridgeQuery) First(ctx context.Context) (*Fridge, error)

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

func (*FridgeQuery) FirstID

func (fq *FridgeQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*FridgeQuery) FirstIDX

func (fq *FridgeQuery) FirstIDX(ctx context.Context) int

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

func (*FridgeQuery) FirstX

func (fq *FridgeQuery) FirstX(ctx context.Context) *Fridge

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

func (*FridgeQuery) GroupBy

func (fq *FridgeQuery) GroupBy(field string, fields ...string) *FridgeGroupBy

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 {
	Title string `json:"title,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Fridge.Query().
	GroupBy(fridge.FieldTitle).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*FridgeQuery) IDs

func (fq *FridgeQuery) IDs(ctx context.Context) ([]int, error)

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

func (*FridgeQuery) IDsX

func (fq *FridgeQuery) IDsX(ctx context.Context) []int

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

func (*FridgeQuery) Limit

func (fq *FridgeQuery) Limit(limit int) *FridgeQuery

Limit adds a limit step to the query.

func (*FridgeQuery) Offset

func (fq *FridgeQuery) Offset(offset int) *FridgeQuery

Offset adds an offset step to the query.

func (*FridgeQuery) Only

func (fq *FridgeQuery) Only(ctx context.Context) (*Fridge, error)

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

func (*FridgeQuery) OnlyID

func (fq *FridgeQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*FridgeQuery) OnlyIDX

func (fq *FridgeQuery) OnlyIDX(ctx context.Context) int

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

func (*FridgeQuery) OnlyX

func (fq *FridgeQuery) OnlyX(ctx context.Context) *Fridge

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

func (*FridgeQuery) Order

func (fq *FridgeQuery) Order(o ...OrderFunc) *FridgeQuery

Order adds an order step to the query.

func (*FridgeQuery) QueryCompartments

func (fq *FridgeQuery) QueryCompartments() *CompartmentQuery

QueryCompartments chains the current query on the "compartments" edge.

func (*FridgeQuery) Select

func (fq *FridgeQuery) Select(fields ...string) *FridgeSelect

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 {
	Title string `json:"title,omitempty"`
}

client.Fridge.Query().
	Select(fridge.FieldTitle).
	Scan(ctx, &v)

func (*FridgeQuery) Unique

func (fq *FridgeQuery) Unique(unique bool) *FridgeQuery

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 (*FridgeQuery) Where

func (fq *FridgeQuery) Where(ps ...predicate.Fridge) *FridgeQuery

Where adds a new predicate for the FridgeQuery builder.

func (*FridgeQuery) WithCompartments

func (fq *FridgeQuery) WithCompartments(opts ...func(*CompartmentQuery)) *FridgeQuery

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

type FridgeSelect

type FridgeSelect struct {
	*FridgeQuery
	// contains filtered or unexported fields
}

FridgeSelect is the builder for selecting fields of Fridge entities.

func (*FridgeSelect) Bool

func (fs *FridgeSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*FridgeSelect) BoolX

func (fs *FridgeSelect) BoolX(ctx context.Context) bool

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

func (*FridgeSelect) Bools

func (fs *FridgeSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*FridgeSelect) BoolsX

func (fs *FridgeSelect) BoolsX(ctx context.Context) []bool

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

func (*FridgeSelect) Float64

func (fs *FridgeSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*FridgeSelect) Float64X

func (fs *FridgeSelect) Float64X(ctx context.Context) float64

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

func (*FridgeSelect) Float64s

func (fs *FridgeSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*FridgeSelect) Float64sX

func (fs *FridgeSelect) Float64sX(ctx context.Context) []float64

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

func (*FridgeSelect) Int

func (fs *FridgeSelect) Int(ctx context.Context) (_ int, err error)

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

func (*FridgeSelect) IntX

func (fs *FridgeSelect) IntX(ctx context.Context) int

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

func (*FridgeSelect) Ints

func (fs *FridgeSelect) Ints(ctx context.Context) ([]int, error)

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

func (*FridgeSelect) IntsX

func (fs *FridgeSelect) IntsX(ctx context.Context) []int

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

func (*FridgeSelect) Scan

func (fs *FridgeSelect) Scan(ctx context.Context, v interface{}) error

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

func (*FridgeSelect) ScanX

func (fs *FridgeSelect) ScanX(ctx context.Context, v interface{})

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

func (*FridgeSelect) String

func (fs *FridgeSelect) String(ctx context.Context) (_ string, err error)

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

func (*FridgeSelect) StringX

func (fs *FridgeSelect) StringX(ctx context.Context) string

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

func (*FridgeSelect) Strings

func (fs *FridgeSelect) Strings(ctx context.Context) ([]string, error)

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

func (*FridgeSelect) StringsX

func (fs *FridgeSelect) StringsX(ctx context.Context) []string

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

type FridgeUpdate

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

FridgeUpdate is the builder for updating Fridge entities.

func (*FridgeUpdate) AddCompartmentIDs

func (fu *FridgeUpdate) AddCompartmentIDs(ids ...int) *FridgeUpdate

AddCompartmentIDs adds the "compartments" edge to the Compartment entity by IDs.

func (*FridgeUpdate) AddCompartments

func (fu *FridgeUpdate) AddCompartments(c ...*Compartment) *FridgeUpdate

AddCompartments adds the "compartments" edges to the Compartment entity.

func (*FridgeUpdate) ClearCompartments

func (fu *FridgeUpdate) ClearCompartments() *FridgeUpdate

ClearCompartments clears all "compartments" edges to the Compartment entity.

func (*FridgeUpdate) Exec

func (fu *FridgeUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*FridgeUpdate) ExecX

func (fu *FridgeUpdate) ExecX(ctx context.Context)

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

func (*FridgeUpdate) Mutation

func (fu *FridgeUpdate) Mutation() *FridgeMutation

Mutation returns the FridgeMutation object of the builder.

func (*FridgeUpdate) RemoveCompartmentIDs

func (fu *FridgeUpdate) RemoveCompartmentIDs(ids ...int) *FridgeUpdate

RemoveCompartmentIDs removes the "compartments" edge to Compartment entities by IDs.

func (*FridgeUpdate) RemoveCompartments

func (fu *FridgeUpdate) RemoveCompartments(c ...*Compartment) *FridgeUpdate

RemoveCompartments removes "compartments" edges to Compartment entities.

func (*FridgeUpdate) Save

func (fu *FridgeUpdate) Save(ctx context.Context) (int, error)

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

func (*FridgeUpdate) SaveX

func (fu *FridgeUpdate) SaveX(ctx context.Context) int

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

func (*FridgeUpdate) SetTitle

func (fu *FridgeUpdate) SetTitle(s string) *FridgeUpdate

SetTitle sets the "title" field.

func (*FridgeUpdate) Where

func (fu *FridgeUpdate) Where(ps ...predicate.Fridge) *FridgeUpdate

Where appends a list predicates to the FridgeUpdate builder.

type FridgeUpdateOne

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

FridgeUpdateOne is the builder for updating a single Fridge entity.

func (*FridgeUpdateOne) AddCompartmentIDs

func (fuo *FridgeUpdateOne) AddCompartmentIDs(ids ...int) *FridgeUpdateOne

AddCompartmentIDs adds the "compartments" edge to the Compartment entity by IDs.

func (*FridgeUpdateOne) AddCompartments

func (fuo *FridgeUpdateOne) AddCompartments(c ...*Compartment) *FridgeUpdateOne

AddCompartments adds the "compartments" edges to the Compartment entity.

func (*FridgeUpdateOne) ClearCompartments

func (fuo *FridgeUpdateOne) ClearCompartments() *FridgeUpdateOne

ClearCompartments clears all "compartments" edges to the Compartment entity.

func (*FridgeUpdateOne) Exec

func (fuo *FridgeUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*FridgeUpdateOne) ExecX

func (fuo *FridgeUpdateOne) ExecX(ctx context.Context)

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

func (*FridgeUpdateOne) Mutation

func (fuo *FridgeUpdateOne) Mutation() *FridgeMutation

Mutation returns the FridgeMutation object of the builder.

func (*FridgeUpdateOne) RemoveCompartmentIDs

func (fuo *FridgeUpdateOne) RemoveCompartmentIDs(ids ...int) *FridgeUpdateOne

RemoveCompartmentIDs removes the "compartments" edge to Compartment entities by IDs.

func (*FridgeUpdateOne) RemoveCompartments

func (fuo *FridgeUpdateOne) RemoveCompartments(c ...*Compartment) *FridgeUpdateOne

RemoveCompartments removes "compartments" edges to Compartment entities.

func (*FridgeUpdateOne) Save

func (fuo *FridgeUpdateOne) Save(ctx context.Context) (*Fridge, error)

Save executes the query and returns the updated Fridge entity.

func (*FridgeUpdateOne) SaveX

func (fuo *FridgeUpdateOne) SaveX(ctx context.Context) *Fridge

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

func (*FridgeUpdateOne) Select

func (fuo *FridgeUpdateOne) Select(field string, fields ...string) *FridgeUpdateOne

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

func (*FridgeUpdateOne) SetTitle

func (fuo *FridgeUpdateOne) SetTitle(s string) *FridgeUpdateOne

SetTitle sets the "title" field.

type Fridges

type Fridges []*Fridge

Fridges is a parsable slice of Fridge.

type Hook

type Hook = ent.Hook

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

type Item

type Item struct {

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

Item is the model entity for the Item schema.

func (*Item) QueryCompartment

func (i *Item) QueryCompartment() *CompartmentQuery

QueryCompartment queries the "compartment" edge of the Item entity.

func (*Item) String

func (i *Item) String() string

String implements the fmt.Stringer.

func (*Item) Unwrap

func (i *Item) Unwrap() *Item

Unwrap unwraps the Item 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 (*Item) Update

func (i *Item) Update() *ItemUpdateOne

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

type ItemClient

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

ItemClient is a client for the Item schema.

func NewItemClient

func NewItemClient(c config) *ItemClient

NewItemClient returns a client for the Item from the given config.

func (*ItemClient) Create

func (c *ItemClient) Create() *ItemCreate

Create returns a create builder for Item.

func (*ItemClient) CreateBulk

func (c *ItemClient) CreateBulk(builders ...*ItemCreate) *ItemCreateBulk

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

func (*ItemClient) Delete

func (c *ItemClient) Delete() *ItemDelete

Delete returns a delete builder for Item.

func (*ItemClient) DeleteOne

func (c *ItemClient) DeleteOne(i *Item) *ItemDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*ItemClient) DeleteOneID

func (c *ItemClient) DeleteOneID(id int) *ItemDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*ItemClient) Get

func (c *ItemClient) Get(ctx context.Context, id int) (*Item, error)

Get returns a Item entity by its id.

func (*ItemClient) GetX

func (c *ItemClient) GetX(ctx context.Context, id int) *Item

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

func (*ItemClient) Hooks

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

Hooks returns the client hooks.

func (*ItemClient) Query

func (c *ItemClient) Query() *ItemQuery

Query returns a query builder for Item.

func (*ItemClient) QueryCompartment

func (c *ItemClient) QueryCompartment(i *Item) *CompartmentQuery

QueryCompartment queries the compartment edge of a Item.

func (*ItemClient) Update

func (c *ItemClient) Update() *ItemUpdate

Update returns an update builder for Item.

func (*ItemClient) UpdateOne

func (c *ItemClient) UpdateOne(i *Item) *ItemUpdateOne

UpdateOne returns an update builder for the given entity.

func (*ItemClient) UpdateOneID

func (c *ItemClient) UpdateOneID(id int) *ItemUpdateOne

UpdateOneID returns an update builder for the given id.

func (*ItemClient) Use

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

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

type ItemCreate

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

ItemCreate is the builder for creating a Item entity.

func (*ItemCreate) Exec

func (ic *ItemCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*ItemCreate) ExecX

func (ic *ItemCreate) ExecX(ctx context.Context)

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

func (*ItemCreate) Mutation

func (ic *ItemCreate) Mutation() *ItemMutation

Mutation returns the ItemMutation object of the builder.

func (*ItemCreate) Save

func (ic *ItemCreate) Save(ctx context.Context) (*Item, error)

Save creates the Item in the database.

func (*ItemCreate) SaveX

func (ic *ItemCreate) SaveX(ctx context.Context) *Item

SaveX calls Save and panics if Save returns an error.

func (*ItemCreate) SetCompartment

func (ic *ItemCreate) SetCompartment(c *Compartment) *ItemCreate

SetCompartment sets the "compartment" edge to the Compartment entity.

func (*ItemCreate) SetCompartmentID

func (ic *ItemCreate) SetCompartmentID(id int) *ItemCreate

SetCompartmentID sets the "compartment" edge to the Compartment entity by ID.

func (*ItemCreate) SetName

func (ic *ItemCreate) SetName(s string) *ItemCreate

SetName sets the "name" field.

func (*ItemCreate) SetNillableCompartmentID

func (ic *ItemCreate) SetNillableCompartmentID(id *int) *ItemCreate

SetNillableCompartmentID sets the "compartment" edge to the Compartment entity by ID if the given value is not nil.

type ItemCreateBulk

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

ItemCreateBulk is the builder for creating many Item entities in bulk.

func (*ItemCreateBulk) Exec

func (icb *ItemCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*ItemCreateBulk) ExecX

func (icb *ItemCreateBulk) ExecX(ctx context.Context)

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

func (*ItemCreateBulk) Save

func (icb *ItemCreateBulk) Save(ctx context.Context) ([]*Item, error)

Save creates the Item entities in the database.

func (*ItemCreateBulk) SaveX

func (icb *ItemCreateBulk) SaveX(ctx context.Context) []*Item

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

type ItemDelete

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

ItemDelete is the builder for deleting a Item entity.

func (*ItemDelete) Exec

func (id *ItemDelete) Exec(ctx context.Context) (int, error)

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

func (*ItemDelete) ExecX

func (id *ItemDelete) ExecX(ctx context.Context) int

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

func (*ItemDelete) Where

func (id *ItemDelete) Where(ps ...predicate.Item) *ItemDelete

Where appends a list predicates to the ItemDelete builder.

type ItemDeleteOne

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

ItemDeleteOne is the builder for deleting a single Item entity.

func (*ItemDeleteOne) Exec

func (ido *ItemDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*ItemDeleteOne) ExecX

func (ido *ItemDeleteOne) ExecX(ctx context.Context)

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

type ItemEdges

type ItemEdges struct {
	// Compartment holds the value of the compartment edge.
	Compartment *Compartment `json:"compartment,omitempty"`
	// contains filtered or unexported fields
}

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

func (ItemEdges) CompartmentOrErr

func (e ItemEdges) CompartmentOrErr() (*Compartment, error)

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

type ItemGroupBy

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

ItemGroupBy is the group-by builder for Item entities.

func (*ItemGroupBy) Aggregate

func (igb *ItemGroupBy) Aggregate(fns ...AggregateFunc) *ItemGroupBy

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

func (*ItemGroupBy) Bool

func (igb *ItemGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.

func (*ItemGroupBy) BoolX

func (igb *ItemGroupBy) BoolX(ctx context.Context) bool

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

func (*ItemGroupBy) Bools

func (igb *ItemGroupBy) Bools(ctx context.Context) ([]bool, error)

Bools returns list of bools from group-by. It is only allowed when executing a group-by query with one field.

func (*ItemGroupBy) BoolsX

func (igb *ItemGroupBy) BoolsX(ctx context.Context) []bool

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

func (*ItemGroupBy) Float64

func (igb *ItemGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.

func (*ItemGroupBy) Float64X

func (igb *ItemGroupBy) Float64X(ctx context.Context) float64

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

func (*ItemGroupBy) Float64s

func (igb *ItemGroupBy) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from group-by. It is only allowed when executing a group-by query with one field.

func (*ItemGroupBy) Float64sX

func (igb *ItemGroupBy) Float64sX(ctx context.Context) []float64

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

func (*ItemGroupBy) Int

func (igb *ItemGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.

func (*ItemGroupBy) IntX

func (igb *ItemGroupBy) IntX(ctx context.Context) int

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

func (*ItemGroupBy) Ints

func (igb *ItemGroupBy) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from group-by. It is only allowed when executing a group-by query with one field.

func (*ItemGroupBy) IntsX

func (igb *ItemGroupBy) IntsX(ctx context.Context) []int

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

func (*ItemGroupBy) Scan

func (igb *ItemGroupBy) Scan(ctx context.Context, v interface{}) error

Scan applies the group-by query and scans the result into the given value.

func (*ItemGroupBy) ScanX

func (igb *ItemGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*ItemGroupBy) String

func (igb *ItemGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.

func (*ItemGroupBy) StringX

func (igb *ItemGroupBy) StringX(ctx context.Context) string

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

func (*ItemGroupBy) Strings

func (igb *ItemGroupBy) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from group-by. It is only allowed when executing a group-by query with one field.

func (*ItemGroupBy) StringsX

func (igb *ItemGroupBy) StringsX(ctx context.Context) []string

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

type ItemMutation

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

ItemMutation represents an operation that mutates the Item nodes in the graph.

func (*ItemMutation) AddField

func (m *ItemMutation) 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 (*ItemMutation) AddedEdges

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

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

func (*ItemMutation) AddedField

func (m *ItemMutation) 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 (*ItemMutation) AddedFields

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

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

func (*ItemMutation) AddedIDs

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

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

func (*ItemMutation) ClearCompartment

func (m *ItemMutation) ClearCompartment()

ClearCompartment clears the "compartment" edge to the Compartment entity.

func (*ItemMutation) ClearEdge

func (m *ItemMutation) 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 (*ItemMutation) ClearField

func (m *ItemMutation) 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 (*ItemMutation) ClearedEdges

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

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

func (*ItemMutation) ClearedFields

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

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

func (ItemMutation) Client

func (m ItemMutation) 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 (*ItemMutation) CompartmentCleared

func (m *ItemMutation) CompartmentCleared() bool

CompartmentCleared reports if the "compartment" edge to the Compartment entity was cleared.

func (*ItemMutation) CompartmentID

func (m *ItemMutation) CompartmentID() (id int, exists bool)

CompartmentID returns the "compartment" edge ID in the mutation.

func (*ItemMutation) CompartmentIDs

func (m *ItemMutation) CompartmentIDs() (ids []int)

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

func (*ItemMutation) EdgeCleared

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

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

func (*ItemMutation) Field

func (m *ItemMutation) 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 (*ItemMutation) FieldCleared

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

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

func (*ItemMutation) Fields

func (m *ItemMutation) 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 (*ItemMutation) ID

func (m *ItemMutation) ID() (id int, 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 (*ItemMutation) Name

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

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

func (*ItemMutation) OldField

func (m *ItemMutation) 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 (*ItemMutation) OldName

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

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

func (m *ItemMutation) Op() Op

Op returns the operation name.

func (*ItemMutation) RemovedEdges

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

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

func (*ItemMutation) RemovedIDs

func (m *ItemMutation) 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 (*ItemMutation) ResetCompartment

func (m *ItemMutation) ResetCompartment()

ResetCompartment resets all changes to the "compartment" edge.

func (*ItemMutation) ResetEdge

func (m *ItemMutation) 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 (*ItemMutation) ResetField

func (m *ItemMutation) 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 (*ItemMutation) ResetName

func (m *ItemMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*ItemMutation) SetCompartmentID

func (m *ItemMutation) SetCompartmentID(id int)

SetCompartmentID sets the "compartment" edge to the Compartment entity by id.

func (*ItemMutation) SetField

func (m *ItemMutation) 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 (*ItemMutation) SetName

func (m *ItemMutation) SetName(s string)

SetName sets the "name" field.

func (ItemMutation) Tx

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

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

func (*ItemMutation) Type

func (m *ItemMutation) Type() string

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

func (*ItemMutation) Where

func (m *ItemMutation) Where(ps ...predicate.Item)

Where appends a list predicates to the ItemMutation builder.

type ItemQuery

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

ItemQuery is the builder for querying Item entities.

func (*ItemQuery) All

func (iq *ItemQuery) All(ctx context.Context) ([]*Item, error)

All executes the query and returns a list of Items.

func (*ItemQuery) AllX

func (iq *ItemQuery) AllX(ctx context.Context) []*Item

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

func (*ItemQuery) Clone

func (iq *ItemQuery) Clone() *ItemQuery

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

func (*ItemQuery) Count

func (iq *ItemQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*ItemQuery) CountX

func (iq *ItemQuery) CountX(ctx context.Context) int

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

func (*ItemQuery) Exist

func (iq *ItemQuery) Exist(ctx context.Context) (bool, error)

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

func (*ItemQuery) ExistX

func (iq *ItemQuery) ExistX(ctx context.Context) bool

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

func (*ItemQuery) First

func (iq *ItemQuery) First(ctx context.Context) (*Item, error)

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

func (*ItemQuery) FirstID

func (iq *ItemQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*ItemQuery) FirstIDX

func (iq *ItemQuery) FirstIDX(ctx context.Context) int

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

func (*ItemQuery) FirstX

func (iq *ItemQuery) FirstX(ctx context.Context) *Item

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

func (*ItemQuery) GroupBy

func (iq *ItemQuery) GroupBy(field string, fields ...string) *ItemGroupBy

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.Item.Query().
	GroupBy(item.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*ItemQuery) IDs

func (iq *ItemQuery) IDs(ctx context.Context) ([]int, error)

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

func (*ItemQuery) IDsX

func (iq *ItemQuery) IDsX(ctx context.Context) []int

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

func (*ItemQuery) Limit

func (iq *ItemQuery) Limit(limit int) *ItemQuery

Limit adds a limit step to the query.

func (*ItemQuery) Offset

func (iq *ItemQuery) Offset(offset int) *ItemQuery

Offset adds an offset step to the query.

func (*ItemQuery) Only

func (iq *ItemQuery) Only(ctx context.Context) (*Item, error)

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

func (*ItemQuery) OnlyID

func (iq *ItemQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*ItemQuery) OnlyIDX

func (iq *ItemQuery) OnlyIDX(ctx context.Context) int

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

func (*ItemQuery) OnlyX

func (iq *ItemQuery) OnlyX(ctx context.Context) *Item

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

func (*ItemQuery) Order

func (iq *ItemQuery) Order(o ...OrderFunc) *ItemQuery

Order adds an order step to the query.

func (*ItemQuery) QueryCompartment

func (iq *ItemQuery) QueryCompartment() *CompartmentQuery

QueryCompartment chains the current query on the "compartment" edge.

func (*ItemQuery) Select

func (iq *ItemQuery) Select(fields ...string) *ItemSelect

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.Item.Query().
	Select(item.FieldName).
	Scan(ctx, &v)

func (*ItemQuery) Unique

func (iq *ItemQuery) Unique(unique bool) *ItemQuery

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 (*ItemQuery) Where

func (iq *ItemQuery) Where(ps ...predicate.Item) *ItemQuery

Where adds a new predicate for the ItemQuery builder.

func (*ItemQuery) WithCompartment

func (iq *ItemQuery) WithCompartment(opts ...func(*CompartmentQuery)) *ItemQuery

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

type ItemSelect

type ItemSelect struct {
	*ItemQuery
	// contains filtered or unexported fields
}

ItemSelect is the builder for selecting fields of Item entities.

func (*ItemSelect) Bool

func (is *ItemSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*ItemSelect) BoolX

func (is *ItemSelect) BoolX(ctx context.Context) bool

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

func (*ItemSelect) Bools

func (is *ItemSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*ItemSelect) BoolsX

func (is *ItemSelect) BoolsX(ctx context.Context) []bool

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

func (*ItemSelect) Float64

func (is *ItemSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*ItemSelect) Float64X

func (is *ItemSelect) Float64X(ctx context.Context) float64

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

func (*ItemSelect) Float64s

func (is *ItemSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*ItemSelect) Float64sX

func (is *ItemSelect) Float64sX(ctx context.Context) []float64

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

func (*ItemSelect) Int

func (is *ItemSelect) Int(ctx context.Context) (_ int, err error)

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

func (*ItemSelect) IntX

func (is *ItemSelect) IntX(ctx context.Context) int

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

func (*ItemSelect) Ints

func (is *ItemSelect) Ints(ctx context.Context) ([]int, error)

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

func (*ItemSelect) IntsX

func (is *ItemSelect) IntsX(ctx context.Context) []int

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

func (*ItemSelect) Scan

func (is *ItemSelect) Scan(ctx context.Context, v interface{}) error

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

func (*ItemSelect) ScanX

func (is *ItemSelect) ScanX(ctx context.Context, v interface{})

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

func (*ItemSelect) String

func (is *ItemSelect) String(ctx context.Context) (_ string, err error)

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

func (*ItemSelect) StringX

func (is *ItemSelect) StringX(ctx context.Context) string

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

func (*ItemSelect) Strings

func (is *ItemSelect) Strings(ctx context.Context) ([]string, error)

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

func (*ItemSelect) StringsX

func (is *ItemSelect) StringsX(ctx context.Context) []string

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

type ItemUpdate

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

ItemUpdate is the builder for updating Item entities.

func (*ItemUpdate) ClearCompartment

func (iu *ItemUpdate) ClearCompartment() *ItemUpdate

ClearCompartment clears the "compartment" edge to the Compartment entity.

func (*ItemUpdate) Exec

func (iu *ItemUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*ItemUpdate) ExecX

func (iu *ItemUpdate) ExecX(ctx context.Context)

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

func (*ItemUpdate) Mutation

func (iu *ItemUpdate) Mutation() *ItemMutation

Mutation returns the ItemMutation object of the builder.

func (*ItemUpdate) Save

func (iu *ItemUpdate) Save(ctx context.Context) (int, error)

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

func (*ItemUpdate) SaveX

func (iu *ItemUpdate) SaveX(ctx context.Context) int

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

func (*ItemUpdate) SetCompartment

func (iu *ItemUpdate) SetCompartment(c *Compartment) *ItemUpdate

SetCompartment sets the "compartment" edge to the Compartment entity.

func (*ItemUpdate) SetCompartmentID

func (iu *ItemUpdate) SetCompartmentID(id int) *ItemUpdate

SetCompartmentID sets the "compartment" edge to the Compartment entity by ID.

func (*ItemUpdate) SetName

func (iu *ItemUpdate) SetName(s string) *ItemUpdate

SetName sets the "name" field.

func (*ItemUpdate) SetNillableCompartmentID

func (iu *ItemUpdate) SetNillableCompartmentID(id *int) *ItemUpdate

SetNillableCompartmentID sets the "compartment" edge to the Compartment entity by ID if the given value is not nil.

func (*ItemUpdate) Where

func (iu *ItemUpdate) Where(ps ...predicate.Item) *ItemUpdate

Where appends a list predicates to the ItemUpdate builder.

type ItemUpdateOne

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

ItemUpdateOne is the builder for updating a single Item entity.

func (*ItemUpdateOne) ClearCompartment

func (iuo *ItemUpdateOne) ClearCompartment() *ItemUpdateOne

ClearCompartment clears the "compartment" edge to the Compartment entity.

func (*ItemUpdateOne) Exec

func (iuo *ItemUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*ItemUpdateOne) ExecX

func (iuo *ItemUpdateOne) ExecX(ctx context.Context)

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

func (*ItemUpdateOne) Mutation

func (iuo *ItemUpdateOne) Mutation() *ItemMutation

Mutation returns the ItemMutation object of the builder.

func (*ItemUpdateOne) Save

func (iuo *ItemUpdateOne) Save(ctx context.Context) (*Item, error)

Save executes the query and returns the updated Item entity.

func (*ItemUpdateOne) SaveX

func (iuo *ItemUpdateOne) SaveX(ctx context.Context) *Item

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

func (*ItemUpdateOne) Select

func (iuo *ItemUpdateOne) Select(field string, fields ...string) *ItemUpdateOne

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

func (*ItemUpdateOne) SetCompartment

func (iuo *ItemUpdateOne) SetCompartment(c *Compartment) *ItemUpdateOne

SetCompartment sets the "compartment" edge to the Compartment entity.

func (*ItemUpdateOne) SetCompartmentID

func (iuo *ItemUpdateOne) SetCompartmentID(id int) *ItemUpdateOne

SetCompartmentID sets the "compartment" edge to the Compartment entity by ID.

func (*ItemUpdateOne) SetName

func (iuo *ItemUpdateOne) SetName(s string) *ItemUpdateOne

SetName sets the "name" field.

func (*ItemUpdateOne) SetNillableCompartmentID

func (iuo *ItemUpdateOne) SetNillableCompartmentID(id *int) *ItemUpdateOne

SetNillableCompartmentID sets the "compartment" edge to the Compartment entity by ID if the given value is not nil.

type Items

type Items []*Item

Items is a parsable slice of Item.

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(...interface{})) Option

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

OrderFunc applies an ordering on the sql selector.

func Asc

func Asc(fields ...string) OrderFunc

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) OrderFunc

Desc applies the given fields in DESC order.

type Policy

type Policy = ent.Policy

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 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(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 Rollbacker method.

type Tx

type Tx struct {

	// Compartment is the client for interacting with the Compartment builders.
	Compartment *CompartmentClient
	// Fridge is the client for interacting with the Fridge builders.
	Fridge *FridgeClient
	// Item is the client for interacting with the Item builders.
	Item *ItemClient
	// 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 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