ent

package
v0.0.0-...-073b88a Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

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

	// Node types.
	TypeUserReport = "UserReport"
)

Variables

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

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

Functions

func Asc

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

Asc applies the given fields in ASC order.

func Desc

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

Desc applies the given fields in DESC order.

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func IsValidationError

func IsValidationError(err error) bool

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

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

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

NewContext returns a new context with the given Client attached.

func NewTxContext

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

NewTxContext returns a new context with the given Tx attached.

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

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

func As

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

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

func Count

func Count() AggregateFunc

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

func Max

func Max(field string) AggregateFunc

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

func Mean

func Mean(field string) AggregateFunc

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

func Min

func Min(field string) AggregateFunc

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

func Sum

func Sum(field string) AggregateFunc

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

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// UserReport is the client for interacting with the UserReport builders.
	UserReport *UserReportClient
	// 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().
	UserReport.
	Query().
	Count(ctx)

func (*Client) Intercept

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

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

func (*Client) Mutate

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

Mutate implements the ent.Mutator interface.

func (*Client) Tx

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

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

func (*Client) Use

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

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

type CommitFunc

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

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

func (CommitFunc) Commit

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

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

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

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

type Committer

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

Committer is the interface that wraps the Commit method.

type ConstraintError

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

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

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

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

type InterceptFunc

type InterceptFunc = ent.InterceptFunc

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

type Interceptor

type Interceptor = ent.Interceptor

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

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

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

type NotFoundError

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

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

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

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

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

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

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

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

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

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

type Policy

type Policy = ent.Policy

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

type Querier

type Querier = ent.Querier

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

type QuerierFunc

type QuerierFunc = ent.QuerierFunc

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

type Query

type Query = ent.Query

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

type QueryContext

type QueryContext = ent.QueryContext

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

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

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

type Rollbacker

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

Rollbacker is the interface that wraps the Rollback method.

type TraverseFunc

type TraverseFunc = ent.TraverseFunc

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

type Traverser

type Traverser = ent.Traverser

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

type Tx

type Tx struct {

	// UserReport is the client for interacting with the UserReport builders.
	UserReport *UserReportClient
	// 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 UserReport

type UserReport struct {

	// ID of the ent.
	ID string `json:"id,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// contains filtered or unexported fields
}

UserReport is the model entity for the UserReport schema.

func (*UserReport) String

func (ur *UserReport) String() string

String implements the fmt.Stringer.

func (*UserReport) Unwrap

func (ur *UserReport) Unwrap() *UserReport

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

func (ur *UserReport) Update() *UserReportUpdateOne

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

func (*UserReport) Value

func (ur *UserReport) Value(name string) (ent.Value, error)

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

type UserReportClient

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

UserReportClient is a client for the UserReport schema.

func NewUserReportClient

func NewUserReportClient(c config) *UserReportClient

NewUserReportClient returns a client for the UserReport from the given config.

func (*UserReportClient) Create

func (c *UserReportClient) Create() *UserReportCreate

Create returns a builder for creating a UserReport entity.

func (*UserReportClient) CreateBulk

func (c *UserReportClient) CreateBulk(builders ...*UserReportCreate) *UserReportCreateBulk

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

func (*UserReportClient) Delete

func (c *UserReportClient) Delete() *UserReportDelete

Delete returns a delete builder for UserReport.

func (*UserReportClient) DeleteOne

func (c *UserReportClient) DeleteOne(ur *UserReport) *UserReportDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*UserReportClient) DeleteOneID

func (c *UserReportClient) DeleteOneID(id string) *UserReportDeleteOne

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

func (*UserReportClient) Get

func (c *UserReportClient) Get(ctx context.Context, id string) (*UserReport, error)

Get returns a UserReport entity by its id.

func (*UserReportClient) GetX

func (c *UserReportClient) GetX(ctx context.Context, id string) *UserReport

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

func (*UserReportClient) Hooks

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

Hooks returns the client hooks.

func (*UserReportClient) Intercept

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

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

func (*UserReportClient) Interceptors

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

Interceptors returns the client interceptors.

func (*UserReportClient) MapCreateBulk

func (c *UserReportClient) MapCreateBulk(slice any, setFunc func(*UserReportCreate, int)) *UserReportCreateBulk

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

func (*UserReportClient) Query

func (c *UserReportClient) Query() *UserReportQuery

Query returns a query builder for UserReport.

func (*UserReportClient) Update

func (c *UserReportClient) Update() *UserReportUpdate

Update returns an update builder for UserReport.

func (*UserReportClient) UpdateOne

func (c *UserReportClient) UpdateOne(ur *UserReport) *UserReportUpdateOne

UpdateOne returns an update builder for the given entity.

func (*UserReportClient) UpdateOneID

func (c *UserReportClient) UpdateOneID(id string) *UserReportUpdateOne

UpdateOneID returns an update builder for the given id.

func (*UserReportClient) Use

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

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

type UserReportCreate

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

UserReportCreate is the builder for creating a UserReport entity.

func (*UserReportCreate) Exec

func (urc *UserReportCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserReportCreate) ExecX

func (urc *UserReportCreate) ExecX(ctx context.Context)

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

func (*UserReportCreate) Mutation

func (urc *UserReportCreate) Mutation() *UserReportMutation

Mutation returns the UserReportMutation object of the builder.

func (*UserReportCreate) Save

func (urc *UserReportCreate) Save(ctx context.Context) (*UserReport, error)

Save creates the UserReport in the database.

func (*UserReportCreate) SaveX

func (urc *UserReportCreate) SaveX(ctx context.Context) *UserReport

SaveX calls Save and panics if Save returns an error.

func (*UserReportCreate) SetCreatedAt

func (urc *UserReportCreate) SetCreatedAt(t time.Time) *UserReportCreate

SetCreatedAt sets the "created_at" field.

func (*UserReportCreate) SetID

func (urc *UserReportCreate) SetID(s string) *UserReportCreate

SetID sets the "id" field.

func (*UserReportCreate) SetNillableCreatedAt

func (urc *UserReportCreate) SetNillableCreatedAt(t *time.Time) *UserReportCreate

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

type UserReportCreateBulk

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

UserReportCreateBulk is the builder for creating many UserReport entities in bulk.

func (*UserReportCreateBulk) Exec

func (urcb *UserReportCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*UserReportCreateBulk) ExecX

func (urcb *UserReportCreateBulk) ExecX(ctx context.Context)

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

func (*UserReportCreateBulk) Save

func (urcb *UserReportCreateBulk) Save(ctx context.Context) ([]*UserReport, error)

Save creates the UserReport entities in the database.

func (*UserReportCreateBulk) SaveX

func (urcb *UserReportCreateBulk) SaveX(ctx context.Context) []*UserReport

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

type UserReportDelete

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

UserReportDelete is the builder for deleting a UserReport entity.

func (*UserReportDelete) Exec

func (urd *UserReportDelete) Exec(ctx context.Context) (int, error)

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

func (*UserReportDelete) ExecX

func (urd *UserReportDelete) ExecX(ctx context.Context) int

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

func (*UserReportDelete) Where

Where appends a list predicates to the UserReportDelete builder.

type UserReportDeleteOne

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

UserReportDeleteOne is the builder for deleting a single UserReport entity.

func (*UserReportDeleteOne) Exec

func (urdo *UserReportDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*UserReportDeleteOne) ExecX

func (urdo *UserReportDeleteOne) ExecX(ctx context.Context)

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

func (*UserReportDeleteOne) Where

Where appends a list predicates to the UserReportDelete builder.

type UserReportGroupBy

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

UserReportGroupBy is the group-by builder for UserReport entities.

func (*UserReportGroupBy) Aggregate

func (urgb *UserReportGroupBy) Aggregate(fns ...AggregateFunc) *UserReportGroupBy

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

func (*UserReportGroupBy) Bool

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

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

func (*UserReportGroupBy) BoolX

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

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

func (*UserReportGroupBy) Bools

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

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

func (*UserReportGroupBy) BoolsX

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

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

func (*UserReportGroupBy) Float64

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

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

func (*UserReportGroupBy) Float64X

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

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

func (*UserReportGroupBy) Float64s

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

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

func (*UserReportGroupBy) Float64sX

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

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

func (*UserReportGroupBy) Int

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

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

func (*UserReportGroupBy) IntX

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

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

func (*UserReportGroupBy) Ints

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

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

func (*UserReportGroupBy) IntsX

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

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

func (*UserReportGroupBy) Scan

func (urgb *UserReportGroupBy) Scan(ctx context.Context, v any) error

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

func (*UserReportGroupBy) ScanX

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

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

func (*UserReportGroupBy) String

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

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

func (*UserReportGroupBy) StringX

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

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

func (*UserReportGroupBy) Strings

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

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

func (*UserReportGroupBy) StringsX

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

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

type UserReportMutation

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

UserReportMutation represents an operation that mutates the UserReport nodes in the graph.

func (*UserReportMutation) AddField

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

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

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

func (*UserReportMutation) AddedField

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

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

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

func (*UserReportMutation) AddedIDs

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

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

func (*UserReportMutation) ClearEdge

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

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

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

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

func (*UserReportMutation) ClearedFields

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

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

func (UserReportMutation) Client

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

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

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

func (*UserReportMutation) EdgeCleared

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

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

func (*UserReportMutation) Field

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

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

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

func (*UserReportMutation) Fields

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

func (m *UserReportMutation) ID() (id string, 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 (*UserReportMutation) IDs

func (m *UserReportMutation) IDs(ctx context.Context) ([]string, 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 (*UserReportMutation) OldCreatedAt

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

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

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

func (m *UserReportMutation) Op() Op

Op returns the operation name.

func (*UserReportMutation) RemovedEdges

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

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

func (*UserReportMutation) RemovedIDs

func (m *UserReportMutation) 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 (*UserReportMutation) ResetCreatedAt

func (m *UserReportMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*UserReportMutation) ResetEdge

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

func (m *UserReportMutation) 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 (*UserReportMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*UserReportMutation) SetField

func (m *UserReportMutation) 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 (*UserReportMutation) SetID

func (m *UserReportMutation) SetID(id string)

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

func (*UserReportMutation) SetOp

func (m *UserReportMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (UserReportMutation) Tx

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

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

func (*UserReportMutation) Type

func (m *UserReportMutation) Type() string

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

func (*UserReportMutation) Where

func (m *UserReportMutation) Where(ps ...predicate.UserReport)

Where appends a list predicates to the UserReportMutation builder.

func (*UserReportMutation) WhereP

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

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

type UserReportQuery

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

UserReportQuery is the builder for querying UserReport entities.

func (*UserReportQuery) Aggregate

func (urq *UserReportQuery) Aggregate(fns ...AggregateFunc) *UserReportSelect

Aggregate returns a UserReportSelect configured with the given aggregations.

func (*UserReportQuery) All

func (urq *UserReportQuery) All(ctx context.Context) ([]*UserReport, error)

All executes the query and returns a list of UserReports.

func (*UserReportQuery) AllX

func (urq *UserReportQuery) AllX(ctx context.Context) []*UserReport

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

func (*UserReportQuery) Clone

func (urq *UserReportQuery) Clone() *UserReportQuery

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

func (*UserReportQuery) Count

func (urq *UserReportQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*UserReportQuery) CountX

func (urq *UserReportQuery) CountX(ctx context.Context) int

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

func (*UserReportQuery) Exist

func (urq *UserReportQuery) Exist(ctx context.Context) (bool, error)

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

func (*UserReportQuery) ExistX

func (urq *UserReportQuery) ExistX(ctx context.Context) bool

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

func (*UserReportQuery) First

func (urq *UserReportQuery) First(ctx context.Context) (*UserReport, error)

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

func (*UserReportQuery) FirstID

func (urq *UserReportQuery) FirstID(ctx context.Context) (id string, err error)

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

func (*UserReportQuery) FirstIDX

func (urq *UserReportQuery) FirstIDX(ctx context.Context) string

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

func (*UserReportQuery) FirstX

func (urq *UserReportQuery) FirstX(ctx context.Context) *UserReport

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

func (*UserReportQuery) GroupBy

func (urq *UserReportQuery) GroupBy(field string, fields ...string) *UserReportGroupBy

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 {
	CreatedAt time.Time `json:"created_at,omitempty"`
	Count int `json:"count,omitempty"`
}

client.UserReport.Query().
	GroupBy(userreport.FieldCreatedAt).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*UserReportQuery) IDs

func (urq *UserReportQuery) IDs(ctx context.Context) (ids []string, err error)

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

func (*UserReportQuery) IDsX

func (urq *UserReportQuery) IDsX(ctx context.Context) []string

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

func (*UserReportQuery) Limit

func (urq *UserReportQuery) Limit(limit int) *UserReportQuery

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

func (*UserReportQuery) Offset

func (urq *UserReportQuery) Offset(offset int) *UserReportQuery

Offset to start from.

func (*UserReportQuery) Only

func (urq *UserReportQuery) Only(ctx context.Context) (*UserReport, error)

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

func (*UserReportQuery) OnlyID

func (urq *UserReportQuery) OnlyID(ctx context.Context) (id string, err error)

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

func (*UserReportQuery) OnlyIDX

func (urq *UserReportQuery) OnlyIDX(ctx context.Context) string

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

func (*UserReportQuery) OnlyX

func (urq *UserReportQuery) OnlyX(ctx context.Context) *UserReport

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

func (*UserReportQuery) Order

Order specifies how the records should be ordered.

func (*UserReportQuery) Select

func (urq *UserReportQuery) Select(fields ...string) *UserReportSelect

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 {
	CreatedAt time.Time `json:"created_at,omitempty"`
}

client.UserReport.Query().
	Select(userreport.FieldCreatedAt).
	Scan(ctx, &v)

func (*UserReportQuery) Unique

func (urq *UserReportQuery) Unique(unique bool) *UserReportQuery

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

Where adds a new predicate for the UserReportQuery builder.

type UserReportSelect

type UserReportSelect struct {
	*UserReportQuery
	// contains filtered or unexported fields
}

UserReportSelect is the builder for selecting fields of UserReport entities.

func (*UserReportSelect) Aggregate

func (urs *UserReportSelect) Aggregate(fns ...AggregateFunc) *UserReportSelect

Aggregate adds the given aggregation functions to the selector query.

func (*UserReportSelect) Bool

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

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

func (*UserReportSelect) BoolX

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

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

func (*UserReportSelect) Bools

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

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

func (*UserReportSelect) BoolsX

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

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

func (*UserReportSelect) Float64

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

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

func (*UserReportSelect) Float64X

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

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

func (*UserReportSelect) Float64s

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

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

func (*UserReportSelect) Float64sX

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

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

func (*UserReportSelect) Int

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

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

func (*UserReportSelect) IntX

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

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

func (*UserReportSelect) Ints

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

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

func (*UserReportSelect) IntsX

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

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

func (*UserReportSelect) Scan

func (urs *UserReportSelect) Scan(ctx context.Context, v any) error

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

func (*UserReportSelect) ScanX

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

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

func (*UserReportSelect) String

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

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

func (*UserReportSelect) StringX

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

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

func (*UserReportSelect) Strings

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

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

func (*UserReportSelect) StringsX

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

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

type UserReportUpdate

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

UserReportUpdate is the builder for updating UserReport entities.

func (*UserReportUpdate) Exec

func (uru *UserReportUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserReportUpdate) ExecX

func (uru *UserReportUpdate) ExecX(ctx context.Context)

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

func (*UserReportUpdate) Mutation

func (uru *UserReportUpdate) Mutation() *UserReportMutation

Mutation returns the UserReportMutation object of the builder.

func (*UserReportUpdate) Save

func (uru *UserReportUpdate) Save(ctx context.Context) (int, error)

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

func (*UserReportUpdate) SaveX

func (uru *UserReportUpdate) SaveX(ctx context.Context) int

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

func (*UserReportUpdate) Where

Where appends a list predicates to the UserReportUpdate builder.

type UserReportUpdateOne

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

UserReportUpdateOne is the builder for updating a single UserReport entity.

func (*UserReportUpdateOne) Exec

func (uruo *UserReportUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*UserReportUpdateOne) ExecX

func (uruo *UserReportUpdateOne) ExecX(ctx context.Context)

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

func (*UserReportUpdateOne) Mutation

func (uruo *UserReportUpdateOne) Mutation() *UserReportMutation

Mutation returns the UserReportMutation object of the builder.

func (*UserReportUpdateOne) Save

func (uruo *UserReportUpdateOne) Save(ctx context.Context) (*UserReport, error)

Save executes the query and returns the updated UserReport entity.

func (*UserReportUpdateOne) SaveX

func (uruo *UserReportUpdateOne) SaveX(ctx context.Context) *UserReport

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

func (*UserReportUpdateOne) Select

func (uruo *UserReportUpdateOne) Select(field string, fields ...string) *UserReportUpdateOne

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

func (*UserReportUpdateOne) Where

Where appends a list predicates to the UserReportUpdate builder.

type UserReports

type UserReports []*UserReport

UserReports is a parsable slice of UserReport.

type ValidationError

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

ValidationError returns when validating a field or edge fails.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Value

type Value = ent.Value

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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