db

package
v0.0.0-...-db1a339 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 23 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.
	TypeLocation = "Location"
	TypePkg      = "Pkg"
)

Variables

View Source
var ErrTxStarted = errors.New("db: cannot start a transaction within a transaction")

ErrTxStarted is returned when trying to start a new transaction from a transactional client.

Functions

func Asc

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

Asc applies the given fields in ASC order.

func Desc

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

Desc applies the given fields in DESC order.

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func IsValidationError

func IsValidationError(err error) bool

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

func 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(db.As(db.Sum(field1), "sum_field1"), (db.As(db.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
	// Location is the client for interacting with the Location builders.
	Location *LocationClient
	// Pkg is the client for interacting with the Pkg builders.
	Pkg *PkgClient
	// 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().
	Location.
	Query().
	Count(ctx)

func (*Client) Intercept

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

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

func (*Client) Mutate

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

Mutate implements the ent.Mutator interface.

func (*Client) Tx

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

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

func (*Client) Use

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

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

type CommitFunc

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

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

func (CommitFunc) Commit

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

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

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

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

type Committer

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

Committer is the interface that wraps the Commit method.

type ConstraintError

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

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

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

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

type InterceptFunc

type InterceptFunc = ent.InterceptFunc

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

type Interceptor

type Interceptor = ent.Interceptor

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

type Location

type Location struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Description holds the value of the "description" field.
	Description string `json:"description,omitempty"`
	// Source holds the value of the "source" field.
	Source types.LocationSource `json:"source,omitempty"`
	// Purpose holds the value of the "purpose" field.
	Purpose types.LocationPurpose `json:"purpose,omitempty"`
	// UUID holds the value of the "uuid" field.
	UUID uuid.UUID `json:"uuid,omitempty"`
	// Config holds the value of the "config" field.
	Config types.LocationConfig `json:"config,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the LocationQuery when eager-loading is set.
	Edges LocationEdges `json:"edges"`
	// contains filtered or unexported fields
}

Location is the model entity for the Location schema.

func (*Location) QueryPackages

func (l *Location) QueryPackages() *PkgQuery

QueryPackages queries the "packages" edge of the Location entity.

func (*Location) String

func (l *Location) String() string

String implements the fmt.Stringer.

func (*Location) Unwrap

func (l *Location) Unwrap() *Location

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

func (l *Location) Update() *LocationUpdateOne

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

func (*Location) Value

func (l *Location) Value(name string) (ent.Value, error)

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

type LocationClient

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

LocationClient is a client for the Location schema.

func NewLocationClient

func NewLocationClient(c config) *LocationClient

NewLocationClient returns a client for the Location from the given config.

func (*LocationClient) Create

func (c *LocationClient) Create() *LocationCreate

Create returns a builder for creating a Location entity.

func (*LocationClient) CreateBulk

func (c *LocationClient) CreateBulk(builders ...*LocationCreate) *LocationCreateBulk

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

func (*LocationClient) Delete

func (c *LocationClient) Delete() *LocationDelete

Delete returns a delete builder for Location.

func (*LocationClient) DeleteOne

func (c *LocationClient) DeleteOne(l *Location) *LocationDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*LocationClient) DeleteOneID

func (c *LocationClient) DeleteOneID(id int) *LocationDeleteOne

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

func (*LocationClient) Get

func (c *LocationClient) Get(ctx context.Context, id int) (*Location, error)

Get returns a Location entity by its id.

func (*LocationClient) GetX

func (c *LocationClient) GetX(ctx context.Context, id int) *Location

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

func (*LocationClient) Hooks

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

Hooks returns the client hooks.

func (*LocationClient) Intercept

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

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

func (*LocationClient) Interceptors

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

Interceptors returns the client interceptors.

func (*LocationClient) MapCreateBulk

func (c *LocationClient) MapCreateBulk(slice any, setFunc func(*LocationCreate, int)) *LocationCreateBulk

MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.

func (*LocationClient) Query

func (c *LocationClient) Query() *LocationQuery

Query returns a query builder for Location.

func (*LocationClient) QueryPackages

func (c *LocationClient) QueryPackages(l *Location) *PkgQuery

QueryPackages queries the packages edge of a Location.

func (*LocationClient) Update

func (c *LocationClient) Update() *LocationUpdate

Update returns an update builder for Location.

func (*LocationClient) UpdateOne

func (c *LocationClient) UpdateOne(l *Location) *LocationUpdateOne

UpdateOne returns an update builder for the given entity.

func (*LocationClient) UpdateOneID

func (c *LocationClient) UpdateOneID(id int) *LocationUpdateOne

UpdateOneID returns an update builder for the given id.

func (*LocationClient) Use

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

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

type LocationCreate

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

LocationCreate is the builder for creating a Location entity.

func (*LocationCreate) AddPackageIDs

func (lc *LocationCreate) AddPackageIDs(ids ...int) *LocationCreate

AddPackageIDs adds the "packages" edge to the Pkg entity by IDs.

func (*LocationCreate) AddPackages

func (lc *LocationCreate) AddPackages(p ...*Pkg) *LocationCreate

AddPackages adds the "packages" edges to the Pkg entity.

func (*LocationCreate) Exec

func (lc *LocationCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*LocationCreate) ExecX

func (lc *LocationCreate) ExecX(ctx context.Context)

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

func (*LocationCreate) Mutation

func (lc *LocationCreate) Mutation() *LocationMutation

Mutation returns the LocationMutation object of the builder.

func (*LocationCreate) Save

func (lc *LocationCreate) Save(ctx context.Context) (*Location, error)

Save creates the Location in the database.

func (*LocationCreate) SaveX

func (lc *LocationCreate) SaveX(ctx context.Context) *Location

SaveX calls Save and panics if Save returns an error.

func (*LocationCreate) SetConfig

SetConfig sets the "config" field.

func (*LocationCreate) SetCreatedAt

func (lc *LocationCreate) SetCreatedAt(t time.Time) *LocationCreate

SetCreatedAt sets the "created_at" field.

func (*LocationCreate) SetDescription

func (lc *LocationCreate) SetDescription(s string) *LocationCreate

SetDescription sets the "description" field.

func (*LocationCreate) SetName

func (lc *LocationCreate) SetName(s string) *LocationCreate

SetName sets the "name" field.

func (*LocationCreate) SetNillableCreatedAt

func (lc *LocationCreate) SetNillableCreatedAt(t *time.Time) *LocationCreate

SetNillableCreatedAt sets the "created_at" field if the given value is not nil.

func (*LocationCreate) SetPurpose

func (lc *LocationCreate) SetPurpose(tp types.LocationPurpose) *LocationCreate

SetPurpose sets the "purpose" field.

func (*LocationCreate) SetSource

SetSource sets the "source" field.

func (*LocationCreate) SetUUID

func (lc *LocationCreate) SetUUID(u uuid.UUID) *LocationCreate

SetUUID sets the "uuid" field.

type LocationCreateBulk

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

LocationCreateBulk is the builder for creating many Location entities in bulk.

func (*LocationCreateBulk) Exec

func (lcb *LocationCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*LocationCreateBulk) ExecX

func (lcb *LocationCreateBulk) ExecX(ctx context.Context)

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

func (*LocationCreateBulk) Save

func (lcb *LocationCreateBulk) Save(ctx context.Context) ([]*Location, error)

Save creates the Location entities in the database.

func (*LocationCreateBulk) SaveX

func (lcb *LocationCreateBulk) SaveX(ctx context.Context) []*Location

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

type LocationDelete

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

LocationDelete is the builder for deleting a Location entity.

func (*LocationDelete) Exec

func (ld *LocationDelete) Exec(ctx context.Context) (int, error)

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

func (*LocationDelete) ExecX

func (ld *LocationDelete) ExecX(ctx context.Context) int

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

func (*LocationDelete) Where

func (ld *LocationDelete) Where(ps ...predicate.Location) *LocationDelete

Where appends a list predicates to the LocationDelete builder.

type LocationDeleteOne

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

LocationDeleteOne is the builder for deleting a single Location entity.

func (*LocationDeleteOne) Exec

func (ldo *LocationDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*LocationDeleteOne) ExecX

func (ldo *LocationDeleteOne) ExecX(ctx context.Context)

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

func (*LocationDeleteOne) Where

Where appends a list predicates to the LocationDelete builder.

type LocationEdges

type LocationEdges struct {
	// Packages holds the value of the packages edge.
	Packages []*Pkg `json:"packages,omitempty"`
	// contains filtered or unexported fields
}

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

func (LocationEdges) PackagesOrErr

func (e LocationEdges) PackagesOrErr() ([]*Pkg, error)

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

type LocationGroupBy

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

LocationGroupBy is the group-by builder for Location entities.

func (*LocationGroupBy) Aggregate

func (lgb *LocationGroupBy) Aggregate(fns ...AggregateFunc) *LocationGroupBy

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

func (*LocationGroupBy) Bool

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

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

func (*LocationGroupBy) BoolX

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

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

func (*LocationGroupBy) Bools

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

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

func (*LocationGroupBy) BoolsX

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

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

func (*LocationGroupBy) Float64

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

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

func (*LocationGroupBy) Float64X

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

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

func (*LocationGroupBy) Float64s

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

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

func (*LocationGroupBy) Float64sX

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

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

func (*LocationGroupBy) Int

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

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

func (*LocationGroupBy) IntX

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

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

func (*LocationGroupBy) Ints

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

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

func (*LocationGroupBy) IntsX

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

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

func (*LocationGroupBy) Scan

func (lgb *LocationGroupBy) Scan(ctx context.Context, v any) error

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

func (*LocationGroupBy) ScanX

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

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

func (*LocationGroupBy) String

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

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

func (*LocationGroupBy) StringX

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

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

func (*LocationGroupBy) Strings

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

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

func (*LocationGroupBy) StringsX

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

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

type LocationMutation

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

LocationMutation represents an operation that mutates the Location nodes in the graph.

func (*LocationMutation) AddField

func (m *LocationMutation) 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 (*LocationMutation) AddPackageIDs

func (m *LocationMutation) AddPackageIDs(ids ...int)

AddPackageIDs adds the "packages" edge to the Pkg entity by ids.

func (*LocationMutation) AddedEdges

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

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

func (*LocationMutation) AddedField

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

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

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

func (*LocationMutation) AddedIDs

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

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

func (*LocationMutation) ClearEdge

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

func (m *LocationMutation) 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 (*LocationMutation) ClearPackages

func (m *LocationMutation) ClearPackages()

ClearPackages clears the "packages" edge to the Pkg entity.

func (*LocationMutation) ClearedEdges

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

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

func (*LocationMutation) ClearedFields

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

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

func (LocationMutation) Client

func (m LocationMutation) 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 (*LocationMutation) Config

func (m *LocationMutation) Config() (r types.LocationConfig, exists bool)

Config returns the value of the "config" field in the mutation.

func (*LocationMutation) CreatedAt

func (m *LocationMutation) CreatedAt() (r time.Time, exists bool)

CreatedAt returns the value of the "created_at" field in the mutation.

func (*LocationMutation) Description

func (m *LocationMutation) Description() (r string, exists bool)

Description returns the value of the "description" field in the mutation.

func (*LocationMutation) EdgeCleared

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

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

func (*LocationMutation) Field

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

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

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

func (*LocationMutation) Fields

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

func (m *LocationMutation) 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 (*LocationMutation) IDs

func (m *LocationMutation) IDs(ctx context.Context) ([]int, error)

IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.

func (*LocationMutation) Name

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

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

func (*LocationMutation) OldConfig

func (m *LocationMutation) OldConfig(ctx context.Context) (v types.LocationConfig, err error)

OldConfig returns the old "config" field's value of the Location entity. If the Location 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 (*LocationMutation) OldCreatedAt

func (m *LocationMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error)

OldCreatedAt returns the old "created_at" field's value of the Location entity. If the Location 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 (*LocationMutation) OldDescription

func (m *LocationMutation) OldDescription(ctx context.Context) (v string, err error)

OldDescription returns the old "description" field's value of the Location entity. If the Location 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 (*LocationMutation) OldField

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

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

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

func (m *LocationMutation) OldPurpose(ctx context.Context) (v types.LocationPurpose, err error)

OldPurpose returns the old "purpose" field's value of the Location entity. If the Location 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 (*LocationMutation) OldSource

func (m *LocationMutation) OldSource(ctx context.Context) (v types.LocationSource, err error)

OldSource returns the old "source" field's value of the Location entity. If the Location 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 (*LocationMutation) OldUUID

func (m *LocationMutation) OldUUID(ctx context.Context) (v uuid.UUID, err error)

OldUUID returns the old "uuid" field's value of the Location entity. If the Location 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 (*LocationMutation) Op

func (m *LocationMutation) Op() Op

Op returns the operation name.

func (*LocationMutation) PackagesCleared

func (m *LocationMutation) PackagesCleared() bool

PackagesCleared reports if the "packages" edge to the Pkg entity was cleared.

func (*LocationMutation) PackagesIDs

func (m *LocationMutation) PackagesIDs() (ids []int)

PackagesIDs returns the "packages" edge IDs in the mutation.

func (*LocationMutation) Purpose

func (m *LocationMutation) Purpose() (r types.LocationPurpose, exists bool)

Purpose returns the value of the "purpose" field in the mutation.

func (*LocationMutation) RemovePackageIDs

func (m *LocationMutation) RemovePackageIDs(ids ...int)

RemovePackageIDs removes the "packages" edge to the Pkg entity by IDs.

func (*LocationMutation) RemovedEdges

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

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

func (*LocationMutation) RemovedIDs

func (m *LocationMutation) 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 (*LocationMutation) RemovedPackagesIDs

func (m *LocationMutation) RemovedPackagesIDs() (ids []int)

RemovedPackages returns the removed IDs of the "packages" edge to the Pkg entity.

func (*LocationMutation) ResetConfig

func (m *LocationMutation) ResetConfig()

ResetConfig resets all changes to the "config" field.

func (*LocationMutation) ResetCreatedAt

func (m *LocationMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*LocationMutation) ResetDescription

func (m *LocationMutation) ResetDescription()

ResetDescription resets all changes to the "description" field.

func (*LocationMutation) ResetEdge

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

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

func (m *LocationMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*LocationMutation) ResetPackages

func (m *LocationMutation) ResetPackages()

ResetPackages resets all changes to the "packages" edge.

func (*LocationMutation) ResetPurpose

func (m *LocationMutation) ResetPurpose()

ResetPurpose resets all changes to the "purpose" field.

func (*LocationMutation) ResetSource

func (m *LocationMutation) ResetSource()

ResetSource resets all changes to the "source" field.

func (*LocationMutation) ResetUUID

func (m *LocationMutation) ResetUUID()

ResetUUID resets all changes to the "uuid" field.

func (*LocationMutation) SetConfig

func (m *LocationMutation) SetConfig(tc types.LocationConfig)

SetConfig sets the "config" field.

func (*LocationMutation) SetCreatedAt

func (m *LocationMutation) SetCreatedAt(t time.Time)

SetCreatedAt sets the "created_at" field.

func (*LocationMutation) SetDescription

func (m *LocationMutation) SetDescription(s string)

SetDescription sets the "description" field.

func (*LocationMutation) SetField

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

func (m *LocationMutation) SetName(s string)

SetName sets the "name" field.

func (*LocationMutation) SetOp

func (m *LocationMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*LocationMutation) SetPurpose

func (m *LocationMutation) SetPurpose(tp types.LocationPurpose)

SetPurpose sets the "purpose" field.

func (*LocationMutation) SetSource

func (m *LocationMutation) SetSource(ts types.LocationSource)

SetSource sets the "source" field.

func (*LocationMutation) SetUUID

func (m *LocationMutation) SetUUID(u uuid.UUID)

SetUUID sets the "uuid" field.

func (*LocationMutation) Source

func (m *LocationMutation) Source() (r types.LocationSource, exists bool)

Source returns the value of the "source" field in the mutation.

func (LocationMutation) Tx

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

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

func (*LocationMutation) Type

func (m *LocationMutation) Type() string

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

func (*LocationMutation) UUID

func (m *LocationMutation) UUID() (r uuid.UUID, exists bool)

UUID returns the value of the "uuid" field in the mutation.

func (*LocationMutation) Where

func (m *LocationMutation) Where(ps ...predicate.Location)

Where appends a list predicates to the LocationMutation builder.

func (*LocationMutation) WhereP

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

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

type LocationQuery

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

LocationQuery is the builder for querying Location entities.

func (*LocationQuery) Aggregate

func (lq *LocationQuery) Aggregate(fns ...AggregateFunc) *LocationSelect

Aggregate returns a LocationSelect configured with the given aggregations.

func (*LocationQuery) All

func (lq *LocationQuery) All(ctx context.Context) ([]*Location, error)

All executes the query and returns a list of Locations.

func (*LocationQuery) AllX

func (lq *LocationQuery) AllX(ctx context.Context) []*Location

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

func (*LocationQuery) Clone

func (lq *LocationQuery) Clone() *LocationQuery

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

func (*LocationQuery) Count

func (lq *LocationQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*LocationQuery) CountX

func (lq *LocationQuery) CountX(ctx context.Context) int

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

func (*LocationQuery) Exist

func (lq *LocationQuery) Exist(ctx context.Context) (bool, error)

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

func (*LocationQuery) ExistX

func (lq *LocationQuery) ExistX(ctx context.Context) bool

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

func (*LocationQuery) First

func (lq *LocationQuery) First(ctx context.Context) (*Location, error)

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

func (*LocationQuery) FirstID

func (lq *LocationQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*LocationQuery) FirstIDX

func (lq *LocationQuery) FirstIDX(ctx context.Context) int

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

func (*LocationQuery) FirstX

func (lq *LocationQuery) FirstX(ctx context.Context) *Location

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

func (*LocationQuery) GroupBy

func (lq *LocationQuery) GroupBy(field string, fields ...string) *LocationGroupBy

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.Location.Query().
	GroupBy(location.FieldName).
	Aggregate(db.Count()).
	Scan(ctx, &v)

func (*LocationQuery) IDs

func (lq *LocationQuery) IDs(ctx context.Context) (ids []int, err error)

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

func (*LocationQuery) IDsX

func (lq *LocationQuery) IDsX(ctx context.Context) []int

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

func (*LocationQuery) Limit

func (lq *LocationQuery) Limit(limit int) *LocationQuery

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

func (*LocationQuery) Offset

func (lq *LocationQuery) Offset(offset int) *LocationQuery

Offset to start from.

func (*LocationQuery) Only

func (lq *LocationQuery) Only(ctx context.Context) (*Location, error)

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

func (*LocationQuery) OnlyID

func (lq *LocationQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*LocationQuery) OnlyIDX

func (lq *LocationQuery) OnlyIDX(ctx context.Context) int

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

func (*LocationQuery) OnlyX

func (lq *LocationQuery) OnlyX(ctx context.Context) *Location

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

func (*LocationQuery) Order

Order specifies how the records should be ordered.

func (*LocationQuery) QueryPackages

func (lq *LocationQuery) QueryPackages() *PkgQuery

QueryPackages chains the current query on the "packages" edge.

func (*LocationQuery) Select

func (lq *LocationQuery) Select(fields ...string) *LocationSelect

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

func (*LocationQuery) Unique

func (lq *LocationQuery) Unique(unique bool) *LocationQuery

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

func (lq *LocationQuery) Where(ps ...predicate.Location) *LocationQuery

Where adds a new predicate for the LocationQuery builder.

func (*LocationQuery) WithPackages

func (lq *LocationQuery) WithPackages(opts ...func(*PkgQuery)) *LocationQuery

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

type LocationSelect

type LocationSelect struct {
	*LocationQuery
	// contains filtered or unexported fields
}

LocationSelect is the builder for selecting fields of Location entities.

func (*LocationSelect) Aggregate

func (ls *LocationSelect) Aggregate(fns ...AggregateFunc) *LocationSelect

Aggregate adds the given aggregation functions to the selector query.

func (*LocationSelect) Bool

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

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

func (*LocationSelect) BoolX

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

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

func (*LocationSelect) Bools

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

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

func (*LocationSelect) BoolsX

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

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

func (*LocationSelect) Float64

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

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

func (*LocationSelect) Float64X

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

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

func (*LocationSelect) Float64s

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

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

func (*LocationSelect) Float64sX

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

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

func (*LocationSelect) Int

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

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

func (*LocationSelect) IntX

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

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

func (*LocationSelect) Ints

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

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

func (*LocationSelect) IntsX

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

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

func (*LocationSelect) Scan

func (ls *LocationSelect) Scan(ctx context.Context, v any) error

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

func (*LocationSelect) ScanX

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

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

func (*LocationSelect) String

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

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

func (*LocationSelect) StringX

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

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

func (*LocationSelect) Strings

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

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

func (*LocationSelect) StringsX

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

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

type LocationUpdate

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

LocationUpdate is the builder for updating Location entities.

func (*LocationUpdate) AddPackageIDs

func (lu *LocationUpdate) AddPackageIDs(ids ...int) *LocationUpdate

AddPackageIDs adds the "packages" edge to the Pkg entity by IDs.

func (*LocationUpdate) AddPackages

func (lu *LocationUpdate) AddPackages(p ...*Pkg) *LocationUpdate

AddPackages adds the "packages" edges to the Pkg entity.

func (*LocationUpdate) ClearPackages

func (lu *LocationUpdate) ClearPackages() *LocationUpdate

ClearPackages clears all "packages" edges to the Pkg entity.

func (*LocationUpdate) Exec

func (lu *LocationUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*LocationUpdate) ExecX

func (lu *LocationUpdate) ExecX(ctx context.Context)

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

func (*LocationUpdate) Mutation

func (lu *LocationUpdate) Mutation() *LocationMutation

Mutation returns the LocationMutation object of the builder.

func (*LocationUpdate) RemovePackageIDs

func (lu *LocationUpdate) RemovePackageIDs(ids ...int) *LocationUpdate

RemovePackageIDs removes the "packages" edge to Pkg entities by IDs.

func (*LocationUpdate) RemovePackages

func (lu *LocationUpdate) RemovePackages(p ...*Pkg) *LocationUpdate

RemovePackages removes "packages" edges to Pkg entities.

func (*LocationUpdate) Save

func (lu *LocationUpdate) Save(ctx context.Context) (int, error)

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

func (*LocationUpdate) SaveX

func (lu *LocationUpdate) SaveX(ctx context.Context) int

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

func (*LocationUpdate) SetConfig

SetConfig sets the "config" field.

func (*LocationUpdate) SetDescription

func (lu *LocationUpdate) SetDescription(s string) *LocationUpdate

SetDescription sets the "description" field.

func (*LocationUpdate) SetName

func (lu *LocationUpdate) SetName(s string) *LocationUpdate

SetName sets the "name" field.

func (*LocationUpdate) SetNillableConfig

func (lu *LocationUpdate) SetNillableConfig(tc *types.LocationConfig) *LocationUpdate

SetNillableConfig sets the "config" field if the given value is not nil.

func (*LocationUpdate) SetNillableDescription

func (lu *LocationUpdate) SetNillableDescription(s *string) *LocationUpdate

SetNillableDescription sets the "description" field if the given value is not nil.

func (*LocationUpdate) SetNillableName

func (lu *LocationUpdate) SetNillableName(s *string) *LocationUpdate

SetNillableName sets the "name" field if the given value is not nil.

func (*LocationUpdate) SetNillablePurpose

func (lu *LocationUpdate) SetNillablePurpose(tp *types.LocationPurpose) *LocationUpdate

SetNillablePurpose sets the "purpose" field if the given value is not nil.

func (*LocationUpdate) SetNillableSource

func (lu *LocationUpdate) SetNillableSource(ts *types.LocationSource) *LocationUpdate

SetNillableSource sets the "source" field if the given value is not nil.

func (*LocationUpdate) SetNillableUUID

func (lu *LocationUpdate) SetNillableUUID(u *uuid.UUID) *LocationUpdate

SetNillableUUID sets the "uuid" field if the given value is not nil.

func (*LocationUpdate) SetPurpose

func (lu *LocationUpdate) SetPurpose(tp types.LocationPurpose) *LocationUpdate

SetPurpose sets the "purpose" field.

func (*LocationUpdate) SetSource

SetSource sets the "source" field.

func (*LocationUpdate) SetUUID

func (lu *LocationUpdate) SetUUID(u uuid.UUID) *LocationUpdate

SetUUID sets the "uuid" field.

func (*LocationUpdate) Where

func (lu *LocationUpdate) Where(ps ...predicate.Location) *LocationUpdate

Where appends a list predicates to the LocationUpdate builder.

type LocationUpdateOne

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

LocationUpdateOne is the builder for updating a single Location entity.

func (*LocationUpdateOne) AddPackageIDs

func (luo *LocationUpdateOne) AddPackageIDs(ids ...int) *LocationUpdateOne

AddPackageIDs adds the "packages" edge to the Pkg entity by IDs.

func (*LocationUpdateOne) AddPackages

func (luo *LocationUpdateOne) AddPackages(p ...*Pkg) *LocationUpdateOne

AddPackages adds the "packages" edges to the Pkg entity.

func (*LocationUpdateOne) ClearPackages

func (luo *LocationUpdateOne) ClearPackages() *LocationUpdateOne

ClearPackages clears all "packages" edges to the Pkg entity.

func (*LocationUpdateOne) Exec

func (luo *LocationUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*LocationUpdateOne) ExecX

func (luo *LocationUpdateOne) ExecX(ctx context.Context)

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

func (*LocationUpdateOne) Mutation

func (luo *LocationUpdateOne) Mutation() *LocationMutation

Mutation returns the LocationMutation object of the builder.

func (*LocationUpdateOne) RemovePackageIDs

func (luo *LocationUpdateOne) RemovePackageIDs(ids ...int) *LocationUpdateOne

RemovePackageIDs removes the "packages" edge to Pkg entities by IDs.

func (*LocationUpdateOne) RemovePackages

func (luo *LocationUpdateOne) RemovePackages(p ...*Pkg) *LocationUpdateOne

RemovePackages removes "packages" edges to Pkg entities.

func (*LocationUpdateOne) Save

func (luo *LocationUpdateOne) Save(ctx context.Context) (*Location, error)

Save executes the query and returns the updated Location entity.

func (*LocationUpdateOne) SaveX

func (luo *LocationUpdateOne) SaveX(ctx context.Context) *Location

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

func (*LocationUpdateOne) Select

func (luo *LocationUpdateOne) Select(field string, fields ...string) *LocationUpdateOne

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

func (*LocationUpdateOne) SetConfig

SetConfig sets the "config" field.

func (*LocationUpdateOne) SetDescription

func (luo *LocationUpdateOne) SetDescription(s string) *LocationUpdateOne

SetDescription sets the "description" field.

func (*LocationUpdateOne) SetName

func (luo *LocationUpdateOne) SetName(s string) *LocationUpdateOne

SetName sets the "name" field.

func (*LocationUpdateOne) SetNillableConfig

func (luo *LocationUpdateOne) SetNillableConfig(tc *types.LocationConfig) *LocationUpdateOne

SetNillableConfig sets the "config" field if the given value is not nil.

func (*LocationUpdateOne) SetNillableDescription

func (luo *LocationUpdateOne) SetNillableDescription(s *string) *LocationUpdateOne

SetNillableDescription sets the "description" field if the given value is not nil.

func (*LocationUpdateOne) SetNillableName

func (luo *LocationUpdateOne) SetNillableName(s *string) *LocationUpdateOne

SetNillableName sets the "name" field if the given value is not nil.

func (*LocationUpdateOne) SetNillablePurpose

func (luo *LocationUpdateOne) SetNillablePurpose(tp *types.LocationPurpose) *LocationUpdateOne

SetNillablePurpose sets the "purpose" field if the given value is not nil.

func (*LocationUpdateOne) SetNillableSource

func (luo *LocationUpdateOne) SetNillableSource(ts *types.LocationSource) *LocationUpdateOne

SetNillableSource sets the "source" field if the given value is not nil.

func (*LocationUpdateOne) SetNillableUUID

func (luo *LocationUpdateOne) SetNillableUUID(u *uuid.UUID) *LocationUpdateOne

SetNillableUUID sets the "uuid" field if the given value is not nil.

func (*LocationUpdateOne) SetPurpose

SetPurpose sets the "purpose" field.

func (*LocationUpdateOne) SetSource

SetSource sets the "source" field.

func (*LocationUpdateOne) SetUUID

func (luo *LocationUpdateOne) SetUUID(u uuid.UUID) *LocationUpdateOne

SetUUID sets the "uuid" field.

func (*LocationUpdateOne) Where

Where appends a list predicates to the LocationUpdate builder.

type Locations

type Locations []*Location

Locations is a parsable slice of Location.

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

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

type NotFoundError

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

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

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

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

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

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

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

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

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

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

type Pkg

type Pkg struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// AipID holds the value of the "aip_id" field.
	AipID uuid.UUID `json:"aip_id,omitempty"`
	// LocationID holds the value of the "location_id" field.
	LocationID int `json:"location_id,omitempty"`
	// Status holds the value of the "status" field.
	Status types.PackageStatus `json:"status,omitempty"`
	// ObjectKey holds the value of the "object_key" field.
	ObjectKey uuid.UUID `json:"object_key,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the PkgQuery when eager-loading is set.
	Edges PkgEdges `json:"edges"`
	// contains filtered or unexported fields
}

Pkg is the model entity for the Pkg schema.

func (*Pkg) QueryLocation

func (pk *Pkg) QueryLocation() *LocationQuery

QueryLocation queries the "location" edge of the Pkg entity.

func (*Pkg) String

func (pk *Pkg) String() string

String implements the fmt.Stringer.

func (*Pkg) Unwrap

func (pk *Pkg) Unwrap() *Pkg

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

func (pk *Pkg) Update() *PkgUpdateOne

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

func (*Pkg) Value

func (pk *Pkg) Value(name string) (ent.Value, error)

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

type PkgClient

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

PkgClient is a client for the Pkg schema.

func NewPkgClient

func NewPkgClient(c config) *PkgClient

NewPkgClient returns a client for the Pkg from the given config.

func (*PkgClient) Create

func (c *PkgClient) Create() *PkgCreate

Create returns a builder for creating a Pkg entity.

func (*PkgClient) CreateBulk

func (c *PkgClient) CreateBulk(builders ...*PkgCreate) *PkgCreateBulk

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

func (*PkgClient) Delete

func (c *PkgClient) Delete() *PkgDelete

Delete returns a delete builder for Pkg.

func (*PkgClient) DeleteOne

func (c *PkgClient) DeleteOne(pk *Pkg) *PkgDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*PkgClient) DeleteOneID

func (c *PkgClient) DeleteOneID(id int) *PkgDeleteOne

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

func (*PkgClient) Get

func (c *PkgClient) Get(ctx context.Context, id int) (*Pkg, error)

Get returns a Pkg entity by its id.

func (*PkgClient) GetX

func (c *PkgClient) GetX(ctx context.Context, id int) *Pkg

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

func (*PkgClient) Hooks

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

Hooks returns the client hooks.

func (*PkgClient) Intercept

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

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

func (*PkgClient) Interceptors

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

Interceptors returns the client interceptors.

func (*PkgClient) MapCreateBulk

func (c *PkgClient) MapCreateBulk(slice any, setFunc func(*PkgCreate, int)) *PkgCreateBulk

MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.

func (*PkgClient) Query

func (c *PkgClient) Query() *PkgQuery

Query returns a query builder for Pkg.

func (*PkgClient) QueryLocation

func (c *PkgClient) QueryLocation(pk *Pkg) *LocationQuery

QueryLocation queries the location edge of a Pkg.

func (*PkgClient) Update

func (c *PkgClient) Update() *PkgUpdate

Update returns an update builder for Pkg.

func (*PkgClient) UpdateOne

func (c *PkgClient) UpdateOne(pk *Pkg) *PkgUpdateOne

UpdateOne returns an update builder for the given entity.

func (*PkgClient) UpdateOneID

func (c *PkgClient) UpdateOneID(id int) *PkgUpdateOne

UpdateOneID returns an update builder for the given id.

func (*PkgClient) Use

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

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

type PkgCreate

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

PkgCreate is the builder for creating a Pkg entity.

func (*PkgCreate) Exec

func (pc *PkgCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*PkgCreate) ExecX

func (pc *PkgCreate) ExecX(ctx context.Context)

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

func (*PkgCreate) Mutation

func (pc *PkgCreate) Mutation() *PkgMutation

Mutation returns the PkgMutation object of the builder.

func (*PkgCreate) Save

func (pc *PkgCreate) Save(ctx context.Context) (*Pkg, error)

Save creates the Pkg in the database.

func (*PkgCreate) SaveX

func (pc *PkgCreate) SaveX(ctx context.Context) *Pkg

SaveX calls Save and panics if Save returns an error.

func (*PkgCreate) SetAipID

func (pc *PkgCreate) SetAipID(u uuid.UUID) *PkgCreate

SetAipID sets the "aip_id" field.

func (*PkgCreate) SetCreatedAt

func (pc *PkgCreate) SetCreatedAt(t time.Time) *PkgCreate

SetCreatedAt sets the "created_at" field.

func (*PkgCreate) SetLocation

func (pc *PkgCreate) SetLocation(l *Location) *PkgCreate

SetLocation sets the "location" edge to the Location entity.

func (*PkgCreate) SetLocationID

func (pc *PkgCreate) SetLocationID(i int) *PkgCreate

SetLocationID sets the "location_id" field.

func (*PkgCreate) SetName

func (pc *PkgCreate) SetName(s string) *PkgCreate

SetName sets the "name" field.

func (*PkgCreate) SetNillableCreatedAt

func (pc *PkgCreate) SetNillableCreatedAt(t *time.Time) *PkgCreate

SetNillableCreatedAt sets the "created_at" field if the given value is not nil.

func (*PkgCreate) SetNillableLocationID

func (pc *PkgCreate) SetNillableLocationID(i *int) *PkgCreate

SetNillableLocationID sets the "location_id" field if the given value is not nil.

func (*PkgCreate) SetObjectKey

func (pc *PkgCreate) SetObjectKey(u uuid.UUID) *PkgCreate

SetObjectKey sets the "object_key" field.

func (*PkgCreate) SetStatus

func (pc *PkgCreate) SetStatus(ts types.PackageStatus) *PkgCreate

SetStatus sets the "status" field.

type PkgCreateBulk

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

PkgCreateBulk is the builder for creating many Pkg entities in bulk.

func (*PkgCreateBulk) Exec

func (pcb *PkgCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*PkgCreateBulk) ExecX

func (pcb *PkgCreateBulk) ExecX(ctx context.Context)

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

func (*PkgCreateBulk) Save

func (pcb *PkgCreateBulk) Save(ctx context.Context) ([]*Pkg, error)

Save creates the Pkg entities in the database.

func (*PkgCreateBulk) SaveX

func (pcb *PkgCreateBulk) SaveX(ctx context.Context) []*Pkg

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

type PkgDelete

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

PkgDelete is the builder for deleting a Pkg entity.

func (*PkgDelete) Exec

func (pd *PkgDelete) Exec(ctx context.Context) (int, error)

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

func (*PkgDelete) ExecX

func (pd *PkgDelete) ExecX(ctx context.Context) int

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

func (*PkgDelete) Where

func (pd *PkgDelete) Where(ps ...predicate.Pkg) *PkgDelete

Where appends a list predicates to the PkgDelete builder.

type PkgDeleteOne

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

PkgDeleteOne is the builder for deleting a single Pkg entity.

func (*PkgDeleteOne) Exec

func (pdo *PkgDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*PkgDeleteOne) ExecX

func (pdo *PkgDeleteOne) ExecX(ctx context.Context)

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

func (*PkgDeleteOne) Where

func (pdo *PkgDeleteOne) Where(ps ...predicate.Pkg) *PkgDeleteOne

Where appends a list predicates to the PkgDelete builder.

type PkgEdges

type PkgEdges struct {
	// Location holds the value of the location edge.
	Location *Location `json:"location,omitempty"`
	// contains filtered or unexported fields
}

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

func (PkgEdges) LocationOrErr

func (e PkgEdges) LocationOrErr() (*Location, error)

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

type PkgGroupBy

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

PkgGroupBy is the group-by builder for Pkg entities.

func (*PkgGroupBy) Aggregate

func (pgb *PkgGroupBy) Aggregate(fns ...AggregateFunc) *PkgGroupBy

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

func (*PkgGroupBy) Bool

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

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

func (*PkgGroupBy) BoolX

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

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

func (*PkgGroupBy) Bools

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

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

func (*PkgGroupBy) BoolsX

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

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

func (*PkgGroupBy) Float64

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

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

func (*PkgGroupBy) Float64X

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

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

func (*PkgGroupBy) Float64s

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

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

func (*PkgGroupBy) Float64sX

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

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

func (*PkgGroupBy) Int

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

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

func (*PkgGroupBy) IntX

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

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

func (*PkgGroupBy) Ints

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

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

func (*PkgGroupBy) IntsX

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

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

func (*PkgGroupBy) Scan

func (pgb *PkgGroupBy) Scan(ctx context.Context, v any) error

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

func (*PkgGroupBy) ScanX

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

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

func (*PkgGroupBy) String

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

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

func (*PkgGroupBy) StringX

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

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

func (*PkgGroupBy) Strings

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

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

func (*PkgGroupBy) StringsX

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

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

type PkgMutation

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

PkgMutation represents an operation that mutates the Pkg nodes in the graph.

func (*PkgMutation) AddField

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

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

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

func (*PkgMutation) AddedField

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

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

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

func (*PkgMutation) AddedIDs

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

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

func (*PkgMutation) AipID

func (m *PkgMutation) AipID() (r uuid.UUID, exists bool)

AipID returns the value of the "aip_id" field in the mutation.

func (*PkgMutation) ClearEdge

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

func (m *PkgMutation) 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 (*PkgMutation) ClearLocation

func (m *PkgMutation) ClearLocation()

ClearLocation clears the "location" edge to the Location entity.

func (*PkgMutation) ClearLocationID

func (m *PkgMutation) ClearLocationID()

ClearLocationID clears the value of the "location_id" field.

func (*PkgMutation) ClearedEdges

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

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

func (*PkgMutation) ClearedFields

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

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

func (PkgMutation) Client

func (m PkgMutation) 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 (*PkgMutation) CreatedAt

func (m *PkgMutation) CreatedAt() (r time.Time, exists bool)

CreatedAt returns the value of the "created_at" field in the mutation.

func (*PkgMutation) EdgeCleared

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

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

func (*PkgMutation) Field

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

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

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

func (*PkgMutation) Fields

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

func (m *PkgMutation) 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 (*PkgMutation) IDs

func (m *PkgMutation) IDs(ctx context.Context) ([]int, error)

IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.

func (*PkgMutation) LocationCleared

func (m *PkgMutation) LocationCleared() bool

LocationCleared reports if the "location" edge to the Location entity was cleared.

func (*PkgMutation) LocationID

func (m *PkgMutation) LocationID() (r int, exists bool)

LocationID returns the value of the "location_id" field in the mutation.

func (*PkgMutation) LocationIDCleared

func (m *PkgMutation) LocationIDCleared() bool

LocationIDCleared returns if the "location_id" field was cleared in this mutation.

func (*PkgMutation) LocationIDs

func (m *PkgMutation) LocationIDs() (ids []int)

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

func (*PkgMutation) Name

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

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

func (*PkgMutation) ObjectKey

func (m *PkgMutation) ObjectKey() (r uuid.UUID, exists bool)

ObjectKey returns the value of the "object_key" field in the mutation.

func (*PkgMutation) OldAipID

func (m *PkgMutation) OldAipID(ctx context.Context) (v uuid.UUID, err error)

OldAipID returns the old "aip_id" field's value of the Pkg entity. If the Pkg 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 (*PkgMutation) OldCreatedAt

func (m *PkgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error)

OldCreatedAt returns the old "created_at" field's value of the Pkg entity. If the Pkg 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 (*PkgMutation) OldField

func (m *PkgMutation) 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 (*PkgMutation) OldLocationID

func (m *PkgMutation) OldLocationID(ctx context.Context) (v int, err error)

OldLocationID returns the old "location_id" field's value of the Pkg entity. If the Pkg 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 (*PkgMutation) OldName

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

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

func (m *PkgMutation) OldObjectKey(ctx context.Context) (v uuid.UUID, err error)

OldObjectKey returns the old "object_key" field's value of the Pkg entity. If the Pkg 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 (*PkgMutation) OldStatus

func (m *PkgMutation) OldStatus(ctx context.Context) (v types.PackageStatus, err error)

OldStatus returns the old "status" field's value of the Pkg entity. If the Pkg 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 (*PkgMutation) Op

func (m *PkgMutation) Op() Op

Op returns the operation name.

func (*PkgMutation) RemovedEdges

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

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

func (*PkgMutation) RemovedIDs

func (m *PkgMutation) 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 (*PkgMutation) ResetAipID

func (m *PkgMutation) ResetAipID()

ResetAipID resets all changes to the "aip_id" field.

func (*PkgMutation) ResetCreatedAt

func (m *PkgMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*PkgMutation) ResetEdge

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

func (m *PkgMutation) 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 (*PkgMutation) ResetLocation

func (m *PkgMutation) ResetLocation()

ResetLocation resets all changes to the "location" edge.

func (*PkgMutation) ResetLocationID

func (m *PkgMutation) ResetLocationID()

ResetLocationID resets all changes to the "location_id" field.

func (*PkgMutation) ResetName

func (m *PkgMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*PkgMutation) ResetObjectKey

func (m *PkgMutation) ResetObjectKey()

ResetObjectKey resets all changes to the "object_key" field.

func (*PkgMutation) ResetStatus

func (m *PkgMutation) ResetStatus()

ResetStatus resets all changes to the "status" field.

func (*PkgMutation) SetAipID

func (m *PkgMutation) SetAipID(u uuid.UUID)

SetAipID sets the "aip_id" field.

func (*PkgMutation) SetCreatedAt

func (m *PkgMutation) SetCreatedAt(t time.Time)

SetCreatedAt sets the "created_at" field.

func (*PkgMutation) SetField

func (m *PkgMutation) 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 (*PkgMutation) SetLocationID

func (m *PkgMutation) SetLocationID(i int)

SetLocationID sets the "location_id" field.

func (*PkgMutation) SetName

func (m *PkgMutation) SetName(s string)

SetName sets the "name" field.

func (*PkgMutation) SetObjectKey

func (m *PkgMutation) SetObjectKey(u uuid.UUID)

SetObjectKey sets the "object_key" field.

func (*PkgMutation) SetOp

func (m *PkgMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*PkgMutation) SetStatus

func (m *PkgMutation) SetStatus(ts types.PackageStatus)

SetStatus sets the "status" field.

func (*PkgMutation) Status

func (m *PkgMutation) Status() (r types.PackageStatus, exists bool)

Status returns the value of the "status" field in the mutation.

func (PkgMutation) Tx

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

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

func (*PkgMutation) Type

func (m *PkgMutation) Type() string

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

func (*PkgMutation) Where

func (m *PkgMutation) Where(ps ...predicate.Pkg)

Where appends a list predicates to the PkgMutation builder.

func (*PkgMutation) WhereP

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

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

type PkgQuery

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

PkgQuery is the builder for querying Pkg entities.

func (*PkgQuery) Aggregate

func (pq *PkgQuery) Aggregate(fns ...AggregateFunc) *PkgSelect

Aggregate returns a PkgSelect configured with the given aggregations.

func (*PkgQuery) All

func (pq *PkgQuery) All(ctx context.Context) ([]*Pkg, error)

All executes the query and returns a list of Pkgs.

func (*PkgQuery) AllX

func (pq *PkgQuery) AllX(ctx context.Context) []*Pkg

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

func (*PkgQuery) Clone

func (pq *PkgQuery) Clone() *PkgQuery

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

func (*PkgQuery) Count

func (pq *PkgQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*PkgQuery) CountX

func (pq *PkgQuery) CountX(ctx context.Context) int

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

func (*PkgQuery) Exist

func (pq *PkgQuery) Exist(ctx context.Context) (bool, error)

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

func (*PkgQuery) ExistX

func (pq *PkgQuery) ExistX(ctx context.Context) bool

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

func (*PkgQuery) First

func (pq *PkgQuery) First(ctx context.Context) (*Pkg, error)

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

func (*PkgQuery) FirstID

func (pq *PkgQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*PkgQuery) FirstIDX

func (pq *PkgQuery) FirstIDX(ctx context.Context) int

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

func (*PkgQuery) FirstX

func (pq *PkgQuery) FirstX(ctx context.Context) *Pkg

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

func (*PkgQuery) GroupBy

func (pq *PkgQuery) GroupBy(field string, fields ...string) *PkgGroupBy

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.Pkg.Query().
	GroupBy(pkg.FieldName).
	Aggregate(db.Count()).
	Scan(ctx, &v)

func (*PkgQuery) IDs

func (pq *PkgQuery) IDs(ctx context.Context) (ids []int, err error)

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

func (*PkgQuery) IDsX

func (pq *PkgQuery) IDsX(ctx context.Context) []int

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

func (*PkgQuery) Limit

func (pq *PkgQuery) Limit(limit int) *PkgQuery

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

func (*PkgQuery) Offset

func (pq *PkgQuery) Offset(offset int) *PkgQuery

Offset to start from.

func (*PkgQuery) Only

func (pq *PkgQuery) Only(ctx context.Context) (*Pkg, error)

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

func (*PkgQuery) OnlyID

func (pq *PkgQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*PkgQuery) OnlyIDX

func (pq *PkgQuery) OnlyIDX(ctx context.Context) int

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

func (*PkgQuery) OnlyX

func (pq *PkgQuery) OnlyX(ctx context.Context) *Pkg

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

func (*PkgQuery) Order

func (pq *PkgQuery) Order(o ...pkg.OrderOption) *PkgQuery

Order specifies how the records should be ordered.

func (*PkgQuery) QueryLocation

func (pq *PkgQuery) QueryLocation() *LocationQuery

QueryLocation chains the current query on the "location" edge.

func (*PkgQuery) Select

func (pq *PkgQuery) Select(fields ...string) *PkgSelect

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

func (*PkgQuery) Unique

func (pq *PkgQuery) Unique(unique bool) *PkgQuery

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

func (pq *PkgQuery) Where(ps ...predicate.Pkg) *PkgQuery

Where adds a new predicate for the PkgQuery builder.

func (*PkgQuery) WithLocation

func (pq *PkgQuery) WithLocation(opts ...func(*LocationQuery)) *PkgQuery

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

type PkgSelect

type PkgSelect struct {
	*PkgQuery
	// contains filtered or unexported fields
}

PkgSelect is the builder for selecting fields of Pkg entities.

func (*PkgSelect) Aggregate

func (ps *PkgSelect) Aggregate(fns ...AggregateFunc) *PkgSelect

Aggregate adds the given aggregation functions to the selector query.

func (*PkgSelect) Bool

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

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

func (*PkgSelect) BoolX

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

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

func (*PkgSelect) Bools

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

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

func (*PkgSelect) BoolsX

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

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

func (*PkgSelect) Float64

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

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

func (*PkgSelect) Float64X

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

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

func (*PkgSelect) Float64s

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

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

func (*PkgSelect) Float64sX

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

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

func (*PkgSelect) Int

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

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

func (*PkgSelect) IntX

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

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

func (*PkgSelect) Ints

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

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

func (*PkgSelect) IntsX

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

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

func (*PkgSelect) Scan

func (ps *PkgSelect) Scan(ctx context.Context, v any) error

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

func (*PkgSelect) ScanX

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

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

func (*PkgSelect) String

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

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

func (*PkgSelect) StringX

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

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

func (*PkgSelect) Strings

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

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

func (*PkgSelect) StringsX

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

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

type PkgUpdate

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

PkgUpdate is the builder for updating Pkg entities.

func (*PkgUpdate) ClearLocation

func (pu *PkgUpdate) ClearLocation() *PkgUpdate

ClearLocation clears the "location" edge to the Location entity.

func (*PkgUpdate) ClearLocationID

func (pu *PkgUpdate) ClearLocationID() *PkgUpdate

ClearLocationID clears the value of the "location_id" field.

func (*PkgUpdate) Exec

func (pu *PkgUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*PkgUpdate) ExecX

func (pu *PkgUpdate) ExecX(ctx context.Context)

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

func (*PkgUpdate) Mutation

func (pu *PkgUpdate) Mutation() *PkgMutation

Mutation returns the PkgMutation object of the builder.

func (*PkgUpdate) Save

func (pu *PkgUpdate) Save(ctx context.Context) (int, error)

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

func (*PkgUpdate) SaveX

func (pu *PkgUpdate) SaveX(ctx context.Context) int

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

func (*PkgUpdate) SetAipID

func (pu *PkgUpdate) SetAipID(u uuid.UUID) *PkgUpdate

SetAipID sets the "aip_id" field.

func (*PkgUpdate) SetLocation

func (pu *PkgUpdate) SetLocation(l *Location) *PkgUpdate

SetLocation sets the "location" edge to the Location entity.

func (*PkgUpdate) SetLocationID

func (pu *PkgUpdate) SetLocationID(i int) *PkgUpdate

SetLocationID sets the "location_id" field.

func (*PkgUpdate) SetName

func (pu *PkgUpdate) SetName(s string) *PkgUpdate

SetName sets the "name" field.

func (*PkgUpdate) SetNillableAipID

func (pu *PkgUpdate) SetNillableAipID(u *uuid.UUID) *PkgUpdate

SetNillableAipID sets the "aip_id" field if the given value is not nil.

func (*PkgUpdate) SetNillableLocationID

func (pu *PkgUpdate) SetNillableLocationID(i *int) *PkgUpdate

SetNillableLocationID sets the "location_id" field if the given value is not nil.

func (*PkgUpdate) SetNillableName

func (pu *PkgUpdate) SetNillableName(s *string) *PkgUpdate

SetNillableName sets the "name" field if the given value is not nil.

func (*PkgUpdate) SetNillableObjectKey

func (pu *PkgUpdate) SetNillableObjectKey(u *uuid.UUID) *PkgUpdate

SetNillableObjectKey sets the "object_key" field if the given value is not nil.

func (*PkgUpdate) SetNillableStatus

func (pu *PkgUpdate) SetNillableStatus(ts *types.PackageStatus) *PkgUpdate

SetNillableStatus sets the "status" field if the given value is not nil.

func (*PkgUpdate) SetObjectKey

func (pu *PkgUpdate) SetObjectKey(u uuid.UUID) *PkgUpdate

SetObjectKey sets the "object_key" field.

func (*PkgUpdate) SetStatus

func (pu *PkgUpdate) SetStatus(ts types.PackageStatus) *PkgUpdate

SetStatus sets the "status" field.

func (*PkgUpdate) Where

func (pu *PkgUpdate) Where(ps ...predicate.Pkg) *PkgUpdate

Where appends a list predicates to the PkgUpdate builder.

type PkgUpdateOne

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

PkgUpdateOne is the builder for updating a single Pkg entity.

func (*PkgUpdateOne) ClearLocation

func (puo *PkgUpdateOne) ClearLocation() *PkgUpdateOne

ClearLocation clears the "location" edge to the Location entity.

func (*PkgUpdateOne) ClearLocationID

func (puo *PkgUpdateOne) ClearLocationID() *PkgUpdateOne

ClearLocationID clears the value of the "location_id" field.

func (*PkgUpdateOne) Exec

func (puo *PkgUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*PkgUpdateOne) ExecX

func (puo *PkgUpdateOne) ExecX(ctx context.Context)

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

func (*PkgUpdateOne) Mutation

func (puo *PkgUpdateOne) Mutation() *PkgMutation

Mutation returns the PkgMutation object of the builder.

func (*PkgUpdateOne) Save

func (puo *PkgUpdateOne) Save(ctx context.Context) (*Pkg, error)

Save executes the query and returns the updated Pkg entity.

func (*PkgUpdateOne) SaveX

func (puo *PkgUpdateOne) SaveX(ctx context.Context) *Pkg

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

func (*PkgUpdateOne) Select

func (puo *PkgUpdateOne) Select(field string, fields ...string) *PkgUpdateOne

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

func (*PkgUpdateOne) SetAipID

func (puo *PkgUpdateOne) SetAipID(u uuid.UUID) *PkgUpdateOne

SetAipID sets the "aip_id" field.

func (*PkgUpdateOne) SetLocation

func (puo *PkgUpdateOne) SetLocation(l *Location) *PkgUpdateOne

SetLocation sets the "location" edge to the Location entity.

func (*PkgUpdateOne) SetLocationID

func (puo *PkgUpdateOne) SetLocationID(i int) *PkgUpdateOne

SetLocationID sets the "location_id" field.

func (*PkgUpdateOne) SetName

func (puo *PkgUpdateOne) SetName(s string) *PkgUpdateOne

SetName sets the "name" field.

func (*PkgUpdateOne) SetNillableAipID

func (puo *PkgUpdateOne) SetNillableAipID(u *uuid.UUID) *PkgUpdateOne

SetNillableAipID sets the "aip_id" field if the given value is not nil.

func (*PkgUpdateOne) SetNillableLocationID

func (puo *PkgUpdateOne) SetNillableLocationID(i *int) *PkgUpdateOne

SetNillableLocationID sets the "location_id" field if the given value is not nil.

func (*PkgUpdateOne) SetNillableName

func (puo *PkgUpdateOne) SetNillableName(s *string) *PkgUpdateOne

SetNillableName sets the "name" field if the given value is not nil.

func (*PkgUpdateOne) SetNillableObjectKey

func (puo *PkgUpdateOne) SetNillableObjectKey(u *uuid.UUID) *PkgUpdateOne

SetNillableObjectKey sets the "object_key" field if the given value is not nil.

func (*PkgUpdateOne) SetNillableStatus

func (puo *PkgUpdateOne) SetNillableStatus(ts *types.PackageStatus) *PkgUpdateOne

SetNillableStatus sets the "status" field if the given value is not nil.

func (*PkgUpdateOne) SetObjectKey

func (puo *PkgUpdateOne) SetObjectKey(u uuid.UUID) *PkgUpdateOne

SetObjectKey sets the "object_key" field.

func (*PkgUpdateOne) SetStatus

func (puo *PkgUpdateOne) SetStatus(ts types.PackageStatus) *PkgUpdateOne

SetStatus sets the "status" field.

func (*PkgUpdateOne) Where

func (puo *PkgUpdateOne) Where(ps ...predicate.Pkg) *PkgUpdateOne

Where appends a list predicates to the PkgUpdate builder.

type Pkgs

type Pkgs []*Pkg

Pkgs is a parsable slice of Pkg.

type Policy

type Policy = ent.Policy

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

type Querier

type Querier = ent.Querier

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

type QuerierFunc

type QuerierFunc = ent.QuerierFunc

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

type Query

type Query = ent.Query

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

type QueryContext

type QueryContext = ent.QueryContext

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

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

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

type Rollbacker

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

Rollbacker is the interface that wraps the Rollback method.

type TraverseFunc

type TraverseFunc = ent.TraverseFunc

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

type Traverser

type Traverser = ent.Traverser

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

type Tx

type Tx struct {

	// Location is the client for interacting with the Location builders.
	Location *LocationClient
	// Pkg is the client for interacting with the Pkg builders.
	Pkg *PkgClient
	// contains filtered or unexported fields
}

Tx is a transactional client that is created by calling Client.Tx().

func TxFromContext

func TxFromContext(ctx context.Context) *Tx

TxFromContext returns a Tx stored inside a context, or nil if there isn't one.

func (*Tx) Client

func (tx *Tx) Client() *Client

Client returns a Client that binds to current transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) OnCommit

func (tx *Tx) OnCommit(f CommitHook)

OnCommit adds a hook to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f RollbackHook)

OnRollback adds a hook to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

type ValidationError

type ValidationError struct {
	Name string // Field or edge name.
	// contains filtered or unexported fields
}

ValidationError returns when validating a field or edge fails.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Value

type Value = ent.Value

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL