ent

package
v0.0.0-...-5192d11 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 16 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.
	TypeRegions = "Regions"
)

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
	// Regions is the client for interacting with the Regions builders.
	Regions *RegionsClient
	// 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().
	Regions.
	Query().
	Count(ctx)

func (*Client) Tx

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

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

func (*Client) Use

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

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

type CommitFunc

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

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

func (CommitFunc) Commit

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

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

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

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

type Committer

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

Committer is the interface that wraps the Commit method.

type ConstraintError

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

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

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

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

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

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

type NotFoundError

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

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

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

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

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

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

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

func Log(fn func(...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 Regions

type Regions struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// RegionName holds the value of the "region_name" field.
	RegionName string `json:"region_name,omitempty"`
	// contains filtered or unexported fields
}

Regions is the model entity for the Regions schema.

func (*Regions) String

func (r *Regions) String() string

String implements the fmt.Stringer.

func (*Regions) Unwrap

func (r *Regions) Unwrap() *Regions

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

func (r *Regions) Update() *RegionsUpdateOne

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

type RegionsClient

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

RegionsClient is a client for the Regions schema.

func NewRegionsClient

func NewRegionsClient(c config) *RegionsClient

NewRegionsClient returns a client for the Regions from the given config.

func (*RegionsClient) Create

func (c *RegionsClient) Create() *RegionsCreate

Create returns a create builder for Regions.

func (*RegionsClient) CreateBulk

func (c *RegionsClient) CreateBulk(builders ...*RegionsCreate) *RegionsCreateBulk

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

func (*RegionsClient) Delete

func (c *RegionsClient) Delete() *RegionsDelete

Delete returns a delete builder for Regions.

func (*RegionsClient) DeleteOne

func (c *RegionsClient) DeleteOne(r *Regions) *RegionsDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*RegionsClient) DeleteOneID

func (c *RegionsClient) DeleteOneID(id int) *RegionsDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*RegionsClient) Get

func (c *RegionsClient) Get(ctx context.Context, id int) (*Regions, error)

Get returns a Regions entity by its id.

func (*RegionsClient) GetX

func (c *RegionsClient) GetX(ctx context.Context, id int) *Regions

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

func (*RegionsClient) Hooks

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

Hooks returns the client hooks.

func (*RegionsClient) Query

func (c *RegionsClient) Query() *RegionsQuery

Query returns a query builder for Regions.

func (*RegionsClient) Update

func (c *RegionsClient) Update() *RegionsUpdate

Update returns an update builder for Regions.

func (*RegionsClient) UpdateOne

func (c *RegionsClient) UpdateOne(r *Regions) *RegionsUpdateOne

UpdateOne returns an update builder for the given entity.

func (*RegionsClient) UpdateOneID

func (c *RegionsClient) UpdateOneID(id int) *RegionsUpdateOne

UpdateOneID returns an update builder for the given id.

func (*RegionsClient) Use

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

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

type RegionsCreate

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

RegionsCreate is the builder for creating a Regions entity.

func (*RegionsCreate) Exec

func (rc *RegionsCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*RegionsCreate) ExecX

func (rc *RegionsCreate) ExecX(ctx context.Context)

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

func (*RegionsCreate) Mutation

func (rc *RegionsCreate) Mutation() *RegionsMutation

Mutation returns the RegionsMutation object of the builder.

func (*RegionsCreate) Save

func (rc *RegionsCreate) Save(ctx context.Context) (*Regions, error)

Save creates the Regions in the database.

func (*RegionsCreate) SaveX

func (rc *RegionsCreate) SaveX(ctx context.Context) *Regions

SaveX calls Save and panics if Save returns an error.

func (*RegionsCreate) SetID

func (rc *RegionsCreate) SetID(i int) *RegionsCreate

SetID sets the "id" field.

func (*RegionsCreate) SetRegionName

func (rc *RegionsCreate) SetRegionName(s string) *RegionsCreate

SetRegionName sets the "region_name" field.

type RegionsCreateBulk

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

RegionsCreateBulk is the builder for creating many Regions entities in bulk.

func (*RegionsCreateBulk) Exec

func (rcb *RegionsCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*RegionsCreateBulk) ExecX

func (rcb *RegionsCreateBulk) ExecX(ctx context.Context)

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

func (*RegionsCreateBulk) Save

func (rcb *RegionsCreateBulk) Save(ctx context.Context) ([]*Regions, error)

Save creates the Regions entities in the database.

func (*RegionsCreateBulk) SaveX

func (rcb *RegionsCreateBulk) SaveX(ctx context.Context) []*Regions

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

type RegionsDelete

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

RegionsDelete is the builder for deleting a Regions entity.

func (*RegionsDelete) Exec

func (rd *RegionsDelete) Exec(ctx context.Context) (int, error)

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

func (*RegionsDelete) ExecX

func (rd *RegionsDelete) ExecX(ctx context.Context) int

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

func (*RegionsDelete) Where

func (rd *RegionsDelete) Where(ps ...predicate.Regions) *RegionsDelete

Where appends a list predicates to the RegionsDelete builder.

type RegionsDeleteOne

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

RegionsDeleteOne is the builder for deleting a single Regions entity.

func (*RegionsDeleteOne) Exec

func (rdo *RegionsDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*RegionsDeleteOne) ExecX

func (rdo *RegionsDeleteOne) ExecX(ctx context.Context)

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

type RegionsGroupBy

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

RegionsGroupBy is the group-by builder for Regions entities.

func (*RegionsGroupBy) Aggregate

func (rgb *RegionsGroupBy) Aggregate(fns ...AggregateFunc) *RegionsGroupBy

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

func (*RegionsGroupBy) Bool

func (rgb *RegionsGroupBy) 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 (*RegionsGroupBy) BoolX

func (rgb *RegionsGroupBy) BoolX(ctx context.Context) bool

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

func (*RegionsGroupBy) Bools

func (rgb *RegionsGroupBy) 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 (*RegionsGroupBy) BoolsX

func (rgb *RegionsGroupBy) BoolsX(ctx context.Context) []bool

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

func (*RegionsGroupBy) Float64

func (rgb *RegionsGroupBy) 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 (*RegionsGroupBy) Float64X

func (rgb *RegionsGroupBy) Float64X(ctx context.Context) float64

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

func (*RegionsGroupBy) Float64s

func (rgb *RegionsGroupBy) 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 (*RegionsGroupBy) Float64sX

func (rgb *RegionsGroupBy) Float64sX(ctx context.Context) []float64

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

func (*RegionsGroupBy) Int

func (rgb *RegionsGroupBy) 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 (*RegionsGroupBy) IntX

func (rgb *RegionsGroupBy) IntX(ctx context.Context) int

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

func (*RegionsGroupBy) Ints

func (rgb *RegionsGroupBy) 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 (*RegionsGroupBy) IntsX

func (rgb *RegionsGroupBy) IntsX(ctx context.Context) []int

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

func (*RegionsGroupBy) Scan

func (rgb *RegionsGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*RegionsGroupBy) ScanX

func (rgb *RegionsGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*RegionsGroupBy) String

func (rgb *RegionsGroupBy) 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 (*RegionsGroupBy) StringX

func (rgb *RegionsGroupBy) StringX(ctx context.Context) string

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

func (*RegionsGroupBy) Strings

func (rgb *RegionsGroupBy) 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 (*RegionsGroupBy) StringsX

func (rgb *RegionsGroupBy) StringsX(ctx context.Context) []string

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

type RegionsMutation

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

RegionsMutation represents an operation that mutates the Regions nodes in the graph.

func (*RegionsMutation) AddField

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

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

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

func (*RegionsMutation) AddedField

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

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

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

func (*RegionsMutation) AddedIDs

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

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

func (*RegionsMutation) ClearEdge

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

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

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

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

func (*RegionsMutation) ClearedFields

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

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

func (RegionsMutation) Client

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

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

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

func (*RegionsMutation) Field

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

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

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

func (*RegionsMutation) Fields

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

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

ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder or after it was returned from the database.

func (*RegionsMutation) IDs

func (m *RegionsMutation) IDs(ctx context.Context) ([]int, error)

IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.

func (*RegionsMutation) OldField

func (m *RegionsMutation) 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 (*RegionsMutation) OldRegionName

func (m *RegionsMutation) OldRegionName(ctx context.Context) (v string, err error)

OldRegionName returns the old "region_name" field's value of the Regions entity. If the Regions 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 (*RegionsMutation) Op

func (m *RegionsMutation) Op() Op

Op returns the operation name.

func (*RegionsMutation) RegionName

func (m *RegionsMutation) RegionName() (r string, exists bool)

RegionName returns the value of the "region_name" field in the mutation.

func (*RegionsMutation) RemovedEdges

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

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

func (*RegionsMutation) RemovedIDs

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

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

func (m *RegionsMutation) 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 (*RegionsMutation) ResetRegionName

func (m *RegionsMutation) ResetRegionName()

ResetRegionName resets all changes to the "region_name" field.

func (*RegionsMutation) SetField

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

func (m *RegionsMutation) SetID(id int)

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

func (*RegionsMutation) SetRegionName

func (m *RegionsMutation) SetRegionName(s string)

SetRegionName sets the "region_name" field.

func (RegionsMutation) Tx

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

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

func (*RegionsMutation) Type

func (m *RegionsMutation) Type() string

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

func (*RegionsMutation) Where

func (m *RegionsMutation) Where(ps ...predicate.Regions)

Where appends a list predicates to the RegionsMutation builder.

type RegionsQuery

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

RegionsQuery is the builder for querying Regions entities.

func (*RegionsQuery) All

func (rq *RegionsQuery) All(ctx context.Context) ([]*Regions, error)

All executes the query and returns a list of RegionsSlice.

func (*RegionsQuery) AllX

func (rq *RegionsQuery) AllX(ctx context.Context) []*Regions

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

func (*RegionsQuery) Clone

func (rq *RegionsQuery) Clone() *RegionsQuery

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

func (*RegionsQuery) Count

func (rq *RegionsQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*RegionsQuery) CountX

func (rq *RegionsQuery) CountX(ctx context.Context) int

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

func (*RegionsQuery) Exist

func (rq *RegionsQuery) Exist(ctx context.Context) (bool, error)

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

func (*RegionsQuery) ExistX

func (rq *RegionsQuery) ExistX(ctx context.Context) bool

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

func (*RegionsQuery) First

func (rq *RegionsQuery) First(ctx context.Context) (*Regions, error)

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

func (*RegionsQuery) FirstID

func (rq *RegionsQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*RegionsQuery) FirstIDX

func (rq *RegionsQuery) FirstIDX(ctx context.Context) int

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

func (*RegionsQuery) FirstX

func (rq *RegionsQuery) FirstX(ctx context.Context) *Regions

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

func (*RegionsQuery) GroupBy

func (rq *RegionsQuery) GroupBy(field string, fields ...string) *RegionsGroupBy

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

client.Regions.Query().
	GroupBy(regions.FieldRegionName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*RegionsQuery) IDs

func (rq *RegionsQuery) IDs(ctx context.Context) ([]int, error)

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

func (*RegionsQuery) IDsX

func (rq *RegionsQuery) IDsX(ctx context.Context) []int

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

func (*RegionsQuery) Limit

func (rq *RegionsQuery) Limit(limit int) *RegionsQuery

Limit adds a limit step to the query.

func (*RegionsQuery) Offset

func (rq *RegionsQuery) Offset(offset int) *RegionsQuery

Offset adds an offset step to the query.

func (*RegionsQuery) Only

func (rq *RegionsQuery) Only(ctx context.Context) (*Regions, error)

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

func (*RegionsQuery) OnlyID

func (rq *RegionsQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*RegionsQuery) OnlyIDX

func (rq *RegionsQuery) OnlyIDX(ctx context.Context) int

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

func (*RegionsQuery) OnlyX

func (rq *RegionsQuery) OnlyX(ctx context.Context) *Regions

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

func (*RegionsQuery) Order

func (rq *RegionsQuery) Order(o ...OrderFunc) *RegionsQuery

Order adds an order step to the query.

func (*RegionsQuery) Select

func (rq *RegionsQuery) Select(fields ...string) *RegionsSelect

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

client.Regions.Query().
	Select(regions.FieldRegionName).
	Scan(ctx, &v)

func (*RegionsQuery) Unique

func (rq *RegionsQuery) Unique(unique bool) *RegionsQuery

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

func (rq *RegionsQuery) Where(ps ...predicate.Regions) *RegionsQuery

Where adds a new predicate for the RegionsQuery builder.

type RegionsSelect

type RegionsSelect struct {
	*RegionsQuery
	// contains filtered or unexported fields
}

RegionsSelect is the builder for selecting fields of Regions entities.

func (*RegionsSelect) Bool

func (rs *RegionsSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*RegionsSelect) BoolX

func (rs *RegionsSelect) BoolX(ctx context.Context) bool

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

func (*RegionsSelect) Bools

func (rs *RegionsSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*RegionsSelect) BoolsX

func (rs *RegionsSelect) BoolsX(ctx context.Context) []bool

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

func (*RegionsSelect) Float64

func (rs *RegionsSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*RegionsSelect) Float64X

func (rs *RegionsSelect) Float64X(ctx context.Context) float64

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

func (*RegionsSelect) Float64s

func (rs *RegionsSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*RegionsSelect) Float64sX

func (rs *RegionsSelect) Float64sX(ctx context.Context) []float64

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

func (*RegionsSelect) Int

func (rs *RegionsSelect) Int(ctx context.Context) (_ int, err error)

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

func (*RegionsSelect) IntX

func (rs *RegionsSelect) IntX(ctx context.Context) int

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

func (*RegionsSelect) Ints

func (rs *RegionsSelect) Ints(ctx context.Context) ([]int, error)

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

func (*RegionsSelect) IntsX

func (rs *RegionsSelect) IntsX(ctx context.Context) []int

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

func (*RegionsSelect) Scan

func (rs *RegionsSelect) Scan(ctx context.Context, v interface{}) error

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

func (*RegionsSelect) ScanX

func (rs *RegionsSelect) ScanX(ctx context.Context, v interface{})

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

func (*RegionsSelect) String

func (rs *RegionsSelect) String(ctx context.Context) (_ string, err error)

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

func (*RegionsSelect) StringX

func (rs *RegionsSelect) StringX(ctx context.Context) string

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

func (*RegionsSelect) Strings

func (rs *RegionsSelect) Strings(ctx context.Context) ([]string, error)

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

func (*RegionsSelect) StringsX

func (rs *RegionsSelect) StringsX(ctx context.Context) []string

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

type RegionsSlice

type RegionsSlice []*Regions

RegionsSlice is a parsable slice of Regions.

type RegionsUpdate

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

RegionsUpdate is the builder for updating Regions entities.

func (*RegionsUpdate) Exec

func (ru *RegionsUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*RegionsUpdate) ExecX

func (ru *RegionsUpdate) ExecX(ctx context.Context)

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

func (*RegionsUpdate) Mutation

func (ru *RegionsUpdate) Mutation() *RegionsMutation

Mutation returns the RegionsMutation object of the builder.

func (*RegionsUpdate) Save

func (ru *RegionsUpdate) Save(ctx context.Context) (int, error)

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

func (*RegionsUpdate) SaveX

func (ru *RegionsUpdate) SaveX(ctx context.Context) int

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

func (*RegionsUpdate) SetRegionName

func (ru *RegionsUpdate) SetRegionName(s string) *RegionsUpdate

SetRegionName sets the "region_name" field.

func (*RegionsUpdate) Where

func (ru *RegionsUpdate) Where(ps ...predicate.Regions) *RegionsUpdate

Where appends a list predicates to the RegionsUpdate builder.

type RegionsUpdateOne

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

RegionsUpdateOne is the builder for updating a single Regions entity.

func (*RegionsUpdateOne) Exec

func (ruo *RegionsUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*RegionsUpdateOne) ExecX

func (ruo *RegionsUpdateOne) ExecX(ctx context.Context)

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

func (*RegionsUpdateOne) Mutation

func (ruo *RegionsUpdateOne) Mutation() *RegionsMutation

Mutation returns the RegionsMutation object of the builder.

func (*RegionsUpdateOne) Save

func (ruo *RegionsUpdateOne) Save(ctx context.Context) (*Regions, error)

Save executes the query and returns the updated Regions entity.

func (*RegionsUpdateOne) SaveX

func (ruo *RegionsUpdateOne) SaveX(ctx context.Context) *Regions

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

func (*RegionsUpdateOne) Select

func (ruo *RegionsUpdateOne) Select(field string, fields ...string) *RegionsUpdateOne

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

func (*RegionsUpdateOne) SetRegionName

func (ruo *RegionsUpdateOne) SetRegionName(s string) *RegionsUpdateOne

SetRegionName sets the "region_name" field.

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 {

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