ent

package
v0.0.0-...-6bfc58f Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 15 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.
	TypeTokens = "Tokens"
)

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 validaton error.

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks nor 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 Client 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
	// Tokens is the client for interacting with the Tokens builders.
	Tokens *TokensClient
	// contains filtered or unexported fields
}

Client is the client that holds all ent builders.

func FromContext

func FromContext(ctx context.Context) *Client

FromContext returns the Client stored in 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 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().
	Tokens.
	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(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 Committer 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 conflict in user's code.

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

ent aliases to avoid import conflict 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 conflict 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 either graph traversal or 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 conflict in user's code.

type Query

type Query = ent.Query

ent aliases to avoid import conflict 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(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 Rollbacker method.

type Tokens

type Tokens struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Provider holds the value of the "provider" field.
	Provider string `json:"provider,omitempty"`
	// User holds the value of the "user" field.
	User string `json:"user,omitempty"`
	// Token holds the value of the "token" field.
	Token string `json:"token,omitempty"`
	// contains filtered or unexported fields
}

Tokens is the model entity for the Tokens schema.

func (*Tokens) String

func (t *Tokens) String() string

String implements the fmt.Stringer.

func (*Tokens) Unwrap

func (t *Tokens) Unwrap() *Tokens

Unwrap unwraps the entity that was returned from a transaction after it was closed, so that all next queries will be executed through the driver which created the transaction.

func (*Tokens) Update

func (t *Tokens) Update() *TokensUpdateOne

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

type TokensClient

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

TokensClient is a client for the Tokens schema.

func NewTokensClient

func NewTokensClient(c config) *TokensClient

NewTokensClient returns a client for the Tokens from the given config.

func (*TokensClient) Create

func (c *TokensClient) Create() *TokensCreate

Create returns a create builder for Tokens.

func (*TokensClient) Delete

func (c *TokensClient) Delete() *TokensDelete

Delete returns a delete builder for Tokens.

func (*TokensClient) DeleteOne

func (c *TokensClient) DeleteOne(t *Tokens) *TokensDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*TokensClient) DeleteOneID

func (c *TokensClient) DeleteOneID(id int) *TokensDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*TokensClient) Get

func (c *TokensClient) Get(ctx context.Context, id int) (*Tokens, error)

Get returns a Tokens entity by its id.

func (*TokensClient) GetX

func (c *TokensClient) GetX(ctx context.Context, id int) *Tokens

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

func (*TokensClient) Hooks

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

Hooks returns the client hooks.

func (*TokensClient) Query

func (c *TokensClient) Query() *TokensQuery

Create returns a query builder for Tokens.

func (*TokensClient) Update

func (c *TokensClient) Update() *TokensUpdate

Update returns an update builder for Tokens.

func (*TokensClient) UpdateOne

func (c *TokensClient) UpdateOne(t *Tokens) *TokensUpdateOne

UpdateOne returns an update builder for the given entity.

func (*TokensClient) UpdateOneID

func (c *TokensClient) UpdateOneID(id int) *TokensUpdateOne

UpdateOneID returns an update builder for the given id.

func (*TokensClient) Use

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

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

type TokensCreate

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

TokensCreate is the builder for creating a Tokens entity.

func (*TokensCreate) Mutation

func (tc *TokensCreate) Mutation() *TokensMutation

Mutation returns the TokensMutation object of the builder.

func (*TokensCreate) Save

func (tc *TokensCreate) Save(ctx context.Context) (*Tokens, error)

Save creates the Tokens in the database.

func (*TokensCreate) SaveX

func (tc *TokensCreate) SaveX(ctx context.Context) *Tokens

SaveX calls Save and panics if Save returns an error.

func (*TokensCreate) SetProvider

func (tc *TokensCreate) SetProvider(s string) *TokensCreate

SetProvider sets the provider field.

func (*TokensCreate) SetToken

func (tc *TokensCreate) SetToken(s string) *TokensCreate

SetToken sets the token field.

func (*TokensCreate) SetUser

func (tc *TokensCreate) SetUser(s string) *TokensCreate

SetUser sets the user field.

type TokensDelete

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

TokensDelete is the builder for deleting a Tokens entity.

func (*TokensDelete) Exec

func (td *TokensDelete) Exec(ctx context.Context) (int, error)

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

func (*TokensDelete) ExecX

func (td *TokensDelete) ExecX(ctx context.Context) int

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

func (*TokensDelete) Where

func (td *TokensDelete) Where(ps ...predicate.Tokens) *TokensDelete

Where adds a new predicate to the delete builder.

type TokensDeleteOne

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

TokensDeleteOne is the builder for deleting a single Tokens entity.

func (*TokensDeleteOne) Exec

func (tdo *TokensDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*TokensDeleteOne) ExecX

func (tdo *TokensDeleteOne) ExecX(ctx context.Context)

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

type TokensGroupBy

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

TokensGroupBy is the builder for group-by Tokens entities.

func (*TokensGroupBy) Aggregate

func (tgb *TokensGroupBy) Aggregate(fns ...AggregateFunc) *TokensGroupBy

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

func (*TokensGroupBy) Bool

func (tgb *TokensGroupBy) Bool(ctx context.Context) (_ bool, err error)

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

func (*TokensGroupBy) BoolX

func (tgb *TokensGroupBy) BoolX(ctx context.Context) bool

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

func (*TokensGroupBy) Bools

func (tgb *TokensGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*TokensGroupBy) BoolsX

func (tgb *TokensGroupBy) BoolsX(ctx context.Context) []bool

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

func (*TokensGroupBy) Float64

func (tgb *TokensGroupBy) Float64(ctx context.Context) (_ float64, err error)

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

func (*TokensGroupBy) Float64X

func (tgb *TokensGroupBy) Float64X(ctx context.Context) float64

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

func (*TokensGroupBy) Float64s

func (tgb *TokensGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*TokensGroupBy) Float64sX

func (tgb *TokensGroupBy) Float64sX(ctx context.Context) []float64

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

func (*TokensGroupBy) Int

func (tgb *TokensGroupBy) Int(ctx context.Context) (_ int, err error)

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

func (*TokensGroupBy) IntX

func (tgb *TokensGroupBy) IntX(ctx context.Context) int

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

func (*TokensGroupBy) Ints

func (tgb *TokensGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*TokensGroupBy) IntsX

func (tgb *TokensGroupBy) IntsX(ctx context.Context) []int

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

func (*TokensGroupBy) Scan

func (tgb *TokensGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*TokensGroupBy) ScanX

func (tgb *TokensGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*TokensGroupBy) String

func (tgb *TokensGroupBy) String(ctx context.Context) (_ string, err error)

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

func (*TokensGroupBy) StringX

func (tgb *TokensGroupBy) StringX(ctx context.Context) string

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

func (*TokensGroupBy) Strings

func (tgb *TokensGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*TokensGroupBy) StringsX

func (tgb *TokensGroupBy) StringsX(ctx context.Context) []string

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

type TokensMutation

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

TokensMutation represents an operation that mutate the TokensSlice nodes in the graph.

func (*TokensMutation) AddField

func (m *TokensMutation) AddField(name string, value ent.Value) error

AddField adds the value for the given name. It returns an error if the field is not defined in the schema, or if the type mismatch the field type.

func (*TokensMutation) AddedEdges

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

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

func (*TokensMutation) AddedField

func (m *TokensMutation) AddedField(name string) (ent.Value, bool)

AddedField returns the numeric value that was in/decremented from a field with the given name. The second value indicates that this field was not set, or was not define in the schema.

func (*TokensMutation) AddedFields

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

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

func (*TokensMutation) AddedIDs

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

AddedIDs returns all ids (to other nodes) that were added for the given edge name.

func (*TokensMutation) ClearEdge

func (m *TokensMutation) ClearEdge(name string) error

ClearEdge clears the value for the given name. It returns an error if the edge name is not defined in the schema.

func (*TokensMutation) ClearField

func (m *TokensMutation) ClearField(name string) error

ClearField clears the value for the given name. It returns an error if the field is not defined in the schema.

func (*TokensMutation) ClearedEdges

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

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

func (*TokensMutation) ClearedFields

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

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

func (TokensMutation) Client

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

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

EdgeCleared returns a boolean indicates if this edge was cleared in this mutation.

func (*TokensMutation) Field

func (m *TokensMutation) Field(name string) (ent.Value, bool)

Field returns the value of a field with the given name. The second boolean value indicates that this field was not set, or was not define in the schema.

func (*TokensMutation) FieldCleared

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

FieldCleared returns a boolean indicates if this field was cleared in this mutation.

func (*TokensMutation) Fields

func (m *TokensMutation) Fields() []string

Fields returns all fields that were changed during this mutation. Note that, in order to get all numeric fields that were in/decremented, call AddedFields().

func (*TokensMutation) ID

func (m *TokensMutation) ID() (id int, exists bool)

ID returns the id value in the mutation. Note that, the id is available only if it was provided to the builder.

func (*TokensMutation) OldField

func (m *TokensMutation) 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 was failed.

func (*TokensMutation) OldProvider

func (m *TokensMutation) OldProvider(ctx context.Context) (v string, err error)

OldProvider returns the old provider value of the Tokens. If the Tokens 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 database query fails.

func (*TokensMutation) OldToken

func (m *TokensMutation) OldToken(ctx context.Context) (v string, err error)

OldToken returns the old token value of the Tokens. If the Tokens 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 database query fails.

func (*TokensMutation) OldUser

func (m *TokensMutation) OldUser(ctx context.Context) (v string, err error)

OldUser returns the old user value of the Tokens. If the Tokens 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 database query fails.

func (*TokensMutation) Op

func (m *TokensMutation) Op() Op

Op returns the operation name.

func (*TokensMutation) Provider

func (m *TokensMutation) Provider() (r string, exists bool)

Provider returns the provider value in the mutation.

func (*TokensMutation) RemovedEdges

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

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

func (*TokensMutation) RemovedIDs

func (m *TokensMutation) RemovedIDs(name string) []ent.Value

RemovedIDs returns all ids (to other nodes) that were removed for the given edge name.

func (*TokensMutation) ResetEdge

func (m *TokensMutation) ResetEdge(name string) error

ResetEdge resets all changes in the mutation regarding the given edge name. It returns an error if the edge is not defined in the schema.

func (*TokensMutation) ResetField

func (m *TokensMutation) ResetField(name string) error

ResetField resets all changes in the mutation regarding the given field name. It returns an error if the field is not defined in the schema.

func (*TokensMutation) ResetProvider

func (m *TokensMutation) ResetProvider()

ResetProvider reset all changes of the "provider" field.

func (*TokensMutation) ResetToken

func (m *TokensMutation) ResetToken()

ResetToken reset all changes of the "token" field.

func (*TokensMutation) ResetUser

func (m *TokensMutation) ResetUser()

ResetUser reset all changes of the "user" field.

func (*TokensMutation) SetField

func (m *TokensMutation) SetField(name string, value ent.Value) error

SetField sets the value for the given name. It returns an error if the field is not defined in the schema, or if the type mismatch the field type.

func (*TokensMutation) SetProvider

func (m *TokensMutation) SetProvider(s string)

SetProvider sets the provider field.

func (*TokensMutation) SetToken

func (m *TokensMutation) SetToken(s string)

SetToken sets the token field.

func (*TokensMutation) SetUser

func (m *TokensMutation) SetUser(s string)

SetUser sets the user field.

func (*TokensMutation) Token

func (m *TokensMutation) Token() (r string, exists bool)

Token returns the token value in the mutation.

func (TokensMutation) Tx

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

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

func (*TokensMutation) Type

func (m *TokensMutation) Type() string

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

func (*TokensMutation) User

func (m *TokensMutation) User() (r string, exists bool)

User returns the user value in the mutation.

type TokensQuery

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

TokensQuery is the builder for querying Tokens entities.

func (*TokensQuery) All

func (tq *TokensQuery) All(ctx context.Context) ([]*Tokens, error)

All executes the query and returns a list of TokensSlice.

func (*TokensQuery) AllX

func (tq *TokensQuery) AllX(ctx context.Context) []*Tokens

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

func (*TokensQuery) Clone

func (tq *TokensQuery) Clone() *TokensQuery

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

func (*TokensQuery) Count

func (tq *TokensQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*TokensQuery) CountX

func (tq *TokensQuery) CountX(ctx context.Context) int

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

func (*TokensQuery) Exist

func (tq *TokensQuery) Exist(ctx context.Context) (bool, error)

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

func (*TokensQuery) ExistX

func (tq *TokensQuery) ExistX(ctx context.Context) bool

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

func (*TokensQuery) First

func (tq *TokensQuery) First(ctx context.Context) (*Tokens, error)

First returns the first Tokens entity in the query. Returns *NotFoundError when no tokens was found.

func (*TokensQuery) FirstID

func (tq *TokensQuery) FirstID(ctx context.Context) (id int, err error)

FirstID returns the first Tokens id in the query. Returns *NotFoundError when no id was found.

func (*TokensQuery) FirstX

func (tq *TokensQuery) FirstX(ctx context.Context) *Tokens

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

func (*TokensQuery) FirstXID

func (tq *TokensQuery) FirstXID(ctx context.Context) int

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

func (*TokensQuery) GroupBy

func (tq *TokensQuery) GroupBy(field string, fields ...string) *TokensGroupBy

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

client.Tokens.Query().
	GroupBy(tokens.FieldProvider).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*TokensQuery) IDs

func (tq *TokensQuery) IDs(ctx context.Context) ([]int, error)

IDs executes the query and returns a list of Tokens ids.

func (*TokensQuery) IDsX

func (tq *TokensQuery) IDsX(ctx context.Context) []int

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

func (*TokensQuery) Limit

func (tq *TokensQuery) Limit(limit int) *TokensQuery

Limit adds a limit step to the query.

func (*TokensQuery) Offset

func (tq *TokensQuery) Offset(offset int) *TokensQuery

Offset adds an offset step to the query.

func (*TokensQuery) Only

func (tq *TokensQuery) Only(ctx context.Context) (*Tokens, error)

Only returns the only Tokens entity in the query, returns an error if not exactly one entity was returned.

func (*TokensQuery) OnlyID

func (tq *TokensQuery) OnlyID(ctx context.Context) (id int, err error)

OnlyID returns the only Tokens id in the query, returns an error if not exactly one id was returned.

func (*TokensQuery) OnlyIDX

func (tq *TokensQuery) OnlyIDX(ctx context.Context) int

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

func (*TokensQuery) OnlyX

func (tq *TokensQuery) OnlyX(ctx context.Context) *Tokens

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

func (*TokensQuery) Order

func (tq *TokensQuery) Order(o ...OrderFunc) *TokensQuery

Order adds an order step to the query.

func (*TokensQuery) Select

func (tq *TokensQuery) Select(field string, fields ...string) *TokensSelect

Select one or more fields from the given query.

Example:

var v []struct {
	Provider string `json:"provider,omitempty"`
}

client.Tokens.Query().
	Select(tokens.FieldProvider).
	Scan(ctx, &v)

func (*TokensQuery) Where

func (tq *TokensQuery) Where(ps ...predicate.Tokens) *TokensQuery

Where adds a new predicate for the builder.

type TokensSelect

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

TokensSelect is the builder for select fields of Tokens entities.

func (*TokensSelect) Bool

func (ts *TokensSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*TokensSelect) BoolX

func (ts *TokensSelect) BoolX(ctx context.Context) bool

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

func (*TokensSelect) Bools

func (ts *TokensSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*TokensSelect) BoolsX

func (ts *TokensSelect) BoolsX(ctx context.Context) []bool

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

func (*TokensSelect) Float64

func (ts *TokensSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*TokensSelect) Float64X

func (ts *TokensSelect) Float64X(ctx context.Context) float64

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

func (*TokensSelect) Float64s

func (ts *TokensSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*TokensSelect) Float64sX

func (ts *TokensSelect) Float64sX(ctx context.Context) []float64

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

func (*TokensSelect) Int

func (ts *TokensSelect) Int(ctx context.Context) (_ int, err error)

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

func (*TokensSelect) IntX

func (ts *TokensSelect) IntX(ctx context.Context) int

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

func (*TokensSelect) Ints

func (ts *TokensSelect) Ints(ctx context.Context) ([]int, error)

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

func (*TokensSelect) IntsX

func (ts *TokensSelect) IntsX(ctx context.Context) []int

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

func (*TokensSelect) Scan

func (ts *TokensSelect) Scan(ctx context.Context, v interface{}) error

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

func (*TokensSelect) ScanX

func (ts *TokensSelect) ScanX(ctx context.Context, v interface{})

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

func (*TokensSelect) String

func (ts *TokensSelect) String(ctx context.Context) (_ string, err error)

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

func (*TokensSelect) StringX

func (ts *TokensSelect) StringX(ctx context.Context) string

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

func (*TokensSelect) Strings

func (ts *TokensSelect) Strings(ctx context.Context) ([]string, error)

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

func (*TokensSelect) StringsX

func (ts *TokensSelect) StringsX(ctx context.Context) []string

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

type TokensSlice

type TokensSlice []*Tokens

TokensSlice is a parsable slice of Tokens.

type TokensUpdate

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

TokensUpdate is the builder for updating Tokens entities.

func (*TokensUpdate) Exec

func (tu *TokensUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*TokensUpdate) ExecX

func (tu *TokensUpdate) ExecX(ctx context.Context)

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

func (*TokensUpdate) Mutation

func (tu *TokensUpdate) Mutation() *TokensMutation

Mutation returns the TokensMutation object of the builder.

func (*TokensUpdate) Save

func (tu *TokensUpdate) Save(ctx context.Context) (int, error)

Save executes the query and returns the number of rows/vertices matched by this operation.

func (*TokensUpdate) SaveX

func (tu *TokensUpdate) SaveX(ctx context.Context) int

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

func (*TokensUpdate) SetProvider

func (tu *TokensUpdate) SetProvider(s string) *TokensUpdate

SetProvider sets the provider field.

func (*TokensUpdate) SetToken

func (tu *TokensUpdate) SetToken(s string) *TokensUpdate

SetToken sets the token field.

func (*TokensUpdate) SetUser

func (tu *TokensUpdate) SetUser(s string) *TokensUpdate

SetUser sets the user field.

func (*TokensUpdate) Where

func (tu *TokensUpdate) Where(ps ...predicate.Tokens) *TokensUpdate

Where adds a new predicate for the builder.

type TokensUpdateOne

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

TokensUpdateOne is the builder for updating a single Tokens entity.

func (*TokensUpdateOne) Exec

func (tuo *TokensUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*TokensUpdateOne) ExecX

func (tuo *TokensUpdateOne) ExecX(ctx context.Context)

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

func (*TokensUpdateOne) Mutation

func (tuo *TokensUpdateOne) Mutation() *TokensMutation

Mutation returns the TokensMutation object of the builder.

func (*TokensUpdateOne) Save

func (tuo *TokensUpdateOne) Save(ctx context.Context) (*Tokens, error)

Save executes the query and returns the updated entity.

func (*TokensUpdateOne) SaveX

func (tuo *TokensUpdateOne) SaveX(ctx context.Context) *Tokens

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

func (*TokensUpdateOne) SetProvider

func (tuo *TokensUpdateOne) SetProvider(s string) *TokensUpdateOne

SetProvider sets the provider field.

func (*TokensUpdateOne) SetToken

func (tuo *TokensUpdateOne) SetToken(s string) *TokensUpdateOne

SetToken sets the token field.

func (*TokensUpdateOne) SetUser

func (tuo *TokensUpdateOne) SetUser(s string) *TokensUpdateOne

SetUser sets the user field.

type Tx

type Tx struct {

	// Tokens is the client for interacting with the Tokens builders.
	Tokens *TokensClient
	// 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 the Tx stored in 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 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 conflict 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