ent

package
v0.0.0-...-86dbffa Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT, MIT Imports: 17 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.
	TypeGame = "Game"
)

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
	// Game is the client for interacting with the Game builders.
	Game *GameClient
	// 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().
	Game.
	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 Game

type Game struct {

	// ID of the ent.
	ID int64 `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Description holds the value of the "description" field.
	Description string `json:"description,omitempty"`
	// Count holds the value of the "count" field.
	Count int64 `json:"count,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

Game is the model entity for the Game schema.

func (*Game) String

func (ga *Game) String() string

String implements the fmt.Stringer.

func (*Game) Unwrap

func (ga *Game) Unwrap() *Game

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

func (ga *Game) Update() *GameUpdateOne

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

type GameClient

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

GameClient is a client for the Game schema.

func NewGameClient

func NewGameClient(c config) *GameClient

NewGameClient returns a client for the Game from the given config.

func (*GameClient) Create

func (c *GameClient) Create() *GameCreate

Create returns a create builder for Game.

func (*GameClient) CreateBulk

func (c *GameClient) CreateBulk(builders ...*GameCreate) *GameCreateBulk

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

func (*GameClient) Delete

func (c *GameClient) Delete() *GameDelete

Delete returns a delete builder for Game.

func (*GameClient) DeleteOne

func (c *GameClient) DeleteOne(ga *Game) *GameDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*GameClient) DeleteOneID

func (c *GameClient) DeleteOneID(id int64) *GameDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*GameClient) Get

func (c *GameClient) Get(ctx context.Context, id int64) (*Game, error)

Get returns a Game entity by its id.

func (*GameClient) GetX

func (c *GameClient) GetX(ctx context.Context, id int64) *Game

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

func (*GameClient) Hooks

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

Hooks returns the client hooks.

func (*GameClient) Query

func (c *GameClient) Query() *GameQuery

Query returns a query builder for Game.

func (*GameClient) Update

func (c *GameClient) Update() *GameUpdate

Update returns an update builder for Game.

func (*GameClient) UpdateOne

func (c *GameClient) UpdateOne(ga *Game) *GameUpdateOne

UpdateOne returns an update builder for the given entity.

func (*GameClient) UpdateOneID

func (c *GameClient) UpdateOneID(id int64) *GameUpdateOne

UpdateOneID returns an update builder for the given id.

func (*GameClient) Use

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

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

type GameCreate

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

GameCreate is the builder for creating a Game entity.

func (*GameCreate) Exec

func (gc *GameCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*GameCreate) ExecX

func (gc *GameCreate) ExecX(ctx context.Context)

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

func (*GameCreate) Mutation

func (gc *GameCreate) Mutation() *GameMutation

Mutation returns the GameMutation object of the builder.

func (*GameCreate) Save

func (gc *GameCreate) Save(ctx context.Context) (*Game, error)

Save creates the Game in the database.

func (*GameCreate) SaveX

func (gc *GameCreate) SaveX(ctx context.Context) *Game

SaveX calls Save and panics if Save returns an error.

func (*GameCreate) SetCount

func (gc *GameCreate) SetCount(i int64) *GameCreate

SetCount sets the "count" field.

func (*GameCreate) SetCreatedAt

func (gc *GameCreate) SetCreatedAt(t time.Time) *GameCreate

SetCreatedAt sets the "created_at" field.

func (*GameCreate) SetDescription

func (gc *GameCreate) SetDescription(s string) *GameCreate

SetDescription sets the "description" field.

func (*GameCreate) SetID

func (gc *GameCreate) SetID(i int64) *GameCreate

SetID sets the "id" field.

func (*GameCreate) SetName

func (gc *GameCreate) SetName(s string) *GameCreate

SetName sets the "name" field.

func (*GameCreate) SetNillableCreatedAt

func (gc *GameCreate) SetNillableCreatedAt(t *time.Time) *GameCreate

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

func (*GameCreate) SetNillableUpdatedAt

func (gc *GameCreate) SetNillableUpdatedAt(t *time.Time) *GameCreate

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (*GameCreate) SetUpdatedAt

func (gc *GameCreate) SetUpdatedAt(t time.Time) *GameCreate

SetUpdatedAt sets the "updated_at" field.

type GameCreateBulk

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

GameCreateBulk is the builder for creating many Game entities in bulk.

func (*GameCreateBulk) Exec

func (gcb *GameCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*GameCreateBulk) ExecX

func (gcb *GameCreateBulk) ExecX(ctx context.Context)

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

func (*GameCreateBulk) Save

func (gcb *GameCreateBulk) Save(ctx context.Context) ([]*Game, error)

Save creates the Game entities in the database.

func (*GameCreateBulk) SaveX

func (gcb *GameCreateBulk) SaveX(ctx context.Context) []*Game

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

type GameDelete

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

GameDelete is the builder for deleting a Game entity.

func (*GameDelete) Exec

func (gd *GameDelete) Exec(ctx context.Context) (int, error)

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

func (*GameDelete) ExecX

func (gd *GameDelete) ExecX(ctx context.Context) int

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

func (*GameDelete) Where

func (gd *GameDelete) Where(ps ...predicate.Game) *GameDelete

Where appends a list predicates to the GameDelete builder.

type GameDeleteOne

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

GameDeleteOne is the builder for deleting a single Game entity.

func (*GameDeleteOne) Exec

func (gdo *GameDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*GameDeleteOne) ExecX

func (gdo *GameDeleteOne) ExecX(ctx context.Context)

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

type GameGroupBy

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

GameGroupBy is the group-by builder for Game entities.

func (*GameGroupBy) Aggregate

func (ggb *GameGroupBy) Aggregate(fns ...AggregateFunc) *GameGroupBy

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

func (*GameGroupBy) Bool

func (ggb *GameGroupBy) Bool(ctx context.Context) (_ bool, err error)

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

func (*GameGroupBy) BoolX

func (ggb *GameGroupBy) BoolX(ctx context.Context) bool

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

func (*GameGroupBy) Bools

func (ggb *GameGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*GameGroupBy) BoolsX

func (ggb *GameGroupBy) BoolsX(ctx context.Context) []bool

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

func (*GameGroupBy) Float64

func (ggb *GameGroupBy) Float64(ctx context.Context) (_ float64, err error)

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

func (*GameGroupBy) Float64X

func (ggb *GameGroupBy) Float64X(ctx context.Context) float64

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

func (*GameGroupBy) Float64s

func (ggb *GameGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*GameGroupBy) Float64sX

func (ggb *GameGroupBy) Float64sX(ctx context.Context) []float64

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

func (*GameGroupBy) Int

func (ggb *GameGroupBy) Int(ctx context.Context) (_ int, err error)

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

func (*GameGroupBy) IntX

func (ggb *GameGroupBy) IntX(ctx context.Context) int

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

func (*GameGroupBy) Ints

func (ggb *GameGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*GameGroupBy) IntsX

func (ggb *GameGroupBy) IntsX(ctx context.Context) []int

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

func (*GameGroupBy) Scan

func (ggb *GameGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*GameGroupBy) ScanX

func (ggb *GameGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*GameGroupBy) String

func (ggb *GameGroupBy) String(ctx context.Context) (_ string, err error)

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

func (*GameGroupBy) StringX

func (ggb *GameGroupBy) StringX(ctx context.Context) string

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

func (*GameGroupBy) Strings

func (ggb *GameGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*GameGroupBy) StringsX

func (ggb *GameGroupBy) StringsX(ctx context.Context) []string

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

type GameMutation

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

GameMutation represents an operation that mutates the Game nodes in the graph.

func (*GameMutation) AddCount

func (m *GameMutation) AddCount(i int64)

AddCount adds i to the "count" field.

func (*GameMutation) AddField

func (m *GameMutation) 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 (*GameMutation) AddedCount

func (m *GameMutation) AddedCount() (r int64, exists bool)

AddedCount returns the value that was added to the "count" field in this mutation.

func (*GameMutation) AddedEdges

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

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

func (*GameMutation) AddedField

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

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

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

func (*GameMutation) AddedIDs

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

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

func (*GameMutation) ClearEdge

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

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

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

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

func (*GameMutation) ClearedFields

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

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

func (GameMutation) Client

func (m GameMutation) 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 (*GameMutation) Count

func (m *GameMutation) Count() (r int64, exists bool)

Count returns the value of the "count" field in the mutation.

func (*GameMutation) CreatedAt

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

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

func (*GameMutation) Description

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

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

func (*GameMutation) EdgeCleared

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

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

func (*GameMutation) Field

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

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

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

func (*GameMutation) Fields

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

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

func (m *GameMutation) IDs(ctx context.Context) ([]int64, 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 (*GameMutation) Name

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

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

func (*GameMutation) OldCount

func (m *GameMutation) OldCount(ctx context.Context) (v int64, err error)

OldCount returns the old "count" field's value of the Game entity. If the Game 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 (*GameMutation) OldCreatedAt

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

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

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

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

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

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

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

func (m *GameMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error)

OldUpdatedAt returns the old "updated_at" field's value of the Game entity. If the Game 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 (*GameMutation) Op

func (m *GameMutation) Op() Op

Op returns the operation name.

func (*GameMutation) RemovedEdges

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

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

func (*GameMutation) RemovedIDs

func (m *GameMutation) 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 (*GameMutation) ResetCount

func (m *GameMutation) ResetCount()

ResetCount resets all changes to the "count" field.

func (*GameMutation) ResetCreatedAt

func (m *GameMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*GameMutation) ResetDescription

func (m *GameMutation) ResetDescription()

ResetDescription resets all changes to the "description" field.

func (*GameMutation) ResetEdge

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

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

func (m *GameMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*GameMutation) ResetUpdatedAt

func (m *GameMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*GameMutation) SetCount

func (m *GameMutation) SetCount(i int64)

SetCount sets the "count" field.

func (*GameMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*GameMutation) SetDescription

func (m *GameMutation) SetDescription(s string)

SetDescription sets the "description" field.

func (*GameMutation) SetField

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

func (m *GameMutation) SetID(id int64)

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

func (*GameMutation) SetName

func (m *GameMutation) SetName(s string)

SetName sets the "name" field.

func (*GameMutation) SetUpdatedAt

func (m *GameMutation) SetUpdatedAt(t time.Time)

SetUpdatedAt sets the "updated_at" field.

func (GameMutation) Tx

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

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

func (*GameMutation) Type

func (m *GameMutation) Type() string

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

func (*GameMutation) UpdatedAt

func (m *GameMutation) UpdatedAt() (r time.Time, exists bool)

UpdatedAt returns the value of the "updated_at" field in the mutation.

func (*GameMutation) Where

func (m *GameMutation) Where(ps ...predicate.Game)

Where appends a list predicates to the GameMutation builder.

type GameQuery

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

GameQuery is the builder for querying Game entities.

func (*GameQuery) All

func (gq *GameQuery) All(ctx context.Context) ([]*Game, error)

All executes the query and returns a list of Games.

func (*GameQuery) AllX

func (gq *GameQuery) AllX(ctx context.Context) []*Game

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

func (*GameQuery) Clone

func (gq *GameQuery) Clone() *GameQuery

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

func (*GameQuery) Count

func (gq *GameQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*GameQuery) CountX

func (gq *GameQuery) CountX(ctx context.Context) int

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

func (*GameQuery) Exist

func (gq *GameQuery) Exist(ctx context.Context) (bool, error)

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

func (*GameQuery) ExistX

func (gq *GameQuery) ExistX(ctx context.Context) bool

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

func (*GameQuery) First

func (gq *GameQuery) First(ctx context.Context) (*Game, error)

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

func (*GameQuery) FirstID

func (gq *GameQuery) FirstID(ctx context.Context) (id int64, err error)

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

func (*GameQuery) FirstIDX

func (gq *GameQuery) FirstIDX(ctx context.Context) int64

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

func (*GameQuery) FirstX

func (gq *GameQuery) FirstX(ctx context.Context) *Game

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

func (*GameQuery) GroupBy

func (gq *GameQuery) GroupBy(field string, fields ...string) *GameGroupBy

GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Game.Query().
	GroupBy(game.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*GameQuery) IDs

func (gq *GameQuery) IDs(ctx context.Context) ([]int64, error)

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

func (*GameQuery) IDsX

func (gq *GameQuery) IDsX(ctx context.Context) []int64

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

func (*GameQuery) Limit

func (gq *GameQuery) Limit(limit int) *GameQuery

Limit adds a limit step to the query.

func (*GameQuery) Offset

func (gq *GameQuery) Offset(offset int) *GameQuery

Offset adds an offset step to the query.

func (*GameQuery) Only

func (gq *GameQuery) Only(ctx context.Context) (*Game, error)

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

func (*GameQuery) OnlyID

func (gq *GameQuery) OnlyID(ctx context.Context) (id int64, err error)

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

func (*GameQuery) OnlyIDX

func (gq *GameQuery) OnlyIDX(ctx context.Context) int64

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

func (*GameQuery) OnlyX

func (gq *GameQuery) OnlyX(ctx context.Context) *Game

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

func (*GameQuery) Order

func (gq *GameQuery) Order(o ...OrderFunc) *GameQuery

Order adds an order step to the query.

func (*GameQuery) Select

func (gq *GameQuery) Select(fields ...string) *GameSelect

Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
}

client.Game.Query().
	Select(game.FieldName).
	Scan(ctx, &v)

func (*GameQuery) Unique

func (gq *GameQuery) Unique(unique bool) *GameQuery

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

func (gq *GameQuery) Where(ps ...predicate.Game) *GameQuery

Where adds a new predicate for the GameQuery builder.

type GameSelect

type GameSelect struct {
	*GameQuery
	// contains filtered or unexported fields
}

GameSelect is the builder for selecting fields of Game entities.

func (*GameSelect) Bool

func (gs *GameSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*GameSelect) BoolX

func (gs *GameSelect) BoolX(ctx context.Context) bool

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

func (*GameSelect) Bools

func (gs *GameSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*GameSelect) BoolsX

func (gs *GameSelect) BoolsX(ctx context.Context) []bool

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

func (*GameSelect) Float64

func (gs *GameSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*GameSelect) Float64X

func (gs *GameSelect) Float64X(ctx context.Context) float64

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

func (*GameSelect) Float64s

func (gs *GameSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*GameSelect) Float64sX

func (gs *GameSelect) Float64sX(ctx context.Context) []float64

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

func (*GameSelect) Int

func (gs *GameSelect) Int(ctx context.Context) (_ int, err error)

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

func (*GameSelect) IntX

func (gs *GameSelect) IntX(ctx context.Context) int

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

func (*GameSelect) Ints

func (gs *GameSelect) Ints(ctx context.Context) ([]int, error)

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

func (*GameSelect) IntsX

func (gs *GameSelect) IntsX(ctx context.Context) []int

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

func (*GameSelect) Scan

func (gs *GameSelect) Scan(ctx context.Context, v interface{}) error

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

func (*GameSelect) ScanX

func (gs *GameSelect) ScanX(ctx context.Context, v interface{})

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

func (*GameSelect) String

func (gs *GameSelect) String(ctx context.Context) (_ string, err error)

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

func (*GameSelect) StringX

func (gs *GameSelect) StringX(ctx context.Context) string

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

func (*GameSelect) Strings

func (gs *GameSelect) Strings(ctx context.Context) ([]string, error)

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

func (*GameSelect) StringsX

func (gs *GameSelect) StringsX(ctx context.Context) []string

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

type GameUpdate

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

GameUpdate is the builder for updating Game entities.

func (*GameUpdate) AddCount

func (gu *GameUpdate) AddCount(i int64) *GameUpdate

AddCount adds i to the "count" field.

func (*GameUpdate) Exec

func (gu *GameUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*GameUpdate) ExecX

func (gu *GameUpdate) ExecX(ctx context.Context)

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

func (*GameUpdate) Mutation

func (gu *GameUpdate) Mutation() *GameMutation

Mutation returns the GameMutation object of the builder.

func (*GameUpdate) Save

func (gu *GameUpdate) Save(ctx context.Context) (int, error)

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

func (*GameUpdate) SaveX

func (gu *GameUpdate) SaveX(ctx context.Context) int

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

func (*GameUpdate) SetCount

func (gu *GameUpdate) SetCount(i int64) *GameUpdate

SetCount sets the "count" field.

func (*GameUpdate) SetCreatedAt

func (gu *GameUpdate) SetCreatedAt(t time.Time) *GameUpdate

SetCreatedAt sets the "created_at" field.

func (*GameUpdate) SetDescription

func (gu *GameUpdate) SetDescription(s string) *GameUpdate

SetDescription sets the "description" field.

func (*GameUpdate) SetName

func (gu *GameUpdate) SetName(s string) *GameUpdate

SetName sets the "name" field.

func (*GameUpdate) SetNillableCreatedAt

func (gu *GameUpdate) SetNillableCreatedAt(t *time.Time) *GameUpdate

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

func (*GameUpdate) SetNillableUpdatedAt

func (gu *GameUpdate) SetNillableUpdatedAt(t *time.Time) *GameUpdate

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (*GameUpdate) SetUpdatedAt

func (gu *GameUpdate) SetUpdatedAt(t time.Time) *GameUpdate

SetUpdatedAt sets the "updated_at" field.

func (*GameUpdate) Where

func (gu *GameUpdate) Where(ps ...predicate.Game) *GameUpdate

Where appends a list predicates to the GameUpdate builder.

type GameUpdateOne

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

GameUpdateOne is the builder for updating a single Game entity.

func (*GameUpdateOne) AddCount

func (guo *GameUpdateOne) AddCount(i int64) *GameUpdateOne

AddCount adds i to the "count" field.

func (*GameUpdateOne) Exec

func (guo *GameUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*GameUpdateOne) ExecX

func (guo *GameUpdateOne) ExecX(ctx context.Context)

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

func (*GameUpdateOne) Mutation

func (guo *GameUpdateOne) Mutation() *GameMutation

Mutation returns the GameMutation object of the builder.

func (*GameUpdateOne) Save

func (guo *GameUpdateOne) Save(ctx context.Context) (*Game, error)

Save executes the query and returns the updated Game entity.

func (*GameUpdateOne) SaveX

func (guo *GameUpdateOne) SaveX(ctx context.Context) *Game

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

func (*GameUpdateOne) Select

func (guo *GameUpdateOne) Select(field string, fields ...string) *GameUpdateOne

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

func (*GameUpdateOne) SetCount

func (guo *GameUpdateOne) SetCount(i int64) *GameUpdateOne

SetCount sets the "count" field.

func (*GameUpdateOne) SetCreatedAt

func (guo *GameUpdateOne) SetCreatedAt(t time.Time) *GameUpdateOne

SetCreatedAt sets the "created_at" field.

func (*GameUpdateOne) SetDescription

func (guo *GameUpdateOne) SetDescription(s string) *GameUpdateOne

SetDescription sets the "description" field.

func (*GameUpdateOne) SetName

func (guo *GameUpdateOne) SetName(s string) *GameUpdateOne

SetName sets the "name" field.

func (*GameUpdateOne) SetNillableCreatedAt

func (guo *GameUpdateOne) SetNillableCreatedAt(t *time.Time) *GameUpdateOne

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

func (*GameUpdateOne) SetNillableUpdatedAt

func (guo *GameUpdateOne) SetNillableUpdatedAt(t *time.Time) *GameUpdateOne

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (*GameUpdateOne) SetUpdatedAt

func (guo *GameUpdateOne) SetUpdatedAt(t time.Time) *GameUpdateOne

SetUpdatedAt sets the "updated_at" field.

type Games

type Games []*Game

Games is a parsable slice of Game.

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(...interface{})) Option

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

OrderFunc applies an ordering on the sql selector.

func Asc

func Asc(fields ...string) OrderFunc

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) OrderFunc

Desc applies the given fields in DESC order.

type Policy

type Policy = ent.Policy

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

type Query

type Query = ent.Query

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

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

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

type Tx struct {

	// Game is the client for interacting with the Game builders.
	Game *GameClient
	// contains filtered or unexported fields
}

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

func TxFromContext

func TxFromContext(ctx context.Context) *Tx

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

func (*Tx) Client

func (tx *Tx) Client() *Client

Client returns a Client that binds to current transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) OnCommit

func (tx *Tx) OnCommit(f CommitHook)

OnCommit adds a hook to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f RollbackHook)

OnRollback adds a hook to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

type ValidationError

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

ValidationError returns when validating a field or edge fails.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Value

type Value = ent.Value

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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