ent

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: MIT Imports: 19 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.
	TypeDirectory = "Directory"
	TypeImage     = "Image"
)

Variables

View Source
var ErrTxStarted = errors.New("ent: 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(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
Scan(ctx, &v)

func Count

func Count() AggregateFunc

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

func Max

func Max(field string) AggregateFunc

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

func Mean

func Mean(field string) AggregateFunc

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

func Min

func Min(field string) AggregateFunc

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

func Sum

func Sum(field string) AggregateFunc

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

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Directory is the client for interacting with the Directory builders.
	Directory *DirectoryClient
	// Image is the client for interacting with the Image builders.
	Image *ImageClient
	// 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().
	Directory.
	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 Directories

type Directories []*Directory

Directories is a parsable slice of Directory.

type Directory

type Directory struct {

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

Directory is the model entity for the Directory schema.

func (*Directory) QueryChildren

func (d *Directory) QueryChildren() *DirectoryQuery

QueryChildren queries the "children" edge of the Directory entity.

func (*Directory) QueryImages

func (d *Directory) QueryImages() *ImageQuery

QueryImages queries the "images" edge of the Directory entity.

func (*Directory) QueryParent

func (d *Directory) QueryParent() *DirectoryQuery

QueryParent queries the "parent" edge of the Directory entity.

func (*Directory) String

func (d *Directory) String() string

String implements the fmt.Stringer.

func (*Directory) Unwrap

func (d *Directory) Unwrap() *Directory

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

func (d *Directory) Update() *DirectoryUpdateOne

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

func (*Directory) Value

func (d *Directory) Value(name string) (ent.Value, error)

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

type DirectoryClient

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

DirectoryClient is a client for the Directory schema.

func NewDirectoryClient

func NewDirectoryClient(c config) *DirectoryClient

NewDirectoryClient returns a client for the Directory from the given config.

func (*DirectoryClient) Create

func (c *DirectoryClient) Create() *DirectoryCreate

Create returns a builder for creating a Directory entity.

func (*DirectoryClient) CreateBulk

func (c *DirectoryClient) CreateBulk(builders ...*DirectoryCreate) *DirectoryCreateBulk

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

func (*DirectoryClient) Delete

func (c *DirectoryClient) Delete() *DirectoryDelete

Delete returns a delete builder for Directory.

func (*DirectoryClient) DeleteOne

func (c *DirectoryClient) DeleteOne(d *Directory) *DirectoryDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*DirectoryClient) DeleteOneID

func (c *DirectoryClient) DeleteOneID(id int) *DirectoryDeleteOne

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

func (*DirectoryClient) Get

func (c *DirectoryClient) Get(ctx context.Context, id int) (*Directory, error)

Get returns a Directory entity by its id.

func (*DirectoryClient) GetX

func (c *DirectoryClient) GetX(ctx context.Context, id int) *Directory

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

func (*DirectoryClient) Hooks

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

Hooks returns the client hooks.

func (*DirectoryClient) Intercept

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

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

func (*DirectoryClient) Interceptors

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

Interceptors returns the client interceptors.

func (*DirectoryClient) MapCreateBulk

func (c *DirectoryClient) MapCreateBulk(slice any, setFunc func(*DirectoryCreate, int)) *DirectoryCreateBulk

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 (*DirectoryClient) Query

func (c *DirectoryClient) Query() *DirectoryQuery

Query returns a query builder for Directory.

func (*DirectoryClient) QueryChildren

func (c *DirectoryClient) QueryChildren(d *Directory) *DirectoryQuery

QueryChildren queries the children edge of a Directory.

func (*DirectoryClient) QueryImages

func (c *DirectoryClient) QueryImages(d *Directory) *ImageQuery

QueryImages queries the images edge of a Directory.

func (*DirectoryClient) QueryParent

func (c *DirectoryClient) QueryParent(d *Directory) *DirectoryQuery

QueryParent queries the parent edge of a Directory.

func (*DirectoryClient) Update

func (c *DirectoryClient) Update() *DirectoryUpdate

Update returns an update builder for Directory.

func (*DirectoryClient) UpdateOne

func (c *DirectoryClient) UpdateOne(d *Directory) *DirectoryUpdateOne

UpdateOne returns an update builder for the given entity.

func (*DirectoryClient) UpdateOneID

func (c *DirectoryClient) UpdateOneID(id int) *DirectoryUpdateOne

UpdateOneID returns an update builder for the given id.

func (*DirectoryClient) Use

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

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

type DirectoryCreate

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

DirectoryCreate is the builder for creating a Directory entity.

func (*DirectoryCreate) AddChildIDs

func (dc *DirectoryCreate) AddChildIDs(ids ...int) *DirectoryCreate

AddChildIDs adds the "children" edge to the Directory entity by IDs.

func (*DirectoryCreate) AddChildren

func (dc *DirectoryCreate) AddChildren(d ...*Directory) *DirectoryCreate

AddChildren adds the "children" edges to the Directory entity.

func (*DirectoryCreate) AddImageIDs

func (dc *DirectoryCreate) AddImageIDs(ids ...int) *DirectoryCreate

AddImageIDs adds the "images" edge to the Image entity by IDs.

func (*DirectoryCreate) AddImages

func (dc *DirectoryCreate) AddImages(i ...*Image) *DirectoryCreate

AddImages adds the "images" edges to the Image entity.

func (*DirectoryCreate) Exec

func (dc *DirectoryCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*DirectoryCreate) ExecX

func (dc *DirectoryCreate) ExecX(ctx context.Context)

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

func (*DirectoryCreate) Mutation

func (dc *DirectoryCreate) Mutation() *DirectoryMutation

Mutation returns the DirectoryMutation object of the builder.

func (*DirectoryCreate) Save

func (dc *DirectoryCreate) Save(ctx context.Context) (*Directory, error)

Save creates the Directory in the database.

func (*DirectoryCreate) SaveX

func (dc *DirectoryCreate) SaveX(ctx context.Context) *Directory

SaveX calls Save and panics if Save returns an error.

func (*DirectoryCreate) SetName

func (dc *DirectoryCreate) SetName(s string) *DirectoryCreate

SetName sets the "name" field.

func (*DirectoryCreate) SetNillableParentID

func (dc *DirectoryCreate) SetNillableParentID(id *int) *DirectoryCreate

SetNillableParentID sets the "parent" edge to the Directory entity by ID if the given value is not nil.

func (*DirectoryCreate) SetParent

func (dc *DirectoryCreate) SetParent(d *Directory) *DirectoryCreate

SetParent sets the "parent" edge to the Directory entity.

func (*DirectoryCreate) SetParentID

func (dc *DirectoryCreate) SetParentID(id int) *DirectoryCreate

SetParentID sets the "parent" edge to the Directory entity by ID.

func (*DirectoryCreate) SetPath

func (dc *DirectoryCreate) SetPath(s string) *DirectoryCreate

SetPath sets the "path" field.

type DirectoryCreateBulk

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

DirectoryCreateBulk is the builder for creating many Directory entities in bulk.

func (*DirectoryCreateBulk) Exec

func (dcb *DirectoryCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*DirectoryCreateBulk) ExecX

func (dcb *DirectoryCreateBulk) ExecX(ctx context.Context)

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

func (*DirectoryCreateBulk) Save

func (dcb *DirectoryCreateBulk) Save(ctx context.Context) ([]*Directory, error)

Save creates the Directory entities in the database.

func (*DirectoryCreateBulk) SaveX

func (dcb *DirectoryCreateBulk) SaveX(ctx context.Context) []*Directory

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

type DirectoryDelete

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

DirectoryDelete is the builder for deleting a Directory entity.

func (*DirectoryDelete) Exec

func (dd *DirectoryDelete) Exec(ctx context.Context) (int, error)

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

func (*DirectoryDelete) ExecX

func (dd *DirectoryDelete) ExecX(ctx context.Context) int

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

func (*DirectoryDelete) Where

Where appends a list predicates to the DirectoryDelete builder.

type DirectoryDeleteOne

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

DirectoryDeleteOne is the builder for deleting a single Directory entity.

func (*DirectoryDeleteOne) Exec

func (ddo *DirectoryDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*DirectoryDeleteOne) ExecX

func (ddo *DirectoryDeleteOne) ExecX(ctx context.Context)

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

func (*DirectoryDeleteOne) Where

Where appends a list predicates to the DirectoryDelete builder.

type DirectoryEdges

type DirectoryEdges struct {
	// Parent holds the value of the parent edge.
	Parent *Directory `json:"parent,omitempty"`
	// Children holds the value of the children edge.
	Children []*Directory `json:"children,omitempty"`
	// Images holds the value of the images edge.
	Images []*Image `json:"images,omitempty"`
	// contains filtered or unexported fields
}

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

func (DirectoryEdges) ChildrenOrErr

func (e DirectoryEdges) ChildrenOrErr() ([]*Directory, error)

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

func (DirectoryEdges) ImagesOrErr

func (e DirectoryEdges) ImagesOrErr() ([]*Image, error)

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

func (DirectoryEdges) ParentOrErr

func (e DirectoryEdges) ParentOrErr() (*Directory, error)

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

type DirectoryGroupBy

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

DirectoryGroupBy is the group-by builder for Directory entities.

func (*DirectoryGroupBy) Aggregate

func (dgb *DirectoryGroupBy) Aggregate(fns ...AggregateFunc) *DirectoryGroupBy

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

func (*DirectoryGroupBy) Bool

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

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

func (*DirectoryGroupBy) BoolX

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

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

func (*DirectoryGroupBy) Bools

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

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

func (*DirectoryGroupBy) BoolsX

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

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

func (*DirectoryGroupBy) Float64

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

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

func (*DirectoryGroupBy) Float64X

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

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

func (*DirectoryGroupBy) Float64s

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

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

func (*DirectoryGroupBy) Float64sX

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

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

func (*DirectoryGroupBy) Int

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

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

func (*DirectoryGroupBy) IntX

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

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

func (*DirectoryGroupBy) Ints

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

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

func (*DirectoryGroupBy) IntsX

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

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

func (*DirectoryGroupBy) Scan

func (dgb *DirectoryGroupBy) Scan(ctx context.Context, v any) error

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

func (*DirectoryGroupBy) ScanX

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

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

func (*DirectoryGroupBy) String

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

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

func (*DirectoryGroupBy) StringX

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

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

func (*DirectoryGroupBy) Strings

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

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

func (*DirectoryGroupBy) StringsX

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

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

type DirectoryMutation

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

DirectoryMutation represents an operation that mutates the Directory nodes in the graph.

func (*DirectoryMutation) AddChildIDs

func (m *DirectoryMutation) AddChildIDs(ids ...int)

AddChildIDs adds the "children" edge to the Directory entity by ids.

func (*DirectoryMutation) AddField

func (m *DirectoryMutation) 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 (*DirectoryMutation) AddImageIDs

func (m *DirectoryMutation) AddImageIDs(ids ...int)

AddImageIDs adds the "images" edge to the Image entity by ids.

func (*DirectoryMutation) AddedEdges

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

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

func (*DirectoryMutation) AddedField

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

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

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

func (*DirectoryMutation) AddedIDs

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

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

func (*DirectoryMutation) ChildrenCleared

func (m *DirectoryMutation) ChildrenCleared() bool

ChildrenCleared reports if the "children" edge to the Directory entity was cleared.

func (*DirectoryMutation) ChildrenIDs

func (m *DirectoryMutation) ChildrenIDs() (ids []int)

ChildrenIDs returns the "children" edge IDs in the mutation.

func (*DirectoryMutation) ClearChildren

func (m *DirectoryMutation) ClearChildren()

ClearChildren clears the "children" edge to the Directory entity.

func (*DirectoryMutation) ClearEdge

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

func (m *DirectoryMutation) 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 (*DirectoryMutation) ClearImages

func (m *DirectoryMutation) ClearImages()

ClearImages clears the "images" edge to the Image entity.

func (*DirectoryMutation) ClearParent

func (m *DirectoryMutation) ClearParent()

ClearParent clears the "parent" edge to the Directory entity.

func (*DirectoryMutation) ClearedEdges

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

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

func (*DirectoryMutation) ClearedFields

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

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

func (DirectoryMutation) Client

func (m DirectoryMutation) 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 (*DirectoryMutation) EdgeCleared

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

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

func (*DirectoryMutation) Field

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

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

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

func (*DirectoryMutation) Fields

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

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

func (m *DirectoryMutation) 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 (*DirectoryMutation) ImagesCleared

func (m *DirectoryMutation) ImagesCleared() bool

ImagesCleared reports if the "images" edge to the Image entity was cleared.

func (*DirectoryMutation) ImagesIDs

func (m *DirectoryMutation) ImagesIDs() (ids []int)

ImagesIDs returns the "images" edge IDs in the mutation.

func (*DirectoryMutation) Name

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

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

func (*DirectoryMutation) OldField

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

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

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

func (m *DirectoryMutation) OldPath(ctx context.Context) (v string, err error)

OldPath returns the old "path" field's value of the Directory entity. If the Directory 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 (*DirectoryMutation) Op

func (m *DirectoryMutation) Op() Op

Op returns the operation name.

func (*DirectoryMutation) ParentCleared

func (m *DirectoryMutation) ParentCleared() bool

ParentCleared reports if the "parent" edge to the Directory entity was cleared.

func (*DirectoryMutation) ParentID

func (m *DirectoryMutation) ParentID() (id int, exists bool)

ParentID returns the "parent" edge ID in the mutation.

func (*DirectoryMutation) ParentIDs

func (m *DirectoryMutation) ParentIDs() (ids []int)

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

func (*DirectoryMutation) Path

func (m *DirectoryMutation) Path() (r string, exists bool)

Path returns the value of the "path" field in the mutation.

func (*DirectoryMutation) RemoveChildIDs

func (m *DirectoryMutation) RemoveChildIDs(ids ...int)

RemoveChildIDs removes the "children" edge to the Directory entity by IDs.

func (*DirectoryMutation) RemoveImageIDs

func (m *DirectoryMutation) RemoveImageIDs(ids ...int)

RemoveImageIDs removes the "images" edge to the Image entity by IDs.

func (*DirectoryMutation) RemovedChildrenIDs

func (m *DirectoryMutation) RemovedChildrenIDs() (ids []int)

RemovedChildren returns the removed IDs of the "children" edge to the Directory entity.

func (*DirectoryMutation) RemovedEdges

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

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

func (*DirectoryMutation) RemovedIDs

func (m *DirectoryMutation) 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 (*DirectoryMutation) RemovedImagesIDs

func (m *DirectoryMutation) RemovedImagesIDs() (ids []int)

RemovedImages returns the removed IDs of the "images" edge to the Image entity.

func (*DirectoryMutation) ResetChildren

func (m *DirectoryMutation) ResetChildren()

ResetChildren resets all changes to the "children" edge.

func (*DirectoryMutation) ResetEdge

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

func (m *DirectoryMutation) 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 (*DirectoryMutation) ResetImages

func (m *DirectoryMutation) ResetImages()

ResetImages resets all changes to the "images" edge.

func (*DirectoryMutation) ResetName

func (m *DirectoryMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*DirectoryMutation) ResetParent

func (m *DirectoryMutation) ResetParent()

ResetParent resets all changes to the "parent" edge.

func (*DirectoryMutation) ResetPath

func (m *DirectoryMutation) ResetPath()

ResetPath resets all changes to the "path" field.

func (*DirectoryMutation) SetField

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

func (m *DirectoryMutation) SetName(s string)

SetName sets the "name" field.

func (*DirectoryMutation) SetOp

func (m *DirectoryMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*DirectoryMutation) SetParentID

func (m *DirectoryMutation) SetParentID(id int)

SetParentID sets the "parent" edge to the Directory entity by id.

func (*DirectoryMutation) SetPath

func (m *DirectoryMutation) SetPath(s string)

SetPath sets the "path" field.

func (DirectoryMutation) Tx

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

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

func (*DirectoryMutation) Type

func (m *DirectoryMutation) Type() string

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

func (*DirectoryMutation) Where

func (m *DirectoryMutation) Where(ps ...predicate.Directory)

Where appends a list predicates to the DirectoryMutation builder.

func (*DirectoryMutation) WhereP

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

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

type DirectoryQuery

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

DirectoryQuery is the builder for querying Directory entities.

func (*DirectoryQuery) Aggregate

func (dq *DirectoryQuery) Aggregate(fns ...AggregateFunc) *DirectorySelect

Aggregate returns a DirectorySelect configured with the given aggregations.

func (*DirectoryQuery) All

func (dq *DirectoryQuery) All(ctx context.Context) ([]*Directory, error)

All executes the query and returns a list of Directories.

func (*DirectoryQuery) AllX

func (dq *DirectoryQuery) AllX(ctx context.Context) []*Directory

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

func (*DirectoryQuery) Clone

func (dq *DirectoryQuery) Clone() *DirectoryQuery

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

func (*DirectoryQuery) Count

func (dq *DirectoryQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*DirectoryQuery) CountX

func (dq *DirectoryQuery) CountX(ctx context.Context) int

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

func (*DirectoryQuery) Exist

func (dq *DirectoryQuery) Exist(ctx context.Context) (bool, error)

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

func (*DirectoryQuery) ExistX

func (dq *DirectoryQuery) ExistX(ctx context.Context) bool

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

func (*DirectoryQuery) First

func (dq *DirectoryQuery) First(ctx context.Context) (*Directory, error)

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

func (*DirectoryQuery) FirstID

func (dq *DirectoryQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*DirectoryQuery) FirstIDX

func (dq *DirectoryQuery) FirstIDX(ctx context.Context) int

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

func (*DirectoryQuery) FirstX

func (dq *DirectoryQuery) FirstX(ctx context.Context) *Directory

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

func (*DirectoryQuery) GroupBy

func (dq *DirectoryQuery) GroupBy(field string, fields ...string) *DirectoryGroupBy

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

client.Directory.Query().
	GroupBy(directory.FieldPath).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*DirectoryQuery) IDs

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

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

func (*DirectoryQuery) IDsX

func (dq *DirectoryQuery) IDsX(ctx context.Context) []int

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

func (*DirectoryQuery) Limit

func (dq *DirectoryQuery) Limit(limit int) *DirectoryQuery

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

func (*DirectoryQuery) Offset

func (dq *DirectoryQuery) Offset(offset int) *DirectoryQuery

Offset to start from.

func (*DirectoryQuery) Only

func (dq *DirectoryQuery) Only(ctx context.Context) (*Directory, error)

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

func (*DirectoryQuery) OnlyID

func (dq *DirectoryQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*DirectoryQuery) OnlyIDX

func (dq *DirectoryQuery) OnlyIDX(ctx context.Context) int

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

func (*DirectoryQuery) OnlyX

func (dq *DirectoryQuery) OnlyX(ctx context.Context) *Directory

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

func (*DirectoryQuery) Order

Order specifies how the records should be ordered.

func (*DirectoryQuery) QueryChildren

func (dq *DirectoryQuery) QueryChildren() *DirectoryQuery

QueryChildren chains the current query on the "children" edge.

func (*DirectoryQuery) QueryImages

func (dq *DirectoryQuery) QueryImages() *ImageQuery

QueryImages chains the current query on the "images" edge.

func (*DirectoryQuery) QueryParent

func (dq *DirectoryQuery) QueryParent() *DirectoryQuery

QueryParent chains the current query on the "parent" edge.

func (*DirectoryQuery) Select

func (dq *DirectoryQuery) Select(fields ...string) *DirectorySelect

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

client.Directory.Query().
	Select(directory.FieldPath).
	Scan(ctx, &v)

func (*DirectoryQuery) Unique

func (dq *DirectoryQuery) Unique(unique bool) *DirectoryQuery

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

Where adds a new predicate for the DirectoryQuery builder.

func (*DirectoryQuery) WithChildren

func (dq *DirectoryQuery) WithChildren(opts ...func(*DirectoryQuery)) *DirectoryQuery

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

func (*DirectoryQuery) WithImages

func (dq *DirectoryQuery) WithImages(opts ...func(*ImageQuery)) *DirectoryQuery

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

func (*DirectoryQuery) WithParent

func (dq *DirectoryQuery) WithParent(opts ...func(*DirectoryQuery)) *DirectoryQuery

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

type DirectorySelect

type DirectorySelect struct {
	*DirectoryQuery
	// contains filtered or unexported fields
}

DirectorySelect is the builder for selecting fields of Directory entities.

func (*DirectorySelect) Aggregate

func (ds *DirectorySelect) Aggregate(fns ...AggregateFunc) *DirectorySelect

Aggregate adds the given aggregation functions to the selector query.

func (*DirectorySelect) Bool

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

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

func (*DirectorySelect) BoolX

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

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

func (*DirectorySelect) Bools

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

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

func (*DirectorySelect) BoolsX

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

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

func (*DirectorySelect) Float64

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

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

func (*DirectorySelect) Float64X

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

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

func (*DirectorySelect) Float64s

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

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

func (*DirectorySelect) Float64sX

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

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

func (*DirectorySelect) Int

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

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

func (*DirectorySelect) IntX

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

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

func (*DirectorySelect) Ints

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

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

func (*DirectorySelect) IntsX

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

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

func (*DirectorySelect) Scan

func (ds *DirectorySelect) Scan(ctx context.Context, v any) error

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

func (*DirectorySelect) ScanX

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

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

func (*DirectorySelect) String

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

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

func (*DirectorySelect) StringX

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

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

func (*DirectorySelect) Strings

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

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

func (*DirectorySelect) StringsX

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

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

type DirectoryUpdate

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

DirectoryUpdate is the builder for updating Directory entities.

func (*DirectoryUpdate) AddChildIDs

func (du *DirectoryUpdate) AddChildIDs(ids ...int) *DirectoryUpdate

AddChildIDs adds the "children" edge to the Directory entity by IDs.

func (*DirectoryUpdate) AddChildren

func (du *DirectoryUpdate) AddChildren(d ...*Directory) *DirectoryUpdate

AddChildren adds the "children" edges to the Directory entity.

func (*DirectoryUpdate) AddImageIDs

func (du *DirectoryUpdate) AddImageIDs(ids ...int) *DirectoryUpdate

AddImageIDs adds the "images" edge to the Image entity by IDs.

func (*DirectoryUpdate) AddImages

func (du *DirectoryUpdate) AddImages(i ...*Image) *DirectoryUpdate

AddImages adds the "images" edges to the Image entity.

func (*DirectoryUpdate) ClearChildren

func (du *DirectoryUpdate) ClearChildren() *DirectoryUpdate

ClearChildren clears all "children" edges to the Directory entity.

func (*DirectoryUpdate) ClearImages

func (du *DirectoryUpdate) ClearImages() *DirectoryUpdate

ClearImages clears all "images" edges to the Image entity.

func (*DirectoryUpdate) ClearParent

func (du *DirectoryUpdate) ClearParent() *DirectoryUpdate

ClearParent clears the "parent" edge to the Directory entity.

func (*DirectoryUpdate) Exec

func (du *DirectoryUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*DirectoryUpdate) ExecX

func (du *DirectoryUpdate) ExecX(ctx context.Context)

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

func (*DirectoryUpdate) Mutation

func (du *DirectoryUpdate) Mutation() *DirectoryMutation

Mutation returns the DirectoryMutation object of the builder.

func (*DirectoryUpdate) RemoveChildIDs

func (du *DirectoryUpdate) RemoveChildIDs(ids ...int) *DirectoryUpdate

RemoveChildIDs removes the "children" edge to Directory entities by IDs.

func (*DirectoryUpdate) RemoveChildren

func (du *DirectoryUpdate) RemoveChildren(d ...*Directory) *DirectoryUpdate

RemoveChildren removes "children" edges to Directory entities.

func (*DirectoryUpdate) RemoveImageIDs

func (du *DirectoryUpdate) RemoveImageIDs(ids ...int) *DirectoryUpdate

RemoveImageIDs removes the "images" edge to Image entities by IDs.

func (*DirectoryUpdate) RemoveImages

func (du *DirectoryUpdate) RemoveImages(i ...*Image) *DirectoryUpdate

RemoveImages removes "images" edges to Image entities.

func (*DirectoryUpdate) Save

func (du *DirectoryUpdate) Save(ctx context.Context) (int, error)

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

func (*DirectoryUpdate) SaveX

func (du *DirectoryUpdate) SaveX(ctx context.Context) int

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

func (*DirectoryUpdate) SetName

func (du *DirectoryUpdate) SetName(s string) *DirectoryUpdate

SetName sets the "name" field.

func (*DirectoryUpdate) SetNillableName

func (du *DirectoryUpdate) SetNillableName(s *string) *DirectoryUpdate

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

func (*DirectoryUpdate) SetNillableParentID

func (du *DirectoryUpdate) SetNillableParentID(id *int) *DirectoryUpdate

SetNillableParentID sets the "parent" edge to the Directory entity by ID if the given value is not nil.

func (*DirectoryUpdate) SetNillablePath

func (du *DirectoryUpdate) SetNillablePath(s *string) *DirectoryUpdate

SetNillablePath sets the "path" field if the given value is not nil.

func (*DirectoryUpdate) SetParent

func (du *DirectoryUpdate) SetParent(d *Directory) *DirectoryUpdate

SetParent sets the "parent" edge to the Directory entity.

func (*DirectoryUpdate) SetParentID

func (du *DirectoryUpdate) SetParentID(id int) *DirectoryUpdate

SetParentID sets the "parent" edge to the Directory entity by ID.

func (*DirectoryUpdate) SetPath

func (du *DirectoryUpdate) SetPath(s string) *DirectoryUpdate

SetPath sets the "path" field.

func (*DirectoryUpdate) Where

Where appends a list predicates to the DirectoryUpdate builder.

type DirectoryUpdateOne

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

DirectoryUpdateOne is the builder for updating a single Directory entity.

func (*DirectoryUpdateOne) AddChildIDs

func (duo *DirectoryUpdateOne) AddChildIDs(ids ...int) *DirectoryUpdateOne

AddChildIDs adds the "children" edge to the Directory entity by IDs.

func (*DirectoryUpdateOne) AddChildren

func (duo *DirectoryUpdateOne) AddChildren(d ...*Directory) *DirectoryUpdateOne

AddChildren adds the "children" edges to the Directory entity.

func (*DirectoryUpdateOne) AddImageIDs

func (duo *DirectoryUpdateOne) AddImageIDs(ids ...int) *DirectoryUpdateOne

AddImageIDs adds the "images" edge to the Image entity by IDs.

func (*DirectoryUpdateOne) AddImages

func (duo *DirectoryUpdateOne) AddImages(i ...*Image) *DirectoryUpdateOne

AddImages adds the "images" edges to the Image entity.

func (*DirectoryUpdateOne) ClearChildren

func (duo *DirectoryUpdateOne) ClearChildren() *DirectoryUpdateOne

ClearChildren clears all "children" edges to the Directory entity.

func (*DirectoryUpdateOne) ClearImages

func (duo *DirectoryUpdateOne) ClearImages() *DirectoryUpdateOne

ClearImages clears all "images" edges to the Image entity.

func (*DirectoryUpdateOne) ClearParent

func (duo *DirectoryUpdateOne) ClearParent() *DirectoryUpdateOne

ClearParent clears the "parent" edge to the Directory entity.

func (*DirectoryUpdateOne) Exec

func (duo *DirectoryUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*DirectoryUpdateOne) ExecX

func (duo *DirectoryUpdateOne) ExecX(ctx context.Context)

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

func (*DirectoryUpdateOne) Mutation

func (duo *DirectoryUpdateOne) Mutation() *DirectoryMutation

Mutation returns the DirectoryMutation object of the builder.

func (*DirectoryUpdateOne) RemoveChildIDs

func (duo *DirectoryUpdateOne) RemoveChildIDs(ids ...int) *DirectoryUpdateOne

RemoveChildIDs removes the "children" edge to Directory entities by IDs.

func (*DirectoryUpdateOne) RemoveChildren

func (duo *DirectoryUpdateOne) RemoveChildren(d ...*Directory) *DirectoryUpdateOne

RemoveChildren removes "children" edges to Directory entities.

func (*DirectoryUpdateOne) RemoveImageIDs

func (duo *DirectoryUpdateOne) RemoveImageIDs(ids ...int) *DirectoryUpdateOne

RemoveImageIDs removes the "images" edge to Image entities by IDs.

func (*DirectoryUpdateOne) RemoveImages

func (duo *DirectoryUpdateOne) RemoveImages(i ...*Image) *DirectoryUpdateOne

RemoveImages removes "images" edges to Image entities.

func (*DirectoryUpdateOne) Save

func (duo *DirectoryUpdateOne) Save(ctx context.Context) (*Directory, error)

Save executes the query and returns the updated Directory entity.

func (*DirectoryUpdateOne) SaveX

func (duo *DirectoryUpdateOne) SaveX(ctx context.Context) *Directory

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

func (*DirectoryUpdateOne) Select

func (duo *DirectoryUpdateOne) Select(field string, fields ...string) *DirectoryUpdateOne

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

func (*DirectoryUpdateOne) SetName

func (duo *DirectoryUpdateOne) SetName(s string) *DirectoryUpdateOne

SetName sets the "name" field.

func (*DirectoryUpdateOne) SetNillableName

func (duo *DirectoryUpdateOne) SetNillableName(s *string) *DirectoryUpdateOne

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

func (*DirectoryUpdateOne) SetNillableParentID

func (duo *DirectoryUpdateOne) SetNillableParentID(id *int) *DirectoryUpdateOne

SetNillableParentID sets the "parent" edge to the Directory entity by ID if the given value is not nil.

func (*DirectoryUpdateOne) SetNillablePath

func (duo *DirectoryUpdateOne) SetNillablePath(s *string) *DirectoryUpdateOne

SetNillablePath sets the "path" field if the given value is not nil.

func (*DirectoryUpdateOne) SetParent

func (duo *DirectoryUpdateOne) SetParent(d *Directory) *DirectoryUpdateOne

SetParent sets the "parent" edge to the Directory entity.

func (*DirectoryUpdateOne) SetParentID

func (duo *DirectoryUpdateOne) SetParentID(id int) *DirectoryUpdateOne

SetParentID sets the "parent" edge to the Directory entity by ID.

func (*DirectoryUpdateOne) SetPath

func (duo *DirectoryUpdateOne) SetPath(s string) *DirectoryUpdateOne

SetPath sets the "path" field.

func (*DirectoryUpdateOne) Where

Where appends a list predicates to the DirectoryUpdate builder.

type Hook

type Hook = ent.Hook

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

type Image

type Image struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Path holds the value of the "path" field.
	Path string `json:"path,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Size holds the value of the "size" field.
	Size int64 `json:"size,omitempty"`
	// ModTime holds the value of the "mod_time" field.
	ModTime time.Time `json:"mod_time,omitempty"`
	// CreateTime holds the value of the "create_time" field.
	CreateTime time.Time `json:"create_time,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the ImageQuery when eager-loading is set.
	Edges ImageEdges `json:"edges"`
	// contains filtered or unexported fields
}

Image is the model entity for the Image schema.

func (*Image) QueryDirectory

func (i *Image) QueryDirectory() *DirectoryQuery

QueryDirectory queries the "directory" edge of the Image entity.

func (*Image) String

func (i *Image) String() string

String implements the fmt.Stringer.

func (*Image) Unwrap

func (i *Image) Unwrap() *Image

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

func (i *Image) Update() *ImageUpdateOne

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

func (*Image) Value

func (i *Image) Value(name string) (ent.Value, error)

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

type ImageClient

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

ImageClient is a client for the Image schema.

func NewImageClient

func NewImageClient(c config) *ImageClient

NewImageClient returns a client for the Image from the given config.

func (*ImageClient) Create

func (c *ImageClient) Create() *ImageCreate

Create returns a builder for creating a Image entity.

func (*ImageClient) CreateBulk

func (c *ImageClient) CreateBulk(builders ...*ImageCreate) *ImageCreateBulk

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

func (*ImageClient) Delete

func (c *ImageClient) Delete() *ImageDelete

Delete returns a delete builder for Image.

func (*ImageClient) DeleteOne

func (c *ImageClient) DeleteOne(i *Image) *ImageDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*ImageClient) DeleteOneID

func (c *ImageClient) DeleteOneID(id int) *ImageDeleteOne

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

func (*ImageClient) Get

func (c *ImageClient) Get(ctx context.Context, id int) (*Image, error)

Get returns a Image entity by its id.

func (*ImageClient) GetX

func (c *ImageClient) GetX(ctx context.Context, id int) *Image

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

func (*ImageClient) Hooks

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

Hooks returns the client hooks.

func (*ImageClient) Intercept

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

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

func (*ImageClient) Interceptors

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

Interceptors returns the client interceptors.

func (*ImageClient) MapCreateBulk

func (c *ImageClient) MapCreateBulk(slice any, setFunc func(*ImageCreate, int)) *ImageCreateBulk

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 (*ImageClient) Query

func (c *ImageClient) Query() *ImageQuery

Query returns a query builder for Image.

func (*ImageClient) QueryDirectory

func (c *ImageClient) QueryDirectory(i *Image) *DirectoryQuery

QueryDirectory queries the directory edge of a Image.

func (*ImageClient) Update

func (c *ImageClient) Update() *ImageUpdate

Update returns an update builder for Image.

func (*ImageClient) UpdateOne

func (c *ImageClient) UpdateOne(i *Image) *ImageUpdateOne

UpdateOne returns an update builder for the given entity.

func (*ImageClient) UpdateOneID

func (c *ImageClient) UpdateOneID(id int) *ImageUpdateOne

UpdateOneID returns an update builder for the given id.

func (*ImageClient) Use

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

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

type ImageCreate

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

ImageCreate is the builder for creating a Image entity.

func (*ImageCreate) Exec

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

Exec executes the query.

func (*ImageCreate) ExecX

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

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

func (*ImageCreate) Mutation

func (ic *ImageCreate) Mutation() *ImageMutation

Mutation returns the ImageMutation object of the builder.

func (*ImageCreate) Save

func (ic *ImageCreate) Save(ctx context.Context) (*Image, error)

Save creates the Image in the database.

func (*ImageCreate) SaveX

func (ic *ImageCreate) SaveX(ctx context.Context) *Image

SaveX calls Save and panics if Save returns an error.

func (*ImageCreate) SetCreateTime

func (ic *ImageCreate) SetCreateTime(t time.Time) *ImageCreate

SetCreateTime sets the "create_time" field.

func (*ImageCreate) SetDirectory

func (ic *ImageCreate) SetDirectory(d *Directory) *ImageCreate

SetDirectory sets the "directory" edge to the Directory entity.

func (*ImageCreate) SetDirectoryID

func (ic *ImageCreate) SetDirectoryID(id int) *ImageCreate

SetDirectoryID sets the "directory" edge to the Directory entity by ID.

func (*ImageCreate) SetModTime

func (ic *ImageCreate) SetModTime(t time.Time) *ImageCreate

SetModTime sets the "mod_time" field.

func (*ImageCreate) SetName

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

SetName sets the "name" field.

func (*ImageCreate) SetPath

func (ic *ImageCreate) SetPath(s string) *ImageCreate

SetPath sets the "path" field.

func (*ImageCreate) SetSize

func (ic *ImageCreate) SetSize(i int64) *ImageCreate

SetSize sets the "size" field.

type ImageCreateBulk

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

ImageCreateBulk is the builder for creating many Image entities in bulk.

func (*ImageCreateBulk) Exec

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

Exec executes the query.

func (*ImageCreateBulk) ExecX

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

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

func (*ImageCreateBulk) Save

func (icb *ImageCreateBulk) Save(ctx context.Context) ([]*Image, error)

Save creates the Image entities in the database.

func (*ImageCreateBulk) SaveX

func (icb *ImageCreateBulk) SaveX(ctx context.Context) []*Image

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

type ImageDelete

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

ImageDelete is the builder for deleting a Image entity.

func (*ImageDelete) Exec

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

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

func (*ImageDelete) ExecX

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

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

func (*ImageDelete) Where

func (id *ImageDelete) Where(ps ...predicate.Image) *ImageDelete

Where appends a list predicates to the ImageDelete builder.

type ImageDeleteOne

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

ImageDeleteOne is the builder for deleting a single Image entity.

func (*ImageDeleteOne) Exec

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

Exec executes the deletion query.

func (*ImageDeleteOne) ExecX

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

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

func (*ImageDeleteOne) Where

func (ido *ImageDeleteOne) Where(ps ...predicate.Image) *ImageDeleteOne

Where appends a list predicates to the ImageDelete builder.

type ImageEdges

type ImageEdges struct {
	// Directory holds the value of the directory edge.
	Directory *Directory `json:"directory,omitempty"`
	// contains filtered or unexported fields
}

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

func (ImageEdges) DirectoryOrErr

func (e ImageEdges) DirectoryOrErr() (*Directory, error)

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

type ImageGroupBy

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

ImageGroupBy is the group-by builder for Image entities.

func (*ImageGroupBy) Aggregate

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

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

func (*ImageGroupBy) Bool

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

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

func (*ImageGroupBy) BoolX

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

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

func (*ImageGroupBy) Bools

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

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

func (*ImageGroupBy) BoolsX

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

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

func (*ImageGroupBy) Float64

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

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

func (*ImageGroupBy) Float64X

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

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

func (*ImageGroupBy) Float64s

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

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

func (*ImageGroupBy) Float64sX

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

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

func (*ImageGroupBy) Int

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

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

func (*ImageGroupBy) IntX

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

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

func (*ImageGroupBy) Ints

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

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

func (*ImageGroupBy) IntsX

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

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

func (*ImageGroupBy) Scan

func (igb *ImageGroupBy) Scan(ctx context.Context, v any) error

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

func (*ImageGroupBy) ScanX

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

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

func (*ImageGroupBy) String

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

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

func (*ImageGroupBy) StringX

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

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

func (*ImageGroupBy) Strings

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

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

func (*ImageGroupBy) StringsX

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

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

type ImageMutation

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

ImageMutation represents an operation that mutates the Image nodes in the graph.

func (*ImageMutation) AddField

func (m *ImageMutation) 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 (*ImageMutation) AddSize

func (m *ImageMutation) AddSize(i int64)

AddSize adds i to the "size" field.

func (*ImageMutation) AddedEdges

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

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

func (*ImageMutation) AddedField

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

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

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

func (*ImageMutation) AddedIDs

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

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

func (*ImageMutation) AddedSize

func (m *ImageMutation) AddedSize() (r int64, exists bool)

AddedSize returns the value that was added to the "size" field in this mutation.

func (*ImageMutation) ClearDirectory

func (m *ImageMutation) ClearDirectory()

ClearDirectory clears the "directory" edge to the Directory entity.

func (*ImageMutation) ClearEdge

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

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

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

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

func (*ImageMutation) ClearedFields

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

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

func (ImageMutation) Client

func (m ImageMutation) 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 (*ImageMutation) CreateTime

func (m *ImageMutation) CreateTime() (r time.Time, exists bool)

CreateTime returns the value of the "create_time" field in the mutation.

func (*ImageMutation) DirectoryCleared

func (m *ImageMutation) DirectoryCleared() bool

DirectoryCleared reports if the "directory" edge to the Directory entity was cleared.

func (*ImageMutation) DirectoryID

func (m *ImageMutation) DirectoryID() (id int, exists bool)

DirectoryID returns the "directory" edge ID in the mutation.

func (*ImageMutation) DirectoryIDs

func (m *ImageMutation) DirectoryIDs() (ids []int)

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

func (*ImageMutation) EdgeCleared

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

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

func (*ImageMutation) Field

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

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

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

func (*ImageMutation) Fields

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

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

func (m *ImageMutation) 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 (*ImageMutation) ModTime

func (m *ImageMutation) ModTime() (r time.Time, exists bool)

ModTime returns the value of the "mod_time" field in the mutation.

func (*ImageMutation) Name

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

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

func (*ImageMutation) OldCreateTime

func (m *ImageMutation) OldCreateTime(ctx context.Context) (v time.Time, err error)

OldCreateTime returns the old "create_time" field's value of the Image entity. If the Image 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 (*ImageMutation) OldField

func (m *ImageMutation) 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 (*ImageMutation) OldModTime

func (m *ImageMutation) OldModTime(ctx context.Context) (v time.Time, err error)

OldModTime returns the old "mod_time" field's value of the Image entity. If the Image 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 (*ImageMutation) OldName

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

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

func (m *ImageMutation) OldPath(ctx context.Context) (v string, err error)

OldPath returns the old "path" field's value of the Image entity. If the Image 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 (*ImageMutation) OldSize

func (m *ImageMutation) OldSize(ctx context.Context) (v int64, err error)

OldSize returns the old "size" field's value of the Image entity. If the Image 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 (*ImageMutation) Op

func (m *ImageMutation) Op() Op

Op returns the operation name.

func (*ImageMutation) Path

func (m *ImageMutation) Path() (r string, exists bool)

Path returns the value of the "path" field in the mutation.

func (*ImageMutation) RemovedEdges

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

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

func (*ImageMutation) RemovedIDs

func (m *ImageMutation) 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 (*ImageMutation) ResetCreateTime

func (m *ImageMutation) ResetCreateTime()

ResetCreateTime resets all changes to the "create_time" field.

func (*ImageMutation) ResetDirectory

func (m *ImageMutation) ResetDirectory()

ResetDirectory resets all changes to the "directory" edge.

func (*ImageMutation) ResetEdge

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

func (m *ImageMutation) 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 (*ImageMutation) ResetModTime

func (m *ImageMutation) ResetModTime()

ResetModTime resets all changes to the "mod_time" field.

func (*ImageMutation) ResetName

func (m *ImageMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*ImageMutation) ResetPath

func (m *ImageMutation) ResetPath()

ResetPath resets all changes to the "path" field.

func (*ImageMutation) ResetSize

func (m *ImageMutation) ResetSize()

ResetSize resets all changes to the "size" field.

func (*ImageMutation) SetCreateTime

func (m *ImageMutation) SetCreateTime(t time.Time)

SetCreateTime sets the "create_time" field.

func (*ImageMutation) SetDirectoryID

func (m *ImageMutation) SetDirectoryID(id int)

SetDirectoryID sets the "directory" edge to the Directory entity by id.

func (*ImageMutation) SetField

func (m *ImageMutation) 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 (*ImageMutation) SetModTime

func (m *ImageMutation) SetModTime(t time.Time)

SetModTime sets the "mod_time" field.

func (*ImageMutation) SetName

func (m *ImageMutation) SetName(s string)

SetName sets the "name" field.

func (*ImageMutation) SetOp

func (m *ImageMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*ImageMutation) SetPath

func (m *ImageMutation) SetPath(s string)

SetPath sets the "path" field.

func (*ImageMutation) SetSize

func (m *ImageMutation) SetSize(i int64)

SetSize sets the "size" field.

func (*ImageMutation) Size

func (m *ImageMutation) Size() (r int64, exists bool)

Size returns the value of the "size" field in the mutation.

func (ImageMutation) Tx

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

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

func (*ImageMutation) Type

func (m *ImageMutation) Type() string

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

func (*ImageMutation) Where

func (m *ImageMutation) Where(ps ...predicate.Image)

Where appends a list predicates to the ImageMutation builder.

func (*ImageMutation) WhereP

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

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

type ImageQuery

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

ImageQuery is the builder for querying Image entities.

func (*ImageQuery) Aggregate

func (iq *ImageQuery) Aggregate(fns ...AggregateFunc) *ImageSelect

Aggregate returns a ImageSelect configured with the given aggregations.

func (*ImageQuery) All

func (iq *ImageQuery) All(ctx context.Context) ([]*Image, error)

All executes the query and returns a list of Images.

func (*ImageQuery) AllX

func (iq *ImageQuery) AllX(ctx context.Context) []*Image

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

func (*ImageQuery) Clone

func (iq *ImageQuery) Clone() *ImageQuery

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

func (*ImageQuery) Count

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

Count returns the count of the given query.

func (*ImageQuery) CountX

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

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

func (*ImageQuery) Exist

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

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

func (*ImageQuery) ExistX

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

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

func (*ImageQuery) First

func (iq *ImageQuery) First(ctx context.Context) (*Image, error)

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

func (*ImageQuery) FirstID

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

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

func (*ImageQuery) FirstIDX

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

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

func (*ImageQuery) FirstX

func (iq *ImageQuery) FirstX(ctx context.Context) *Image

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

func (*ImageQuery) GroupBy

func (iq *ImageQuery) GroupBy(field string, fields ...string) *ImageGroupBy

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

client.Image.Query().
	GroupBy(image.FieldPath).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*ImageQuery) IDs

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

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

func (*ImageQuery) IDsX

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

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

func (*ImageQuery) Limit

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

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

func (*ImageQuery) Offset

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

Offset to start from.

func (*ImageQuery) Only

func (iq *ImageQuery) Only(ctx context.Context) (*Image, error)

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

func (*ImageQuery) OnlyID

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

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

func (*ImageQuery) OnlyIDX

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

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

func (*ImageQuery) OnlyX

func (iq *ImageQuery) OnlyX(ctx context.Context) *Image

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

func (*ImageQuery) Order

func (iq *ImageQuery) Order(o ...image.OrderOption) *ImageQuery

Order specifies how the records should be ordered.

func (*ImageQuery) QueryDirectory

func (iq *ImageQuery) QueryDirectory() *DirectoryQuery

QueryDirectory chains the current query on the "directory" edge.

func (*ImageQuery) Select

func (iq *ImageQuery) Select(fields ...string) *ImageSelect

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

client.Image.Query().
	Select(image.FieldPath).
	Scan(ctx, &v)

func (*ImageQuery) Unique

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

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

func (iq *ImageQuery) Where(ps ...predicate.Image) *ImageQuery

Where adds a new predicate for the ImageQuery builder.

func (*ImageQuery) WithDirectory

func (iq *ImageQuery) WithDirectory(opts ...func(*DirectoryQuery)) *ImageQuery

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

type ImageSelect

type ImageSelect struct {
	*ImageQuery
	// contains filtered or unexported fields
}

ImageSelect is the builder for selecting fields of Image entities.

func (*ImageSelect) Aggregate

func (is *ImageSelect) Aggregate(fns ...AggregateFunc) *ImageSelect

Aggregate adds the given aggregation functions to the selector query.

func (*ImageSelect) Bool

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

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

func (*ImageSelect) BoolX

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

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

func (*ImageSelect) Bools

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

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

func (*ImageSelect) BoolsX

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

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

func (*ImageSelect) Float64

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

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

func (*ImageSelect) Float64X

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

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

func (*ImageSelect) Float64s

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

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

func (*ImageSelect) Float64sX

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

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

func (*ImageSelect) Int

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

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

func (*ImageSelect) IntX

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

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

func (*ImageSelect) Ints

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

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

func (*ImageSelect) IntsX

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

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

func (*ImageSelect) Scan

func (is *ImageSelect) Scan(ctx context.Context, v any) error

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

func (*ImageSelect) ScanX

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

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

func (*ImageSelect) String

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

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

func (*ImageSelect) StringX

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

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

func (*ImageSelect) Strings

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

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

func (*ImageSelect) StringsX

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

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

type ImageUpdate

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

ImageUpdate is the builder for updating Image entities.

func (*ImageUpdate) AddSize

func (iu *ImageUpdate) AddSize(i int64) *ImageUpdate

AddSize adds i to the "size" field.

func (*ImageUpdate) ClearDirectory

func (iu *ImageUpdate) ClearDirectory() *ImageUpdate

ClearDirectory clears the "directory" edge to the Directory entity.

func (*ImageUpdate) Exec

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

Exec executes the query.

func (*ImageUpdate) ExecX

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

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

func (*ImageUpdate) Mutation

func (iu *ImageUpdate) Mutation() *ImageMutation

Mutation returns the ImageMutation object of the builder.

func (*ImageUpdate) Save

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

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

func (*ImageUpdate) SaveX

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

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

func (*ImageUpdate) SetCreateTime

func (iu *ImageUpdate) SetCreateTime(t time.Time) *ImageUpdate

SetCreateTime sets the "create_time" field.

func (*ImageUpdate) SetDirectory

func (iu *ImageUpdate) SetDirectory(d *Directory) *ImageUpdate

SetDirectory sets the "directory" edge to the Directory entity.

func (*ImageUpdate) SetDirectoryID

func (iu *ImageUpdate) SetDirectoryID(id int) *ImageUpdate

SetDirectoryID sets the "directory" edge to the Directory entity by ID.

func (*ImageUpdate) SetModTime

func (iu *ImageUpdate) SetModTime(t time.Time) *ImageUpdate

SetModTime sets the "mod_time" field.

func (*ImageUpdate) SetName

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

SetName sets the "name" field.

func (*ImageUpdate) SetNillableCreateTime

func (iu *ImageUpdate) SetNillableCreateTime(t *time.Time) *ImageUpdate

SetNillableCreateTime sets the "create_time" field if the given value is not nil.

func (*ImageUpdate) SetNillableModTime

func (iu *ImageUpdate) SetNillableModTime(t *time.Time) *ImageUpdate

SetNillableModTime sets the "mod_time" field if the given value is not nil.

func (*ImageUpdate) SetNillableName

func (iu *ImageUpdate) SetNillableName(s *string) *ImageUpdate

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

func (*ImageUpdate) SetNillablePath

func (iu *ImageUpdate) SetNillablePath(s *string) *ImageUpdate

SetNillablePath sets the "path" field if the given value is not nil.

func (*ImageUpdate) SetNillableSize

func (iu *ImageUpdate) SetNillableSize(i *int64) *ImageUpdate

SetNillableSize sets the "size" field if the given value is not nil.

func (*ImageUpdate) SetPath

func (iu *ImageUpdate) SetPath(s string) *ImageUpdate

SetPath sets the "path" field.

func (*ImageUpdate) SetSize

func (iu *ImageUpdate) SetSize(i int64) *ImageUpdate

SetSize sets the "size" field.

func (*ImageUpdate) Where

func (iu *ImageUpdate) Where(ps ...predicate.Image) *ImageUpdate

Where appends a list predicates to the ImageUpdate builder.

type ImageUpdateOne

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

ImageUpdateOne is the builder for updating a single Image entity.

func (*ImageUpdateOne) AddSize

func (iuo *ImageUpdateOne) AddSize(i int64) *ImageUpdateOne

AddSize adds i to the "size" field.

func (*ImageUpdateOne) ClearDirectory

func (iuo *ImageUpdateOne) ClearDirectory() *ImageUpdateOne

ClearDirectory clears the "directory" edge to the Directory entity.

func (*ImageUpdateOne) Exec

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

Exec executes the query on the entity.

func (*ImageUpdateOne) ExecX

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

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

func (*ImageUpdateOne) Mutation

func (iuo *ImageUpdateOne) Mutation() *ImageMutation

Mutation returns the ImageMutation object of the builder.

func (*ImageUpdateOne) Save

func (iuo *ImageUpdateOne) Save(ctx context.Context) (*Image, error)

Save executes the query and returns the updated Image entity.

func (*ImageUpdateOne) SaveX

func (iuo *ImageUpdateOne) SaveX(ctx context.Context) *Image

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

func (*ImageUpdateOne) Select

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

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

func (*ImageUpdateOne) SetCreateTime

func (iuo *ImageUpdateOne) SetCreateTime(t time.Time) *ImageUpdateOne

SetCreateTime sets the "create_time" field.

func (*ImageUpdateOne) SetDirectory

func (iuo *ImageUpdateOne) SetDirectory(d *Directory) *ImageUpdateOne

SetDirectory sets the "directory" edge to the Directory entity.

func (*ImageUpdateOne) SetDirectoryID

func (iuo *ImageUpdateOne) SetDirectoryID(id int) *ImageUpdateOne

SetDirectoryID sets the "directory" edge to the Directory entity by ID.

func (*ImageUpdateOne) SetModTime

func (iuo *ImageUpdateOne) SetModTime(t time.Time) *ImageUpdateOne

SetModTime sets the "mod_time" field.

func (*ImageUpdateOne) SetName

func (iuo *ImageUpdateOne) SetName(s string) *ImageUpdateOne

SetName sets the "name" field.

func (*ImageUpdateOne) SetNillableCreateTime

func (iuo *ImageUpdateOne) SetNillableCreateTime(t *time.Time) *ImageUpdateOne

SetNillableCreateTime sets the "create_time" field if the given value is not nil.

func (*ImageUpdateOne) SetNillableModTime

func (iuo *ImageUpdateOne) SetNillableModTime(t *time.Time) *ImageUpdateOne

SetNillableModTime sets the "mod_time" field if the given value is not nil.

func (*ImageUpdateOne) SetNillableName

func (iuo *ImageUpdateOne) SetNillableName(s *string) *ImageUpdateOne

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

func (*ImageUpdateOne) SetNillablePath

func (iuo *ImageUpdateOne) SetNillablePath(s *string) *ImageUpdateOne

SetNillablePath sets the "path" field if the given value is not nil.

func (*ImageUpdateOne) SetNillableSize

func (iuo *ImageUpdateOne) SetNillableSize(i *int64) *ImageUpdateOne

SetNillableSize sets the "size" field if the given value is not nil.

func (*ImageUpdateOne) SetPath

func (iuo *ImageUpdateOne) SetPath(s string) *ImageUpdateOne

SetPath sets the "path" field.

func (*ImageUpdateOne) SetSize

func (iuo *ImageUpdateOne) SetSize(i int64) *ImageUpdateOne

SetSize sets the "size" field.

func (*ImageUpdateOne) Where

func (iuo *ImageUpdateOne) Where(ps ...predicate.Image) *ImageUpdateOne

Where appends a list predicates to the ImageUpdate builder.

type Images

type Images []*Image

Images is a parsable slice of Image.

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 MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

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

type NotFoundError

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

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

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

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

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

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

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

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

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

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

type Policy

type Policy = ent.Policy

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

type Querier

type Querier = ent.Querier

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

type QuerierFunc

type QuerierFunc = ent.QuerierFunc

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

type Query

type Query = ent.Query

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

type QueryContext

type QueryContext = ent.QueryContext

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

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

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

type Rollbacker

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

Rollbacker is the interface that wraps the Rollback method.

type 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 {

	// Directory is the client for interacting with the Directory builders.
	Directory *DirectoryClient
	// Image is the client for interacting with the Image builders.
	Image *ImageClient
	// 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