ent

package
v0.0.0-...-c111925 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 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.
	TypeSite  = "Site"
	TypeUser  = "User"
	TypeVisit = "Visit"
)

Variables

This section is empty.

Functions

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func IsValidationError

func IsValidationError(err error) bool

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

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

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

NewContext returns a new context with the given Client attached.

func NewTxContext

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

NewTxContext returns a new context with the given Tx attached.

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

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

func As

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

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

func Count

func Count() AggregateFunc

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

func Max

func Max(field string) AggregateFunc

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

func Mean

func Mean(field string) AggregateFunc

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

func Min

func Min(field string) AggregateFunc

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

func Sum

func Sum(field string) AggregateFunc

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

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Site is the client for interacting with the Site builders.
	Site *SiteClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// Visit is the client for interacting with the Visit builders.
	Visit *VisitClient
	// 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().
	Site.
	Query().
	Count(ctx)

func (*Client) Tx

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

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

func (*Client) Use

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

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

type CommitFunc

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

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

func (CommitFunc) Commit

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

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

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

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

type Committer

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

Committer is the interface that wraps the Commit method.

type ConstraintError

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

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

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

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

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

func Asc

func Asc(fields ...string) OrderFunc

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) OrderFunc

Desc applies the given fields in DESC order.

type Policy

type Policy = ent.Policy

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

type Query

type Query = ent.Query

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

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

hook := func(next ent.Rollbacker) ent.Rollbacker {
	return ent.RollbackFunc(func(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 Site

type Site struct {

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

Site is the model entity for the Site schema.

func (*Site) QueryUsers

func (s *Site) QueryUsers() *UserQuery

QueryUsers queries the "users" edge of the Site entity.

func (*Site) QueryVisits

func (s *Site) QueryVisits() *VisitQuery

QueryVisits queries the "visits" edge of the Site entity.

func (*Site) String

func (s *Site) String() string

String implements the fmt.Stringer.

func (*Site) Unwrap

func (s *Site) Unwrap() *Site

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

func (s *Site) Update() *SiteUpdateOne

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

type SiteClient

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

SiteClient is a client for the Site schema.

func NewSiteClient

func NewSiteClient(c config) *SiteClient

NewSiteClient returns a client for the Site from the given config.

func (*SiteClient) Create

func (c *SiteClient) Create() *SiteCreate

Create returns a builder for creating a Site entity.

func (*SiteClient) CreateBulk

func (c *SiteClient) CreateBulk(builders ...*SiteCreate) *SiteCreateBulk

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

func (*SiteClient) Delete

func (c *SiteClient) Delete() *SiteDelete

Delete returns a delete builder for Site.

func (*SiteClient) DeleteOne

func (c *SiteClient) DeleteOne(s *Site) *SiteDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*SiteClient) DeleteOneID

func (c *SiteClient) DeleteOneID(id int) *SiteDeleteOne

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

func (*SiteClient) Get

func (c *SiteClient) Get(ctx context.Context, id int) (*Site, error)

Get returns a Site entity by its id.

func (*SiteClient) GetX

func (c *SiteClient) GetX(ctx context.Context, id int) *Site

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

func (*SiteClient) Hooks

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

Hooks returns the client hooks.

func (*SiteClient) Query

func (c *SiteClient) Query() *SiteQuery

Query returns a query builder for Site.

func (*SiteClient) QueryUsers

func (c *SiteClient) QueryUsers(s *Site) *UserQuery

QueryUsers queries the users edge of a Site.

func (*SiteClient) QueryVisits

func (c *SiteClient) QueryVisits(s *Site) *VisitQuery

QueryVisits queries the visits edge of a Site.

func (*SiteClient) Update

func (c *SiteClient) Update() *SiteUpdate

Update returns an update builder for Site.

func (*SiteClient) UpdateOne

func (c *SiteClient) UpdateOne(s *Site) *SiteUpdateOne

UpdateOne returns an update builder for the given entity.

func (*SiteClient) UpdateOneID

func (c *SiteClient) UpdateOneID(id int) *SiteUpdateOne

UpdateOneID returns an update builder for the given id.

func (*SiteClient) Use

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

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

type SiteCreate

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

SiteCreate is the builder for creating a Site entity.

func (*SiteCreate) AddUserIDs

func (sc *SiteCreate) AddUserIDs(ids ...int) *SiteCreate

AddUserIDs adds the "users" edge to the User entity by IDs.

func (*SiteCreate) AddUsers

func (sc *SiteCreate) AddUsers(u ...*User) *SiteCreate

AddUsers adds the "users" edges to the User entity.

func (*SiteCreate) AddVisitIDs

func (sc *SiteCreate) AddVisitIDs(ids ...int) *SiteCreate

AddVisitIDs adds the "visits" edge to the Visit entity by IDs.

func (*SiteCreate) AddVisits

func (sc *SiteCreate) AddVisits(v ...*Visit) *SiteCreate

AddVisits adds the "visits" edges to the Visit entity.

func (*SiteCreate) Exec

func (sc *SiteCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*SiteCreate) ExecX

func (sc *SiteCreate) ExecX(ctx context.Context)

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

func (*SiteCreate) Mutation

func (sc *SiteCreate) Mutation() *SiteMutation

Mutation returns the SiteMutation object of the builder.

func (*SiteCreate) Save

func (sc *SiteCreate) Save(ctx context.Context) (*Site, error)

Save creates the Site in the database.

func (*SiteCreate) SaveX

func (sc *SiteCreate) SaveX(ctx context.Context) *Site

SaveX calls Save and panics if Save returns an error.

func (*SiteCreate) SetDomain

func (sc *SiteCreate) SetDomain(s string) *SiteCreate

SetDomain sets the "domain" field.

func (*SiteCreate) SetFavicon

func (sc *SiteCreate) SetFavicon(s string) *SiteCreate

SetFavicon sets the "favicon" field.

func (*SiteCreate) SetNillableFavicon

func (sc *SiteCreate) SetNillableFavicon(s *string) *SiteCreate

SetNillableFavicon sets the "favicon" field if the given value is not nil.

type SiteCreateBulk

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

SiteCreateBulk is the builder for creating many Site entities in bulk.

func (*SiteCreateBulk) Exec

func (scb *SiteCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*SiteCreateBulk) ExecX

func (scb *SiteCreateBulk) ExecX(ctx context.Context)

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

func (*SiteCreateBulk) Save

func (scb *SiteCreateBulk) Save(ctx context.Context) ([]*Site, error)

Save creates the Site entities in the database.

func (*SiteCreateBulk) SaveX

func (scb *SiteCreateBulk) SaveX(ctx context.Context) []*Site

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

type SiteDelete

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

SiteDelete is the builder for deleting a Site entity.

func (*SiteDelete) Exec

func (sd *SiteDelete) Exec(ctx context.Context) (int, error)

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

func (*SiteDelete) ExecX

func (sd *SiteDelete) ExecX(ctx context.Context) int

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

func (*SiteDelete) Where

func (sd *SiteDelete) Where(ps ...predicate.Site) *SiteDelete

Where appends a list predicates to the SiteDelete builder.

type SiteDeleteOne

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

SiteDeleteOne is the builder for deleting a single Site entity.

func (*SiteDeleteOne) Exec

func (sdo *SiteDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*SiteDeleteOne) ExecX

func (sdo *SiteDeleteOne) ExecX(ctx context.Context)

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

type SiteEdges

type SiteEdges struct {
	// Users holds the value of the users edge.
	Users []*User `json:"users,omitempty"`
	// Visits holds the value of the visits edge.
	Visits []*Visit `json:"visits,omitempty"`
	// contains filtered or unexported fields
}

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

func (SiteEdges) UsersOrErr

func (e SiteEdges) UsersOrErr() ([]*User, error)

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

func (SiteEdges) VisitsOrErr

func (e SiteEdges) VisitsOrErr() ([]*Visit, error)

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

type SiteGroupBy

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

SiteGroupBy is the group-by builder for Site entities.

func (*SiteGroupBy) Aggregate

func (sgb *SiteGroupBy) Aggregate(fns ...AggregateFunc) *SiteGroupBy

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

func (*SiteGroupBy) Bool

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

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

func (*SiteGroupBy) BoolX

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

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

func (*SiteGroupBy) Bools

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

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

func (*SiteGroupBy) BoolsX

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

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

func (*SiteGroupBy) Float64

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

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

func (*SiteGroupBy) Float64X

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

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

func (*SiteGroupBy) Float64s

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

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

func (*SiteGroupBy) Float64sX

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

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

func (*SiteGroupBy) Int

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

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

func (*SiteGroupBy) IntX

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

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

func (*SiteGroupBy) Ints

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

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

func (*SiteGroupBy) IntsX

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

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

func (*SiteGroupBy) Scan

func (sgb *SiteGroupBy) Scan(ctx context.Context, v any) error

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

func (*SiteGroupBy) ScanX

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

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

func (*SiteGroupBy) String

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

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

func (*SiteGroupBy) StringX

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

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

func (*SiteGroupBy) Strings

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

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

func (*SiteGroupBy) StringsX

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

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

type SiteMutation

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

SiteMutation represents an operation that mutates the Site nodes in the graph.

func (*SiteMutation) AddField

func (m *SiteMutation) 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 (*SiteMutation) AddUserIDs

func (m *SiteMutation) AddUserIDs(ids ...int)

AddUserIDs adds the "users" edge to the User entity by ids.

func (*SiteMutation) AddVisitIDs

func (m *SiteMutation) AddVisitIDs(ids ...int)

AddVisitIDs adds the "visits" edge to the Visit entity by ids.

func (*SiteMutation) AddedEdges

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

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

func (*SiteMutation) AddedField

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

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

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

func (*SiteMutation) AddedIDs

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

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

func (*SiteMutation) ClearEdge

func (m *SiteMutation) 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 (*SiteMutation) ClearFavicon

func (m *SiteMutation) ClearFavicon()

ClearFavicon clears the value of the "favicon" field.

func (*SiteMutation) ClearField

func (m *SiteMutation) 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 (*SiteMutation) ClearUsers

func (m *SiteMutation) ClearUsers()

ClearUsers clears the "users" edge to the User entity.

func (*SiteMutation) ClearVisits

func (m *SiteMutation) ClearVisits()

ClearVisits clears the "visits" edge to the Visit entity.

func (*SiteMutation) ClearedEdges

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

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

func (*SiteMutation) ClearedFields

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

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

func (SiteMutation) Client

func (m SiteMutation) 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 (*SiteMutation) Domain

func (m *SiteMutation) Domain() (r string, exists bool)

Domain returns the value of the "domain" field in the mutation.

func (*SiteMutation) EdgeCleared

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

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

func (*SiteMutation) Favicon

func (m *SiteMutation) Favicon() (r string, exists bool)

Favicon returns the value of the "favicon" field in the mutation.

func (*SiteMutation) FaviconCleared

func (m *SiteMutation) FaviconCleared() bool

FaviconCleared returns if the "favicon" field was cleared in this mutation.

func (*SiteMutation) Field

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

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

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

func (*SiteMutation) Fields

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

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

func (m *SiteMutation) 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 (*SiteMutation) OldDomain

func (m *SiteMutation) OldDomain(ctx context.Context) (v string, err error)

OldDomain returns the old "domain" field's value of the Site entity. If the Site 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 (*SiteMutation) OldFavicon

func (m *SiteMutation) OldFavicon(ctx context.Context) (v string, err error)

OldFavicon returns the old "favicon" field's value of the Site entity. If the Site 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 (*SiteMutation) OldField

func (m *SiteMutation) 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 (*SiteMutation) Op

func (m *SiteMutation) Op() Op

Op returns the operation name.

func (*SiteMutation) RemoveUserIDs

func (m *SiteMutation) RemoveUserIDs(ids ...int)

RemoveUserIDs removes the "users" edge to the User entity by IDs.

func (*SiteMutation) RemoveVisitIDs

func (m *SiteMutation) RemoveVisitIDs(ids ...int)

RemoveVisitIDs removes the "visits" edge to the Visit entity by IDs.

func (*SiteMutation) RemovedEdges

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

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

func (*SiteMutation) RemovedIDs

func (m *SiteMutation) 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 (*SiteMutation) RemovedUsersIDs

func (m *SiteMutation) RemovedUsersIDs() (ids []int)

RemovedUsers returns the removed IDs of the "users" edge to the User entity.

func (*SiteMutation) RemovedVisitsIDs

func (m *SiteMutation) RemovedVisitsIDs() (ids []int)

RemovedVisits returns the removed IDs of the "visits" edge to the Visit entity.

func (*SiteMutation) ResetDomain

func (m *SiteMutation) ResetDomain()

ResetDomain resets all changes to the "domain" field.

func (*SiteMutation) ResetEdge

func (m *SiteMutation) 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 (*SiteMutation) ResetFavicon

func (m *SiteMutation) ResetFavicon()

ResetFavicon resets all changes to the "favicon" field.

func (*SiteMutation) ResetField

func (m *SiteMutation) 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 (*SiteMutation) ResetUsers

func (m *SiteMutation) ResetUsers()

ResetUsers resets all changes to the "users" edge.

func (*SiteMutation) ResetVisits

func (m *SiteMutation) ResetVisits()

ResetVisits resets all changes to the "visits" edge.

func (*SiteMutation) SetDomain

func (m *SiteMutation) SetDomain(s string)

SetDomain sets the "domain" field.

func (*SiteMutation) SetFavicon

func (m *SiteMutation) SetFavicon(s string)

SetFavicon sets the "favicon" field.

func (*SiteMutation) SetField

func (m *SiteMutation) 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 (SiteMutation) Tx

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

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

func (*SiteMutation) Type

func (m *SiteMutation) Type() string

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

func (*SiteMutation) UsersCleared

func (m *SiteMutation) UsersCleared() bool

UsersCleared reports if the "users" edge to the User entity was cleared.

func (*SiteMutation) UsersIDs

func (m *SiteMutation) UsersIDs() (ids []int)

UsersIDs returns the "users" edge IDs in the mutation.

func (*SiteMutation) VisitsCleared

func (m *SiteMutation) VisitsCleared() bool

VisitsCleared reports if the "visits" edge to the Visit entity was cleared.

func (*SiteMutation) VisitsIDs

func (m *SiteMutation) VisitsIDs() (ids []int)

VisitsIDs returns the "visits" edge IDs in the mutation.

func (*SiteMutation) Where

func (m *SiteMutation) Where(ps ...predicate.Site)

Where appends a list predicates to the SiteMutation builder.

type SiteQuery

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

SiteQuery is the builder for querying Site entities.

func (*SiteQuery) Aggregate

func (sq *SiteQuery) Aggregate(fns ...AggregateFunc) *SiteSelect

Aggregate returns a SiteSelect configured with the given aggregations.

func (*SiteQuery) All

func (sq *SiteQuery) All(ctx context.Context) ([]*Site, error)

All executes the query and returns a list of Sites.

func (*SiteQuery) AllX

func (sq *SiteQuery) AllX(ctx context.Context) []*Site

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

func (*SiteQuery) Clone

func (sq *SiteQuery) Clone() *SiteQuery

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

func (*SiteQuery) Count

func (sq *SiteQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*SiteQuery) CountX

func (sq *SiteQuery) CountX(ctx context.Context) int

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

func (*SiteQuery) Exist

func (sq *SiteQuery) Exist(ctx context.Context) (bool, error)

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

func (*SiteQuery) ExistX

func (sq *SiteQuery) ExistX(ctx context.Context) bool

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

func (*SiteQuery) First

func (sq *SiteQuery) First(ctx context.Context) (*Site, error)

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

func (*SiteQuery) FirstID

func (sq *SiteQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*SiteQuery) FirstIDX

func (sq *SiteQuery) FirstIDX(ctx context.Context) int

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

func (*SiteQuery) FirstX

func (sq *SiteQuery) FirstX(ctx context.Context) *Site

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

func (*SiteQuery) GroupBy

func (sq *SiteQuery) GroupBy(field string, fields ...string) *SiteGroupBy

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

client.Site.Query().
	GroupBy(site.FieldDomain).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*SiteQuery) IDs

func (sq *SiteQuery) IDs(ctx context.Context) ([]int, error)

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

func (*SiteQuery) IDsX

func (sq *SiteQuery) IDsX(ctx context.Context) []int

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

func (*SiteQuery) Limit

func (sq *SiteQuery) Limit(limit int) *SiteQuery

Limit adds a limit step to the query.

func (*SiteQuery) Offset

func (sq *SiteQuery) Offset(offset int) *SiteQuery

Offset adds an offset step to the query.

func (*SiteQuery) Only

func (sq *SiteQuery) Only(ctx context.Context) (*Site, error)

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

func (*SiteQuery) OnlyID

func (sq *SiteQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*SiteQuery) OnlyIDX

func (sq *SiteQuery) OnlyIDX(ctx context.Context) int

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

func (*SiteQuery) OnlyX

func (sq *SiteQuery) OnlyX(ctx context.Context) *Site

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

func (*SiteQuery) Order

func (sq *SiteQuery) Order(o ...OrderFunc) *SiteQuery

Order adds an order step to the query.

func (*SiteQuery) QueryUsers

func (sq *SiteQuery) QueryUsers() *UserQuery

QueryUsers chains the current query on the "users" edge.

func (*SiteQuery) QueryVisits

func (sq *SiteQuery) QueryVisits() *VisitQuery

QueryVisits chains the current query on the "visits" edge.

func (*SiteQuery) Select

func (sq *SiteQuery) Select(fields ...string) *SiteSelect

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

client.Site.Query().
	Select(site.FieldDomain).
	Scan(ctx, &v)

func (*SiteQuery) Unique

func (sq *SiteQuery) Unique(unique bool) *SiteQuery

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

func (sq *SiteQuery) Where(ps ...predicate.Site) *SiteQuery

Where adds a new predicate for the SiteQuery builder.

func (*SiteQuery) WithUsers

func (sq *SiteQuery) WithUsers(opts ...func(*UserQuery)) *SiteQuery

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

func (*SiteQuery) WithVisits

func (sq *SiteQuery) WithVisits(opts ...func(*VisitQuery)) *SiteQuery

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

type SiteSelect

type SiteSelect struct {
	*SiteQuery
	// contains filtered or unexported fields
}

SiteSelect is the builder for selecting fields of Site entities.

func (*SiteSelect) Aggregate

func (ss *SiteSelect) Aggregate(fns ...AggregateFunc) *SiteSelect

Aggregate adds the given aggregation functions to the selector query.

func (*SiteSelect) Bool

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

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

func (*SiteSelect) BoolX

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

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

func (*SiteSelect) Bools

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

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

func (*SiteSelect) BoolsX

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

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

func (*SiteSelect) Float64

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

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

func (*SiteSelect) Float64X

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

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

func (*SiteSelect) Float64s

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

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

func (*SiteSelect) Float64sX

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

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

func (*SiteSelect) Int

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

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

func (*SiteSelect) IntX

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

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

func (*SiteSelect) Ints

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

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

func (*SiteSelect) IntsX

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

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

func (*SiteSelect) Scan

func (ss *SiteSelect) Scan(ctx context.Context, v any) error

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

func (*SiteSelect) ScanX

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

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

func (*SiteSelect) String

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

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

func (*SiteSelect) StringX

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

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

func (*SiteSelect) Strings

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

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

func (*SiteSelect) StringsX

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

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

type SiteUpdate

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

SiteUpdate is the builder for updating Site entities.

func (*SiteUpdate) AddUserIDs

func (su *SiteUpdate) AddUserIDs(ids ...int) *SiteUpdate

AddUserIDs adds the "users" edge to the User entity by IDs.

func (*SiteUpdate) AddUsers

func (su *SiteUpdate) AddUsers(u ...*User) *SiteUpdate

AddUsers adds the "users" edges to the User entity.

func (*SiteUpdate) AddVisitIDs

func (su *SiteUpdate) AddVisitIDs(ids ...int) *SiteUpdate

AddVisitIDs adds the "visits" edge to the Visit entity by IDs.

func (*SiteUpdate) AddVisits

func (su *SiteUpdate) AddVisits(v ...*Visit) *SiteUpdate

AddVisits adds the "visits" edges to the Visit entity.

func (*SiteUpdate) ClearFavicon

func (su *SiteUpdate) ClearFavicon() *SiteUpdate

ClearFavicon clears the value of the "favicon" field.

func (*SiteUpdate) ClearUsers

func (su *SiteUpdate) ClearUsers() *SiteUpdate

ClearUsers clears all "users" edges to the User entity.

func (*SiteUpdate) ClearVisits

func (su *SiteUpdate) ClearVisits() *SiteUpdate

ClearVisits clears all "visits" edges to the Visit entity.

func (*SiteUpdate) Exec

func (su *SiteUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*SiteUpdate) ExecX

func (su *SiteUpdate) ExecX(ctx context.Context)

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

func (*SiteUpdate) Mutation

func (su *SiteUpdate) Mutation() *SiteMutation

Mutation returns the SiteMutation object of the builder.

func (*SiteUpdate) RemoveUserIDs

func (su *SiteUpdate) RemoveUserIDs(ids ...int) *SiteUpdate

RemoveUserIDs removes the "users" edge to User entities by IDs.

func (*SiteUpdate) RemoveUsers

func (su *SiteUpdate) RemoveUsers(u ...*User) *SiteUpdate

RemoveUsers removes "users" edges to User entities.

func (*SiteUpdate) RemoveVisitIDs

func (su *SiteUpdate) RemoveVisitIDs(ids ...int) *SiteUpdate

RemoveVisitIDs removes the "visits" edge to Visit entities by IDs.

func (*SiteUpdate) RemoveVisits

func (su *SiteUpdate) RemoveVisits(v ...*Visit) *SiteUpdate

RemoveVisits removes "visits" edges to Visit entities.

func (*SiteUpdate) Save

func (su *SiteUpdate) Save(ctx context.Context) (int, error)

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

func (*SiteUpdate) SaveX

func (su *SiteUpdate) SaveX(ctx context.Context) int

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

func (*SiteUpdate) SetDomain

func (su *SiteUpdate) SetDomain(s string) *SiteUpdate

SetDomain sets the "domain" field.

func (*SiteUpdate) SetFavicon

func (su *SiteUpdate) SetFavicon(s string) *SiteUpdate

SetFavicon sets the "favicon" field.

func (*SiteUpdate) SetNillableFavicon

func (su *SiteUpdate) SetNillableFavicon(s *string) *SiteUpdate

SetNillableFavicon sets the "favicon" field if the given value is not nil.

func (*SiteUpdate) Where

func (su *SiteUpdate) Where(ps ...predicate.Site) *SiteUpdate

Where appends a list predicates to the SiteUpdate builder.

type SiteUpdateOne

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

SiteUpdateOne is the builder for updating a single Site entity.

func (*SiteUpdateOne) AddUserIDs

func (suo *SiteUpdateOne) AddUserIDs(ids ...int) *SiteUpdateOne

AddUserIDs adds the "users" edge to the User entity by IDs.

func (*SiteUpdateOne) AddUsers

func (suo *SiteUpdateOne) AddUsers(u ...*User) *SiteUpdateOne

AddUsers adds the "users" edges to the User entity.

func (*SiteUpdateOne) AddVisitIDs

func (suo *SiteUpdateOne) AddVisitIDs(ids ...int) *SiteUpdateOne

AddVisitIDs adds the "visits" edge to the Visit entity by IDs.

func (*SiteUpdateOne) AddVisits

func (suo *SiteUpdateOne) AddVisits(v ...*Visit) *SiteUpdateOne

AddVisits adds the "visits" edges to the Visit entity.

func (*SiteUpdateOne) ClearFavicon

func (suo *SiteUpdateOne) ClearFavicon() *SiteUpdateOne

ClearFavicon clears the value of the "favicon" field.

func (*SiteUpdateOne) ClearUsers

func (suo *SiteUpdateOne) ClearUsers() *SiteUpdateOne

ClearUsers clears all "users" edges to the User entity.

func (*SiteUpdateOne) ClearVisits

func (suo *SiteUpdateOne) ClearVisits() *SiteUpdateOne

ClearVisits clears all "visits" edges to the Visit entity.

func (*SiteUpdateOne) Exec

func (suo *SiteUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*SiteUpdateOne) ExecX

func (suo *SiteUpdateOne) ExecX(ctx context.Context)

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

func (*SiteUpdateOne) Mutation

func (suo *SiteUpdateOne) Mutation() *SiteMutation

Mutation returns the SiteMutation object of the builder.

func (*SiteUpdateOne) RemoveUserIDs

func (suo *SiteUpdateOne) RemoveUserIDs(ids ...int) *SiteUpdateOne

RemoveUserIDs removes the "users" edge to User entities by IDs.

func (*SiteUpdateOne) RemoveUsers

func (suo *SiteUpdateOne) RemoveUsers(u ...*User) *SiteUpdateOne

RemoveUsers removes "users" edges to User entities.

func (*SiteUpdateOne) RemoveVisitIDs

func (suo *SiteUpdateOne) RemoveVisitIDs(ids ...int) *SiteUpdateOne

RemoveVisitIDs removes the "visits" edge to Visit entities by IDs.

func (*SiteUpdateOne) RemoveVisits

func (suo *SiteUpdateOne) RemoveVisits(v ...*Visit) *SiteUpdateOne

RemoveVisits removes "visits" edges to Visit entities.

func (*SiteUpdateOne) Save

func (suo *SiteUpdateOne) Save(ctx context.Context) (*Site, error)

Save executes the query and returns the updated Site entity.

func (*SiteUpdateOne) SaveX

func (suo *SiteUpdateOne) SaveX(ctx context.Context) *Site

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

func (*SiteUpdateOne) Select

func (suo *SiteUpdateOne) Select(field string, fields ...string) *SiteUpdateOne

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

func (*SiteUpdateOne) SetDomain

func (suo *SiteUpdateOne) SetDomain(s string) *SiteUpdateOne

SetDomain sets the "domain" field.

func (*SiteUpdateOne) SetFavicon

func (suo *SiteUpdateOne) SetFavicon(s string) *SiteUpdateOne

SetFavicon sets the "favicon" field.

func (*SiteUpdateOne) SetNillableFavicon

func (suo *SiteUpdateOne) SetNillableFavicon(s *string) *SiteUpdateOne

SetNillableFavicon sets the "favicon" field if the given value is not nil.

type Sites

type Sites []*Site

Sites is a parsable slice of Site.

type Tx

type Tx struct {

	// Site is the client for interacting with the Site builders.
	Site *SiteClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// Visit is the client for interacting with the Visit builders.
	Visit *VisitClient
	// 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 User

type User struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Email holds the value of the "email" field.
	Email string `json:"email,omitempty"`
	// Password holds the value of the "password" field.
	Password []byte `json:"password,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the UserQuery when eager-loading is set.
	Edges UserEdges `json:"edges"`
	// contains filtered or unexported fields
}

User is the model entity for the User schema.

func (*User) QuerySites

func (u *User) QuerySites() *SiteQuery

QuerySites queries the "sites" edge of the User entity.

func (*User) String

func (u *User) String() string

String implements the fmt.Stringer.

func (*User) Unwrap

func (u *User) Unwrap() *User

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

func (u *User) Update() *UserUpdateOne

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

type UserClient

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

UserClient is a client for the User schema.

func NewUserClient

func NewUserClient(c config) *UserClient

NewUserClient returns a client for the User from the given config.

func (*UserClient) Create

func (c *UserClient) Create() *UserCreate

Create returns a builder for creating a User entity.

func (*UserClient) CreateBulk

func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk

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

func (*UserClient) Delete

func (c *UserClient) Delete() *UserDelete

Delete returns a delete builder for User.

func (*UserClient) DeleteOne

func (c *UserClient) DeleteOne(u *User) *UserDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*UserClient) DeleteOneID

func (c *UserClient) DeleteOneID(id int) *UserDeleteOne

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

func (*UserClient) Get

func (c *UserClient) Get(ctx context.Context, id int) (*User, error)

Get returns a User entity by its id.

func (*UserClient) GetX

func (c *UserClient) GetX(ctx context.Context, id int) *User

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

func (*UserClient) Hooks

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

Hooks returns the client hooks.

func (*UserClient) Query

func (c *UserClient) Query() *UserQuery

Query returns a query builder for User.

func (*UserClient) QuerySites

func (c *UserClient) QuerySites(u *User) *SiteQuery

QuerySites queries the sites edge of a User.

func (*UserClient) Update

func (c *UserClient) Update() *UserUpdate

Update returns an update builder for User.

func (*UserClient) UpdateOne

func (c *UserClient) UpdateOne(u *User) *UserUpdateOne

UpdateOne returns an update builder for the given entity.

func (*UserClient) UpdateOneID

func (c *UserClient) UpdateOneID(id int) *UserUpdateOne

UpdateOneID returns an update builder for the given id.

func (*UserClient) Use

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

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

type UserCreate

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

UserCreate is the builder for creating a User entity.

func (*UserCreate) AddSiteIDs

func (uc *UserCreate) AddSiteIDs(ids ...int) *UserCreate

AddSiteIDs adds the "sites" edge to the Site entity by IDs.

func (*UserCreate) AddSites

func (uc *UserCreate) AddSites(s ...*Site) *UserCreate

AddSites adds the "sites" edges to the Site entity.

func (*UserCreate) Exec

func (uc *UserCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserCreate) ExecX

func (uc *UserCreate) ExecX(ctx context.Context)

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

func (*UserCreate) Mutation

func (uc *UserCreate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserCreate) Save

func (uc *UserCreate) Save(ctx context.Context) (*User, error)

Save creates the User in the database.

func (*UserCreate) SaveX

func (uc *UserCreate) SaveX(ctx context.Context) *User

SaveX calls Save and panics if Save returns an error.

func (*UserCreate) SetEmail

func (uc *UserCreate) SetEmail(s string) *UserCreate

SetEmail sets the "email" field.

func (*UserCreate) SetPassword

func (uc *UserCreate) SetPassword(b []byte) *UserCreate

SetPassword sets the "password" field.

type UserCreateBulk

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

UserCreateBulk is the builder for creating many User entities in bulk.

func (*UserCreateBulk) Exec

func (ucb *UserCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*UserCreateBulk) ExecX

func (ucb *UserCreateBulk) ExecX(ctx context.Context)

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

func (*UserCreateBulk) Save

func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error)

Save creates the User entities in the database.

func (*UserCreateBulk) SaveX

func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User

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

type UserDelete

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

UserDelete is the builder for deleting a User entity.

func (*UserDelete) Exec

func (ud *UserDelete) Exec(ctx context.Context) (int, error)

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

func (*UserDelete) ExecX

func (ud *UserDelete) ExecX(ctx context.Context) int

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

func (*UserDelete) Where

func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete

Where appends a list predicates to the UserDelete builder.

type UserDeleteOne

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

UserDeleteOne is the builder for deleting a single User entity.

func (*UserDeleteOne) Exec

func (udo *UserDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*UserDeleteOne) ExecX

func (udo *UserDeleteOne) ExecX(ctx context.Context)

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

type UserEdges

type UserEdges struct {
	// Sites holds the value of the sites edge.
	Sites []*Site `json:"sites,omitempty"`
	// contains filtered or unexported fields
}

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

func (UserEdges) SitesOrErr

func (e UserEdges) SitesOrErr() ([]*Site, error)

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

type UserGroupBy

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

UserGroupBy is the group-by builder for User entities.

func (*UserGroupBy) Aggregate

func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy

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

func (*UserGroupBy) Bool

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

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

func (*UserGroupBy) BoolX

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

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

func (*UserGroupBy) Bools

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

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

func (*UserGroupBy) BoolsX

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

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

func (*UserGroupBy) Float64

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

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

func (*UserGroupBy) Float64X

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

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

func (*UserGroupBy) Float64s

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

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

func (*UserGroupBy) Float64sX

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

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

func (*UserGroupBy) Int

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

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

func (*UserGroupBy) IntX

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

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

func (*UserGroupBy) Ints

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

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

func (*UserGroupBy) IntsX

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

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

func (*UserGroupBy) Scan

func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error

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

func (*UserGroupBy) ScanX

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

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

func (*UserGroupBy) String

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

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

func (*UserGroupBy) StringX

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

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

func (*UserGroupBy) Strings

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

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

func (*UserGroupBy) StringsX

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

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

type UserMutation

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

UserMutation represents an operation that mutates the User nodes in the graph.

func (*UserMutation) AddField

func (m *UserMutation) 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 (*UserMutation) AddSiteIDs

func (m *UserMutation) AddSiteIDs(ids ...int)

AddSiteIDs adds the "sites" edge to the Site entity by ids.

func (*UserMutation) AddedEdges

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

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

func (*UserMutation) AddedField

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

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

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

func (*UserMutation) AddedIDs

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

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

func (*UserMutation) ClearEdge

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

func (m *UserMutation) 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 (*UserMutation) ClearSites

func (m *UserMutation) ClearSites()

ClearSites clears the "sites" edge to the Site entity.

func (*UserMutation) ClearedEdges

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

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

func (*UserMutation) ClearedFields

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

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

func (UserMutation) Client

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

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

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

func (*UserMutation) Email

func (m *UserMutation) Email() (r string, exists bool)

Email returns the value of the "email" field in the mutation.

func (*UserMutation) Field

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

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

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

func (*UserMutation) Fields

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

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

func (m *UserMutation) 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 (*UserMutation) OldEmail

func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error)

OldEmail returns the old "email" field's value of the User entity. If the User 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 (*UserMutation) OldField

func (m *UserMutation) 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 (*UserMutation) OldPassword

func (m *UserMutation) OldPassword(ctx context.Context) (v []byte, err error)

OldPassword returns the old "password" field's value of the User entity. If the User 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 (*UserMutation) Op

func (m *UserMutation) Op() Op

Op returns the operation name.

func (*UserMutation) Password

func (m *UserMutation) Password() (r []byte, exists bool)

Password returns the value of the "password" field in the mutation.

func (*UserMutation) RemoveSiteIDs

func (m *UserMutation) RemoveSiteIDs(ids ...int)

RemoveSiteIDs removes the "sites" edge to the Site entity by IDs.

func (*UserMutation) RemovedEdges

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

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

func (*UserMutation) RemovedIDs

func (m *UserMutation) 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 (*UserMutation) RemovedSitesIDs

func (m *UserMutation) RemovedSitesIDs() (ids []int)

RemovedSites returns the removed IDs of the "sites" edge to the Site entity.

func (*UserMutation) ResetEdge

func (m *UserMutation) 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 (*UserMutation) ResetEmail

func (m *UserMutation) ResetEmail()

ResetEmail resets all changes to the "email" field.

func (*UserMutation) ResetField

func (m *UserMutation) 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 (*UserMutation) ResetPassword

func (m *UserMutation) ResetPassword()

ResetPassword resets all changes to the "password" field.

func (*UserMutation) ResetSites

func (m *UserMutation) ResetSites()

ResetSites resets all changes to the "sites" edge.

func (*UserMutation) SetEmail

func (m *UserMutation) SetEmail(s string)

SetEmail sets the "email" field.

func (*UserMutation) SetField

func (m *UserMutation) 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 (*UserMutation) SetPassword

func (m *UserMutation) SetPassword(b []byte)

SetPassword sets the "password" field.

func (*UserMutation) SitesCleared

func (m *UserMutation) SitesCleared() bool

SitesCleared reports if the "sites" edge to the Site entity was cleared.

func (*UserMutation) SitesIDs

func (m *UserMutation) SitesIDs() (ids []int)

SitesIDs returns the "sites" edge IDs in the mutation.

func (UserMutation) Tx

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

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

func (*UserMutation) Type

func (m *UserMutation) Type() string

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

func (*UserMutation) Where

func (m *UserMutation) Where(ps ...predicate.User)

Where appends a list predicates to the UserMutation builder.

type UserQuery

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

UserQuery is the builder for querying User entities.

func (*UserQuery) Aggregate

func (uq *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect

Aggregate returns a UserSelect configured with the given aggregations.

func (*UserQuery) All

func (uq *UserQuery) All(ctx context.Context) ([]*User, error)

All executes the query and returns a list of Users.

func (*UserQuery) AllX

func (uq *UserQuery) AllX(ctx context.Context) []*User

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

func (*UserQuery) Clone

func (uq *UserQuery) Clone() *UserQuery

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

func (*UserQuery) Count

func (uq *UserQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*UserQuery) CountX

func (uq *UserQuery) CountX(ctx context.Context) int

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

func (*UserQuery) Exist

func (uq *UserQuery) Exist(ctx context.Context) (bool, error)

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

func (*UserQuery) ExistX

func (uq *UserQuery) ExistX(ctx context.Context) bool

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

func (*UserQuery) First

func (uq *UserQuery) First(ctx context.Context) (*User, error)

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

func (*UserQuery) FirstID

func (uq *UserQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*UserQuery) FirstIDX

func (uq *UserQuery) FirstIDX(ctx context.Context) int

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

func (*UserQuery) FirstX

func (uq *UserQuery) FirstX(ctx context.Context) *User

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

func (*UserQuery) GroupBy

func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy

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

client.User.Query().
	GroupBy(user.FieldEmail).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*UserQuery) IDs

func (uq *UserQuery) IDs(ctx context.Context) ([]int, error)

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

func (*UserQuery) IDsX

func (uq *UserQuery) IDsX(ctx context.Context) []int

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

func (*UserQuery) Limit

func (uq *UserQuery) Limit(limit int) *UserQuery

Limit adds a limit step to the query.

func (*UserQuery) Offset

func (uq *UserQuery) Offset(offset int) *UserQuery

Offset adds an offset step to the query.

func (*UserQuery) Only

func (uq *UserQuery) Only(ctx context.Context) (*User, error)

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

func (*UserQuery) OnlyID

func (uq *UserQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*UserQuery) OnlyIDX

func (uq *UserQuery) OnlyIDX(ctx context.Context) int

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

func (*UserQuery) OnlyX

func (uq *UserQuery) OnlyX(ctx context.Context) *User

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

func (*UserQuery) Order

func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery

Order adds an order step to the query.

func (*UserQuery) QuerySites

func (uq *UserQuery) QuerySites() *SiteQuery

QuerySites chains the current query on the "sites" edge.

func (*UserQuery) Select

func (uq *UserQuery) Select(fields ...string) *UserSelect

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

client.User.Query().
	Select(user.FieldEmail).
	Scan(ctx, &v)

func (*UserQuery) Unique

func (uq *UserQuery) Unique(unique bool) *UserQuery

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

func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery

Where adds a new predicate for the UserQuery builder.

func (*UserQuery) WithSites

func (uq *UserQuery) WithSites(opts ...func(*SiteQuery)) *UserQuery

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

type UserSelect

type UserSelect struct {
	*UserQuery
	// contains filtered or unexported fields
}

UserSelect is the builder for selecting fields of User entities.

func (*UserSelect) Aggregate

func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect

Aggregate adds the given aggregation functions to the selector query.

func (*UserSelect) Bool

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

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

func (*UserSelect) BoolX

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

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

func (*UserSelect) Bools

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

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

func (*UserSelect) BoolsX

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

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

func (*UserSelect) Float64

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

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

func (*UserSelect) Float64X

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

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

func (*UserSelect) Float64s

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

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

func (*UserSelect) Float64sX

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

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

func (*UserSelect) Int

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

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

func (*UserSelect) IntX

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

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

func (*UserSelect) Ints

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

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

func (*UserSelect) IntsX

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

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

func (*UserSelect) Scan

func (us *UserSelect) Scan(ctx context.Context, v any) error

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

func (*UserSelect) ScanX

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

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

func (*UserSelect) String

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

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

func (*UserSelect) StringX

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

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

func (*UserSelect) Strings

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

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

func (*UserSelect) StringsX

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

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

type UserUpdate

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

UserUpdate is the builder for updating User entities.

func (*UserUpdate) AddSiteIDs

func (uu *UserUpdate) AddSiteIDs(ids ...int) *UserUpdate

AddSiteIDs adds the "sites" edge to the Site entity by IDs.

func (*UserUpdate) AddSites

func (uu *UserUpdate) AddSites(s ...*Site) *UserUpdate

AddSites adds the "sites" edges to the Site entity.

func (*UserUpdate) ClearSites

func (uu *UserUpdate) ClearSites() *UserUpdate

ClearSites clears all "sites" edges to the Site entity.

func (*UserUpdate) Exec

func (uu *UserUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserUpdate) ExecX

func (uu *UserUpdate) ExecX(ctx context.Context)

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

func (*UserUpdate) Mutation

func (uu *UserUpdate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdate) RemoveSiteIDs

func (uu *UserUpdate) RemoveSiteIDs(ids ...int) *UserUpdate

RemoveSiteIDs removes the "sites" edge to Site entities by IDs.

func (*UserUpdate) RemoveSites

func (uu *UserUpdate) RemoveSites(s ...*Site) *UserUpdate

RemoveSites removes "sites" edges to Site entities.

func (*UserUpdate) Save

func (uu *UserUpdate) Save(ctx context.Context) (int, error)

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

func (*UserUpdate) SaveX

func (uu *UserUpdate) SaveX(ctx context.Context) int

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

func (*UserUpdate) SetEmail

func (uu *UserUpdate) SetEmail(s string) *UserUpdate

SetEmail sets the "email" field.

func (*UserUpdate) SetPassword

func (uu *UserUpdate) SetPassword(b []byte) *UserUpdate

SetPassword sets the "password" field.

func (*UserUpdate) Where

func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate

Where appends a list predicates to the UserUpdate builder.

type UserUpdateOne

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

UserUpdateOne is the builder for updating a single User entity.

func (*UserUpdateOne) AddSiteIDs

func (uuo *UserUpdateOne) AddSiteIDs(ids ...int) *UserUpdateOne

AddSiteIDs adds the "sites" edge to the Site entity by IDs.

func (*UserUpdateOne) AddSites

func (uuo *UserUpdateOne) AddSites(s ...*Site) *UserUpdateOne

AddSites adds the "sites" edges to the Site entity.

func (*UserUpdateOne) ClearSites

func (uuo *UserUpdateOne) ClearSites() *UserUpdateOne

ClearSites clears all "sites" edges to the Site entity.

func (*UserUpdateOne) Exec

func (uuo *UserUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*UserUpdateOne) ExecX

func (uuo *UserUpdateOne) ExecX(ctx context.Context)

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

func (*UserUpdateOne) Mutation

func (uuo *UserUpdateOne) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdateOne) RemoveSiteIDs

func (uuo *UserUpdateOne) RemoveSiteIDs(ids ...int) *UserUpdateOne

RemoveSiteIDs removes the "sites" edge to Site entities by IDs.

func (*UserUpdateOne) RemoveSites

func (uuo *UserUpdateOne) RemoveSites(s ...*Site) *UserUpdateOne

RemoveSites removes "sites" edges to Site entities.

func (*UserUpdateOne) Save

func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error)

Save executes the query and returns the updated User entity.

func (*UserUpdateOne) SaveX

func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User

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

func (*UserUpdateOne) Select

func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne

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

func (*UserUpdateOne) SetEmail

func (uuo *UserUpdateOne) SetEmail(s string) *UserUpdateOne

SetEmail sets the "email" field.

func (*UserUpdateOne) SetPassword

func (uuo *UserUpdateOne) SetPassword(b []byte) *UserUpdateOne

SetPassword sets the "password" field.

type Users

type Users []*User

Users is a parsable slice of User.

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.

type Visit

type Visit struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Path holds the value of the "path" field.
	Path string `json:"path,omitempty"`
	// Referrer holds the value of the "referrer" field.
	Referrer string `json:"referrer,omitempty"`
	// Timestamp holds the value of the "timestamp" field.
	Timestamp time.Time `json:"timestamp,omitempty"`
	// IP holds the value of the "ip" field.
	IP string `json:"ip,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the VisitQuery when eager-loading is set.
	Edges VisitEdges `json:"edges"`
	// contains filtered or unexported fields
}

Visit is the model entity for the Visit schema.

func (*Visit) QuerySite

func (v *Visit) QuerySite() *SiteQuery

QuerySite queries the "site" edge of the Visit entity.

func (*Visit) String

func (v *Visit) String() string

String implements the fmt.Stringer.

func (*Visit) Unwrap

func (v *Visit) Unwrap() *Visit

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

func (v *Visit) Update() *VisitUpdateOne

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

type VisitClient

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

VisitClient is a client for the Visit schema.

func NewVisitClient

func NewVisitClient(c config) *VisitClient

NewVisitClient returns a client for the Visit from the given config.

func (*VisitClient) Create

func (c *VisitClient) Create() *VisitCreate

Create returns a builder for creating a Visit entity.

func (*VisitClient) CreateBulk

func (c *VisitClient) CreateBulk(builders ...*VisitCreate) *VisitCreateBulk

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

func (*VisitClient) Delete

func (c *VisitClient) Delete() *VisitDelete

Delete returns a delete builder for Visit.

func (*VisitClient) DeleteOne

func (c *VisitClient) DeleteOne(v *Visit) *VisitDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*VisitClient) DeleteOneID

func (c *VisitClient) DeleteOneID(id int) *VisitDeleteOne

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

func (*VisitClient) Get

func (c *VisitClient) Get(ctx context.Context, id int) (*Visit, error)

Get returns a Visit entity by its id.

func (*VisitClient) GetX

func (c *VisitClient) GetX(ctx context.Context, id int) *Visit

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

func (*VisitClient) Hooks

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

Hooks returns the client hooks.

func (*VisitClient) Query

func (c *VisitClient) Query() *VisitQuery

Query returns a query builder for Visit.

func (*VisitClient) QuerySite

func (c *VisitClient) QuerySite(v *Visit) *SiteQuery

QuerySite queries the site edge of a Visit.

func (*VisitClient) Update

func (c *VisitClient) Update() *VisitUpdate

Update returns an update builder for Visit.

func (*VisitClient) UpdateOne

func (c *VisitClient) UpdateOne(v *Visit) *VisitUpdateOne

UpdateOne returns an update builder for the given entity.

func (*VisitClient) UpdateOneID

func (c *VisitClient) UpdateOneID(id int) *VisitUpdateOne

UpdateOneID returns an update builder for the given id.

func (*VisitClient) Use

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

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

type VisitCreate

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

VisitCreate is the builder for creating a Visit entity.

func (*VisitCreate) Exec

func (vc *VisitCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*VisitCreate) ExecX

func (vc *VisitCreate) ExecX(ctx context.Context)

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

func (*VisitCreate) Mutation

func (vc *VisitCreate) Mutation() *VisitMutation

Mutation returns the VisitMutation object of the builder.

func (*VisitCreate) Save

func (vc *VisitCreate) Save(ctx context.Context) (*Visit, error)

Save creates the Visit in the database.

func (*VisitCreate) SaveX

func (vc *VisitCreate) SaveX(ctx context.Context) *Visit

SaveX calls Save and panics if Save returns an error.

func (*VisitCreate) SetIP

func (vc *VisitCreate) SetIP(s string) *VisitCreate

SetIP sets the "ip" field.

func (*VisitCreate) SetPath

func (vc *VisitCreate) SetPath(s string) *VisitCreate

SetPath sets the "path" field.

func (*VisitCreate) SetReferrer

func (vc *VisitCreate) SetReferrer(s string) *VisitCreate

SetReferrer sets the "referrer" field.

func (*VisitCreate) SetSite

func (vc *VisitCreate) SetSite(s *Site) *VisitCreate

SetSite sets the "site" edge to the Site entity.

func (*VisitCreate) SetSiteID

func (vc *VisitCreate) SetSiteID(id int) *VisitCreate

SetSiteID sets the "site" edge to the Site entity by ID.

func (*VisitCreate) SetTimestamp

func (vc *VisitCreate) SetTimestamp(t time.Time) *VisitCreate

SetTimestamp sets the "timestamp" field.

type VisitCreateBulk

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

VisitCreateBulk is the builder for creating many Visit entities in bulk.

func (*VisitCreateBulk) Exec

func (vcb *VisitCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*VisitCreateBulk) ExecX

func (vcb *VisitCreateBulk) ExecX(ctx context.Context)

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

func (*VisitCreateBulk) Save

func (vcb *VisitCreateBulk) Save(ctx context.Context) ([]*Visit, error)

Save creates the Visit entities in the database.

func (*VisitCreateBulk) SaveX

func (vcb *VisitCreateBulk) SaveX(ctx context.Context) []*Visit

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

type VisitDelete

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

VisitDelete is the builder for deleting a Visit entity.

func (*VisitDelete) Exec

func (vd *VisitDelete) Exec(ctx context.Context) (int, error)

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

func (*VisitDelete) ExecX

func (vd *VisitDelete) ExecX(ctx context.Context) int

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

func (*VisitDelete) Where

func (vd *VisitDelete) Where(ps ...predicate.Visit) *VisitDelete

Where appends a list predicates to the VisitDelete builder.

type VisitDeleteOne

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

VisitDeleteOne is the builder for deleting a single Visit entity.

func (*VisitDeleteOne) Exec

func (vdo *VisitDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*VisitDeleteOne) ExecX

func (vdo *VisitDeleteOne) ExecX(ctx context.Context)

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

type VisitEdges

type VisitEdges struct {
	// Site holds the value of the site edge.
	Site *Site `json:"site,omitempty"`
	// contains filtered or unexported fields
}

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

func (VisitEdges) SiteOrErr

func (e VisitEdges) SiteOrErr() (*Site, error)

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

type VisitGroupBy

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

VisitGroupBy is the group-by builder for Visit entities.

func (*VisitGroupBy) Aggregate

func (vgb *VisitGroupBy) Aggregate(fns ...AggregateFunc) *VisitGroupBy

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

func (*VisitGroupBy) Bool

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

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

func (*VisitGroupBy) BoolX

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

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

func (*VisitGroupBy) Bools

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

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

func (*VisitGroupBy) BoolsX

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

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

func (*VisitGroupBy) Float64

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

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

func (*VisitGroupBy) Float64X

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

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

func (*VisitGroupBy) Float64s

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

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

func (*VisitGroupBy) Float64sX

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

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

func (*VisitGroupBy) Int

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

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

func (*VisitGroupBy) IntX

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

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

func (*VisitGroupBy) Ints

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

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

func (*VisitGroupBy) IntsX

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

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

func (*VisitGroupBy) Scan

func (vgb *VisitGroupBy) Scan(ctx context.Context, v any) error

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

func (*VisitGroupBy) ScanX

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

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

func (*VisitGroupBy) String

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

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

func (*VisitGroupBy) StringX

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

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

func (*VisitGroupBy) Strings

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

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

func (*VisitGroupBy) StringsX

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

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

type VisitMutation

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

VisitMutation represents an operation that mutates the Visit nodes in the graph.

func (*VisitMutation) AddField

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

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

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

func (*VisitMutation) AddedField

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

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

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

func (*VisitMutation) AddedIDs

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

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

func (*VisitMutation) ClearEdge

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

func (m *VisitMutation) 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 (*VisitMutation) ClearSite

func (m *VisitMutation) ClearSite()

ClearSite clears the "site" edge to the Site entity.

func (*VisitMutation) ClearedEdges

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

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

func (*VisitMutation) ClearedFields

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

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

func (VisitMutation) Client

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

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

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

func (*VisitMutation) Field

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

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

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

func (*VisitMutation) Fields

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

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

func (m *VisitMutation) 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 (*VisitMutation) IP

func (m *VisitMutation) IP() (r string, exists bool)

IP returns the value of the "ip" field in the mutation.

func (*VisitMutation) OldField

func (m *VisitMutation) 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 (*VisitMutation) OldIP

func (m *VisitMutation) OldIP(ctx context.Context) (v string, err error)

OldIP returns the old "ip" field's value of the Visit entity. If the Visit 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 (*VisitMutation) OldPath

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

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

func (m *VisitMutation) OldReferrer(ctx context.Context) (v string, err error)

OldReferrer returns the old "referrer" field's value of the Visit entity. If the Visit 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 (*VisitMutation) OldTimestamp

func (m *VisitMutation) OldTimestamp(ctx context.Context) (v time.Time, err error)

OldTimestamp returns the old "timestamp" field's value of the Visit entity. If the Visit 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 (*VisitMutation) Op

func (m *VisitMutation) Op() Op

Op returns the operation name.

func (*VisitMutation) Path

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

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

func (*VisitMutation) Referrer

func (m *VisitMutation) Referrer() (r string, exists bool)

Referrer returns the value of the "referrer" field in the mutation.

func (*VisitMutation) RemovedEdges

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

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

func (*VisitMutation) RemovedIDs

func (m *VisitMutation) 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 (*VisitMutation) ResetEdge

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

func (m *VisitMutation) 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 (*VisitMutation) ResetIP

func (m *VisitMutation) ResetIP()

ResetIP resets all changes to the "ip" field.

func (*VisitMutation) ResetPath

func (m *VisitMutation) ResetPath()

ResetPath resets all changes to the "path" field.

func (*VisitMutation) ResetReferrer

func (m *VisitMutation) ResetReferrer()

ResetReferrer resets all changes to the "referrer" field.

func (*VisitMutation) ResetSite

func (m *VisitMutation) ResetSite()

ResetSite resets all changes to the "site" edge.

func (*VisitMutation) ResetTimestamp

func (m *VisitMutation) ResetTimestamp()

ResetTimestamp resets all changes to the "timestamp" field.

func (*VisitMutation) SetField

func (m *VisitMutation) 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 (*VisitMutation) SetIP

func (m *VisitMutation) SetIP(s string)

SetIP sets the "ip" field.

func (*VisitMutation) SetPath

func (m *VisitMutation) SetPath(s string)

SetPath sets the "path" field.

func (*VisitMutation) SetReferrer

func (m *VisitMutation) SetReferrer(s string)

SetReferrer sets the "referrer" field.

func (*VisitMutation) SetSiteID

func (m *VisitMutation) SetSiteID(id int)

SetSiteID sets the "site" edge to the Site entity by id.

func (*VisitMutation) SetTimestamp

func (m *VisitMutation) SetTimestamp(t time.Time)

SetTimestamp sets the "timestamp" field.

func (*VisitMutation) SiteCleared

func (m *VisitMutation) SiteCleared() bool

SiteCleared reports if the "site" edge to the Site entity was cleared.

func (*VisitMutation) SiteID

func (m *VisitMutation) SiteID() (id int, exists bool)

SiteID returns the "site" edge ID in the mutation.

func (*VisitMutation) SiteIDs

func (m *VisitMutation) SiteIDs() (ids []int)

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

func (*VisitMutation) Timestamp

func (m *VisitMutation) Timestamp() (r time.Time, exists bool)

Timestamp returns the value of the "timestamp" field in the mutation.

func (VisitMutation) Tx

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

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

func (*VisitMutation) Type

func (m *VisitMutation) Type() string

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

func (*VisitMutation) Where

func (m *VisitMutation) Where(ps ...predicate.Visit)

Where appends a list predicates to the VisitMutation builder.

type VisitQuery

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

VisitQuery is the builder for querying Visit entities.

func (*VisitQuery) Aggregate

func (vq *VisitQuery) Aggregate(fns ...AggregateFunc) *VisitSelect

Aggregate returns a VisitSelect configured with the given aggregations.

func (*VisitQuery) All

func (vq *VisitQuery) All(ctx context.Context) ([]*Visit, error)

All executes the query and returns a list of Visits.

func (*VisitQuery) AllX

func (vq *VisitQuery) AllX(ctx context.Context) []*Visit

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

func (*VisitQuery) Clone

func (vq *VisitQuery) Clone() *VisitQuery

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

func (*VisitQuery) Count

func (vq *VisitQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*VisitQuery) CountX

func (vq *VisitQuery) CountX(ctx context.Context) int

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

func (*VisitQuery) Exist

func (vq *VisitQuery) Exist(ctx context.Context) (bool, error)

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

func (*VisitQuery) ExistX

func (vq *VisitQuery) ExistX(ctx context.Context) bool

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

func (*VisitQuery) First

func (vq *VisitQuery) First(ctx context.Context) (*Visit, error)

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

func (*VisitQuery) FirstID

func (vq *VisitQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*VisitQuery) FirstIDX

func (vq *VisitQuery) FirstIDX(ctx context.Context) int

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

func (*VisitQuery) FirstX

func (vq *VisitQuery) FirstX(ctx context.Context) *Visit

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

func (*VisitQuery) GroupBy

func (vq *VisitQuery) GroupBy(field string, fields ...string) *VisitGroupBy

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.Visit.Query().
	GroupBy(visit.FieldPath).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*VisitQuery) IDs

func (vq *VisitQuery) IDs(ctx context.Context) ([]int, error)

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

func (*VisitQuery) IDsX

func (vq *VisitQuery) IDsX(ctx context.Context) []int

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

func (*VisitQuery) Limit

func (vq *VisitQuery) Limit(limit int) *VisitQuery

Limit adds a limit step to the query.

func (*VisitQuery) Offset

func (vq *VisitQuery) Offset(offset int) *VisitQuery

Offset adds an offset step to the query.

func (*VisitQuery) Only

func (vq *VisitQuery) Only(ctx context.Context) (*Visit, error)

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

func (*VisitQuery) OnlyID

func (vq *VisitQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*VisitQuery) OnlyIDX

func (vq *VisitQuery) OnlyIDX(ctx context.Context) int

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

func (*VisitQuery) OnlyX

func (vq *VisitQuery) OnlyX(ctx context.Context) *Visit

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

func (*VisitQuery) Order

func (vq *VisitQuery) Order(o ...OrderFunc) *VisitQuery

Order adds an order step to the query.

func (*VisitQuery) QuerySite

func (vq *VisitQuery) QuerySite() *SiteQuery

QuerySite chains the current query on the "site" edge.

func (*VisitQuery) Select

func (vq *VisitQuery) Select(fields ...string) *VisitSelect

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.Visit.Query().
	Select(visit.FieldPath).
	Scan(ctx, &v)

func (*VisitQuery) Unique

func (vq *VisitQuery) Unique(unique bool) *VisitQuery

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

func (vq *VisitQuery) Where(ps ...predicate.Visit) *VisitQuery

Where adds a new predicate for the VisitQuery builder.

func (*VisitQuery) WithSite

func (vq *VisitQuery) WithSite(opts ...func(*SiteQuery)) *VisitQuery

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

type VisitSelect

type VisitSelect struct {
	*VisitQuery
	// contains filtered or unexported fields
}

VisitSelect is the builder for selecting fields of Visit entities.

func (*VisitSelect) Aggregate

func (vs *VisitSelect) Aggregate(fns ...AggregateFunc) *VisitSelect

Aggregate adds the given aggregation functions to the selector query.

func (*VisitSelect) Bool

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

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

func (*VisitSelect) BoolX

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

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

func (*VisitSelect) Bools

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

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

func (*VisitSelect) BoolsX

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

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

func (*VisitSelect) Float64

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

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

func (*VisitSelect) Float64X

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

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

func (*VisitSelect) Float64s

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

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

func (*VisitSelect) Float64sX

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

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

func (*VisitSelect) Int

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

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

func (*VisitSelect) IntX

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

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

func (*VisitSelect) Ints

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

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

func (*VisitSelect) IntsX

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

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

func (*VisitSelect) Scan

func (vs *VisitSelect) Scan(ctx context.Context, v any) error

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

func (*VisitSelect) ScanX

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

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

func (*VisitSelect) String

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

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

func (*VisitSelect) StringX

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

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

func (*VisitSelect) Strings

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

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

func (*VisitSelect) StringsX

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

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

type VisitUpdate

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

VisitUpdate is the builder for updating Visit entities.

func (*VisitUpdate) ClearSite

func (vu *VisitUpdate) ClearSite() *VisitUpdate

ClearSite clears the "site" edge to the Site entity.

func (*VisitUpdate) Exec

func (vu *VisitUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*VisitUpdate) ExecX

func (vu *VisitUpdate) ExecX(ctx context.Context)

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

func (*VisitUpdate) Mutation

func (vu *VisitUpdate) Mutation() *VisitMutation

Mutation returns the VisitMutation object of the builder.

func (*VisitUpdate) Save

func (vu *VisitUpdate) Save(ctx context.Context) (int, error)

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

func (*VisitUpdate) SaveX

func (vu *VisitUpdate) SaveX(ctx context.Context) int

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

func (*VisitUpdate) SetIP

func (vu *VisitUpdate) SetIP(s string) *VisitUpdate

SetIP sets the "ip" field.

func (*VisitUpdate) SetPath

func (vu *VisitUpdate) SetPath(s string) *VisitUpdate

SetPath sets the "path" field.

func (*VisitUpdate) SetReferrer

func (vu *VisitUpdate) SetReferrer(s string) *VisitUpdate

SetReferrer sets the "referrer" field.

func (*VisitUpdate) SetSite

func (vu *VisitUpdate) SetSite(s *Site) *VisitUpdate

SetSite sets the "site" edge to the Site entity.

func (*VisitUpdate) SetSiteID

func (vu *VisitUpdate) SetSiteID(id int) *VisitUpdate

SetSiteID sets the "site" edge to the Site entity by ID.

func (*VisitUpdate) SetTimestamp

func (vu *VisitUpdate) SetTimestamp(t time.Time) *VisitUpdate

SetTimestamp sets the "timestamp" field.

func (*VisitUpdate) Where

func (vu *VisitUpdate) Where(ps ...predicate.Visit) *VisitUpdate

Where appends a list predicates to the VisitUpdate builder.

type VisitUpdateOne

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

VisitUpdateOne is the builder for updating a single Visit entity.

func (*VisitUpdateOne) ClearSite

func (vuo *VisitUpdateOne) ClearSite() *VisitUpdateOne

ClearSite clears the "site" edge to the Site entity.

func (*VisitUpdateOne) Exec

func (vuo *VisitUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*VisitUpdateOne) ExecX

func (vuo *VisitUpdateOne) ExecX(ctx context.Context)

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

func (*VisitUpdateOne) Mutation

func (vuo *VisitUpdateOne) Mutation() *VisitMutation

Mutation returns the VisitMutation object of the builder.

func (*VisitUpdateOne) Save

func (vuo *VisitUpdateOne) Save(ctx context.Context) (*Visit, error)

Save executes the query and returns the updated Visit entity.

func (*VisitUpdateOne) SaveX

func (vuo *VisitUpdateOne) SaveX(ctx context.Context) *Visit

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

func (*VisitUpdateOne) Select

func (vuo *VisitUpdateOne) Select(field string, fields ...string) *VisitUpdateOne

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

func (*VisitUpdateOne) SetIP

func (vuo *VisitUpdateOne) SetIP(s string) *VisitUpdateOne

SetIP sets the "ip" field.

func (*VisitUpdateOne) SetPath

func (vuo *VisitUpdateOne) SetPath(s string) *VisitUpdateOne

SetPath sets the "path" field.

func (*VisitUpdateOne) SetReferrer

func (vuo *VisitUpdateOne) SetReferrer(s string) *VisitUpdateOne

SetReferrer sets the "referrer" field.

func (*VisitUpdateOne) SetSite

func (vuo *VisitUpdateOne) SetSite(s *Site) *VisitUpdateOne

SetSite sets the "site" edge to the Site entity.

func (*VisitUpdateOne) SetSiteID

func (vuo *VisitUpdateOne) SetSiteID(id int) *VisitUpdateOne

SetSiteID sets the "site" edge to the Site entity by ID.

func (*VisitUpdateOne) SetTimestamp

func (vuo *VisitUpdateOne) SetTimestamp(t time.Time) *VisitUpdateOne

SetTimestamp sets the "timestamp" field.

type Visits

type Visits []*Visit

Visits is a parsable slice of Visit.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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