ent

package
v0.1.5-0...-40e571d Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: Apache-2.0 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.
	TypeGalaxy = "Galaxy"
	TypePlanet = "Planet"
)

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 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 Aggregate

type Aggregate func(*sql.Selector) string

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

func As

func As(fn Aggregate, end string) Aggregate

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() Aggregate

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

func Max

func Max(field string) Aggregate

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

func Mean

func Mean(field string) Aggregate

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

func Min

func Min(field string) Aggregate

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

func Sum

func Sum(field string) Aggregate

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
	// Galaxy is the client for interacting with the Galaxy builders.
	Galaxy *GalaxyClient
	// Planet is the client for interacting with the Planet builders.
	Planet *PlanetClient
	// 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 connection to the database specified by the driver name and a driver-specific data source name, and returns a new client attached to it. Optional parameters can be added for configuring the client.

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().
	Galaxy.
	Query().
	Count(ctx)

func (*Client) Tx

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

Tx returns a new transactional client.

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 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 Galaxies

type Galaxies []*Galaxy

Galaxies is a parsable slice of Galaxy.

type Galaxy

type Galaxy struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Type holds the value of the "type" field.
	Type galaxy.Type `json:"type,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the GalaxyQuery when eager-loading is set.
	Edges GalaxyEdges `json:"edges"`
	// contains filtered or unexported fields
}

Galaxy is the model entity for the Galaxy schema.

func (*Galaxy) QueryPlanets

func (ga *Galaxy) QueryPlanets() *PlanetQuery

QueryPlanets queries the planets edge of the Galaxy.

func (*Galaxy) String

func (ga *Galaxy) String() string

String implements the fmt.Stringer.

func (*Galaxy) Unwrap

func (ga *Galaxy) Unwrap() *Galaxy

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 (*Galaxy) Update

func (ga *Galaxy) Update() *GalaxyUpdateOne

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

type GalaxyClient

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

GalaxyClient is a client for the Galaxy schema.

func NewGalaxyClient

func NewGalaxyClient(c config) *GalaxyClient

NewGalaxyClient returns a client for the Galaxy from the given config.

func (*GalaxyClient) Create

func (c *GalaxyClient) Create() *GalaxyCreate

Create returns a create builder for Galaxy.

func (*GalaxyClient) Delete

func (c *GalaxyClient) Delete() *GalaxyDelete

Delete returns a delete builder for Galaxy.

func (*GalaxyClient) DeleteOne

func (c *GalaxyClient) DeleteOne(ga *Galaxy) *GalaxyDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*GalaxyClient) DeleteOneID

func (c *GalaxyClient) DeleteOneID(id int) *GalaxyDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*GalaxyClient) Get

func (c *GalaxyClient) Get(ctx context.Context, id int) (*Galaxy, error)

Get returns a Galaxy entity by its id.

func (*GalaxyClient) GetX

func (c *GalaxyClient) GetX(ctx context.Context, id int) *Galaxy

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

func (*GalaxyClient) Hooks

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

Hooks returns the client hooks.

func (*GalaxyClient) Query

func (c *GalaxyClient) Query() *GalaxyQuery

Create returns a query builder for Galaxy.

func (*GalaxyClient) QueryPlanets

func (c *GalaxyClient) QueryPlanets(ga *Galaxy) *PlanetQuery

QueryPlanets queries the planets edge of a Galaxy.

func (*GalaxyClient) Update

func (c *GalaxyClient) Update() *GalaxyUpdate

Update returns an update builder for Galaxy.

func (*GalaxyClient) UpdateOne

func (c *GalaxyClient) UpdateOne(ga *Galaxy) *GalaxyUpdateOne

UpdateOne returns an update builder for the given entity.

func (*GalaxyClient) UpdateOneID

func (c *GalaxyClient) UpdateOneID(id int) *GalaxyUpdateOne

UpdateOneID returns an update builder for the given id.

func (*GalaxyClient) Use

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

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

type GalaxyCreate

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

GalaxyCreate is the builder for creating a Galaxy entity.

func (*GalaxyCreate) AddPlanetIDs

func (gc *GalaxyCreate) AddPlanetIDs(ids ...int) *GalaxyCreate

AddPlanetIDs adds the planets edge to Planet by ids.

func (*GalaxyCreate) AddPlanets

func (gc *GalaxyCreate) AddPlanets(p ...*Planet) *GalaxyCreate

AddPlanets adds the planets edges to Planet.

func (*GalaxyCreate) Save

func (gc *GalaxyCreate) Save(ctx context.Context) (*Galaxy, error)

Save creates the Galaxy in the database.

func (*GalaxyCreate) SaveX

func (gc *GalaxyCreate) SaveX(ctx context.Context) *Galaxy

SaveX calls Save and panics if Save returns an error.

func (*GalaxyCreate) SetName

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

SetName sets the name field.

func (*GalaxyCreate) SetType

func (gc *GalaxyCreate) SetType(ga galaxy.Type) *GalaxyCreate

SetType sets the type field.

type GalaxyDelete

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

GalaxyDelete is the builder for deleting a Galaxy entity.

func (*GalaxyDelete) Exec

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

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

func (*GalaxyDelete) ExecX

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

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

func (*GalaxyDelete) Where

func (gd *GalaxyDelete) Where(ps ...predicate.Galaxy) *GalaxyDelete

Where adds a new predicate to the delete builder.

type GalaxyDeleteOne

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

GalaxyDeleteOne is the builder for deleting a single Galaxy entity.

func (*GalaxyDeleteOne) Exec

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

Exec executes the deletion query.

func (*GalaxyDeleteOne) ExecX

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

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

type GalaxyEdges

type GalaxyEdges struct {
	// Planets holds the value of the planets edge.
	Planets []*Planet
	// contains filtered or unexported fields
}

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

func (GalaxyEdges) PlanetsOrErr

func (e GalaxyEdges) PlanetsOrErr() ([]*Planet, error)

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

type GalaxyGroupBy

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

GalaxyGroupBy is the builder for group-by Galaxy entities.

func (*GalaxyGroupBy) Aggregate

func (ggb *GalaxyGroupBy) Aggregate(fns ...Aggregate) *GalaxyGroupBy

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

func (*GalaxyGroupBy) Bools

func (ggb *GalaxyGroupBy) 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 (*GalaxyGroupBy) BoolsX

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

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

func (*GalaxyGroupBy) Float64s

func (ggb *GalaxyGroupBy) 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 (*GalaxyGroupBy) Float64sX

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

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

func (*GalaxyGroupBy) Ints

func (ggb *GalaxyGroupBy) 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 (*GalaxyGroupBy) IntsX

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

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

func (*GalaxyGroupBy) Scan

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

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

func (*GalaxyGroupBy) ScanX

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

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

func (*GalaxyGroupBy) Strings

func (ggb *GalaxyGroupBy) 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 (*GalaxyGroupBy) StringsX

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

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

type GalaxyMutation

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

GalaxyMutation represents an operation that mutate the Galaxies nodes in the graph.

func (*GalaxyMutation) AddField

func (m *GalaxyMutation) 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 (*GalaxyMutation) AddPlanetIDs

func (m *GalaxyMutation) AddPlanetIDs(ids ...int)

AddPlanetIDs adds the planets edge to Planet by ids.

func (*GalaxyMutation) AddedEdges

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

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

func (*GalaxyMutation) AddedField

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

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

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

func (*GalaxyMutation) AddedIDs

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

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

func (*GalaxyMutation) ClearEdge

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

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

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

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

func (*GalaxyMutation) ClearedFields

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

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

func (GalaxyMutation) Client

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

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

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

func (*GalaxyMutation) Field

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

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

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

func (*GalaxyMutation) Fields

func (m *GalaxyMutation) 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 (*GalaxyMutation) GetType

func (m *GalaxyMutation) GetType() (r galaxy.Type, exists bool)

GetType returns the type value in the mutation.

func (*GalaxyMutation) ID

func (m *GalaxyMutation) 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 (*GalaxyMutation) Name

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

Name returns the name value in the mutation.

func (*GalaxyMutation) Op

func (m *GalaxyMutation) Op() Op

Op returns the operation name.

func (*GalaxyMutation) PlanetsIDs

func (m *GalaxyMutation) PlanetsIDs() (ids []int)

PlanetsIDs returns the planets ids in the mutation.

func (*GalaxyMutation) RemovePlanetIDs

func (m *GalaxyMutation) RemovePlanetIDs(ids ...int)

RemovePlanetIDs removes the planets edge to Planet by ids.

func (*GalaxyMutation) RemovedEdges

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

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

func (*GalaxyMutation) RemovedIDs

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

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

func (*GalaxyMutation) RemovedPlanetsIDs

func (m *GalaxyMutation) RemovedPlanetsIDs() (ids []int)

RemovedPlanets returns the removed ids of planets.

func (*GalaxyMutation) ResetEdge

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

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

func (m *GalaxyMutation) ResetName()

ResetName reset all changes of the name field.

func (*GalaxyMutation) ResetPlanets

func (m *GalaxyMutation) ResetPlanets()

ResetPlanets reset all changes of the planets edge.

func (*GalaxyMutation) ResetType

func (m *GalaxyMutation) ResetType()

ResetType reset all changes of the type field.

func (*GalaxyMutation) SetField

func (m *GalaxyMutation) 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 (*GalaxyMutation) SetName

func (m *GalaxyMutation) SetName(s string)

SetName sets the name field.

func (*GalaxyMutation) SetType

func (m *GalaxyMutation) SetType(ga galaxy.Type)

SetType sets the type field.

func (GalaxyMutation) Tx

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

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

func (*GalaxyMutation) Type

func (m *GalaxyMutation) Type() string

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

type GalaxyQuery

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

GalaxyQuery is the builder for querying Galaxy entities.

func (*GalaxyQuery) All

func (gq *GalaxyQuery) All(ctx context.Context) ([]*Galaxy, error)

All executes the query and returns a list of Galaxies.

func (*GalaxyQuery) AllX

func (gq *GalaxyQuery) AllX(ctx context.Context) []*Galaxy

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

func (*GalaxyQuery) Clone

func (gq *GalaxyQuery) Clone() *GalaxyQuery

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 (*GalaxyQuery) Count

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

Count returns the count of the given query.

func (*GalaxyQuery) CountX

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

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

func (*GalaxyQuery) Exist

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

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

func (*GalaxyQuery) ExistX

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

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

func (*GalaxyQuery) First

func (gq *GalaxyQuery) First(ctx context.Context) (*Galaxy, error)

First returns the first Galaxy entity in the query. Returns *NotFoundError when no galaxy was found.

func (*GalaxyQuery) FirstID

func (gq *GalaxyQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*GalaxyQuery) FirstX

func (gq *GalaxyQuery) FirstX(ctx context.Context) *Galaxy

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

func (*GalaxyQuery) FirstXID

func (gq *GalaxyQuery) FirstXID(ctx context.Context) int

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

func (*GalaxyQuery) GroupBy

func (gq *GalaxyQuery) GroupBy(field string, fields ...string) *GalaxyGroupBy

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

client.Galaxy.Query().
	GroupBy(galaxy.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*GalaxyQuery) IDs

func (gq *GalaxyQuery) IDs(ctx context.Context) ([]int, error)

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

func (*GalaxyQuery) IDsX

func (gq *GalaxyQuery) IDsX(ctx context.Context) []int

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

func (*GalaxyQuery) Limit

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

Limit adds a limit step to the query.

func (*GalaxyQuery) Offset

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

Offset adds an offset step to the query.

func (*GalaxyQuery) Only

func (gq *GalaxyQuery) Only(ctx context.Context) (*Galaxy, error)

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

func (*GalaxyQuery) OnlyID

func (gq *GalaxyQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*GalaxyQuery) OnlyX

func (gq *GalaxyQuery) OnlyX(ctx context.Context) *Galaxy

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

func (*GalaxyQuery) OnlyXID

func (gq *GalaxyQuery) OnlyXID(ctx context.Context) int

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

func (*GalaxyQuery) Order

func (gq *GalaxyQuery) Order(o ...Order) *GalaxyQuery

Order adds an order step to the query.

func (*GalaxyQuery) QueryPlanets

func (gq *GalaxyQuery) QueryPlanets() *PlanetQuery

QueryPlanets chains the current query on the planets edge.

func (*GalaxyQuery) Select

func (gq *GalaxyQuery) Select(field string, fields ...string) *GalaxySelect

Select one or more fields from the given query.

Example:

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

client.Galaxy.Query().
	Select(galaxy.FieldName).
	Scan(ctx, &v)

func (*GalaxyQuery) Where

func (gq *GalaxyQuery) Where(ps ...predicate.Galaxy) *GalaxyQuery

Where adds a new predicate for the builder.

func (*GalaxyQuery) WithPlanets

func (gq *GalaxyQuery) WithPlanets(opts ...func(*PlanetQuery)) *GalaxyQuery
WithPlanets tells the query-builder to eager-loads the nodes that are connected to

the "planets" edge. The optional arguments used to configure the query builder of the edge.

type GalaxySelect

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

GalaxySelect is the builder for select fields of Galaxy entities.

func (*GalaxySelect) Bools

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

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

func (*GalaxySelect) BoolsX

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

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

func (*GalaxySelect) Float64s

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

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

func (*GalaxySelect) Float64sX

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

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

func (*GalaxySelect) Ints

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

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

func (*GalaxySelect) IntsX

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

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

func (*GalaxySelect) Scan

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

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

func (*GalaxySelect) ScanX

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

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

func (*GalaxySelect) Strings

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

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

func (*GalaxySelect) StringsX

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

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

type GalaxyUpdate

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

GalaxyUpdate is the builder for updating Galaxy entities.

func (*GalaxyUpdate) AddPlanetIDs

func (gu *GalaxyUpdate) AddPlanetIDs(ids ...int) *GalaxyUpdate

AddPlanetIDs adds the planets edge to Planet by ids.

func (*GalaxyUpdate) AddPlanets

func (gu *GalaxyUpdate) AddPlanets(p ...*Planet) *GalaxyUpdate

AddPlanets adds the planets edges to Planet.

func (*GalaxyUpdate) Exec

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

Exec executes the query.

func (*GalaxyUpdate) ExecX

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

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

func (*GalaxyUpdate) RemovePlanetIDs

func (gu *GalaxyUpdate) RemovePlanetIDs(ids ...int) *GalaxyUpdate

RemovePlanetIDs removes the planets edge to Planet by ids.

func (*GalaxyUpdate) RemovePlanets

func (gu *GalaxyUpdate) RemovePlanets(p ...*Planet) *GalaxyUpdate

RemovePlanets removes planets edges to Planet.

func (*GalaxyUpdate) Save

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

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

func (*GalaxyUpdate) SaveX

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

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

func (*GalaxyUpdate) SetName

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

SetName sets the name field.

func (*GalaxyUpdate) SetType

func (gu *GalaxyUpdate) SetType(ga galaxy.Type) *GalaxyUpdate

SetType sets the type field.

func (*GalaxyUpdate) Where

func (gu *GalaxyUpdate) Where(ps ...predicate.Galaxy) *GalaxyUpdate

Where adds a new predicate for the builder.

type GalaxyUpdateOne

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

GalaxyUpdateOne is the builder for updating a single Galaxy entity.

func (*GalaxyUpdateOne) AddPlanetIDs

func (guo *GalaxyUpdateOne) AddPlanetIDs(ids ...int) *GalaxyUpdateOne

AddPlanetIDs adds the planets edge to Planet by ids.

func (*GalaxyUpdateOne) AddPlanets

func (guo *GalaxyUpdateOne) AddPlanets(p ...*Planet) *GalaxyUpdateOne

AddPlanets adds the planets edges to Planet.

func (*GalaxyUpdateOne) Exec

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

Exec executes the query on the entity.

func (*GalaxyUpdateOne) ExecX

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

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

func (*GalaxyUpdateOne) RemovePlanetIDs

func (guo *GalaxyUpdateOne) RemovePlanetIDs(ids ...int) *GalaxyUpdateOne

RemovePlanetIDs removes the planets edge to Planet by ids.

func (*GalaxyUpdateOne) RemovePlanets

func (guo *GalaxyUpdateOne) RemovePlanets(p ...*Planet) *GalaxyUpdateOne

RemovePlanets removes planets edges to Planet.

func (*GalaxyUpdateOne) Save

func (guo *GalaxyUpdateOne) Save(ctx context.Context) (*Galaxy, error)

Save executes the query and returns the updated entity.

func (*GalaxyUpdateOne) SaveX

func (guo *GalaxyUpdateOne) SaveX(ctx context.Context) *Galaxy

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

func (*GalaxyUpdateOne) SetName

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

SetName sets the name field.

func (*GalaxyUpdateOne) SetType

func (guo *GalaxyUpdateOne) SetType(ga galaxy.Type) *GalaxyUpdateOne

SetType sets the type field.

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 Order

type Order func(*sql.Selector)

Order applies an ordering on either graph traversal or sql selector.

func Asc

func Asc(fields ...string) Order

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) Order

Desc applies the given fields in DESC order.

type Planet

type Planet struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Age holds the value of the "age" field.
	Age uint `json:"age,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the PlanetQuery when eager-loading is set.
	Edges PlanetEdges `json:"edges"`
	// contains filtered or unexported fields
}

Planet is the model entity for the Planet schema.

func (*Planet) QueryNeighbors

func (pl *Planet) QueryNeighbors() *PlanetQuery

QueryNeighbors queries the neighbors edge of the Planet.

func (*Planet) String

func (pl *Planet) String() string

String implements the fmt.Stringer.

func (*Planet) Unwrap

func (pl *Planet) Unwrap() *Planet

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 (*Planet) Update

func (pl *Planet) Update() *PlanetUpdateOne

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

type PlanetClient

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

PlanetClient is a client for the Planet schema.

func NewPlanetClient

func NewPlanetClient(c config) *PlanetClient

NewPlanetClient returns a client for the Planet from the given config.

func (*PlanetClient) Create

func (c *PlanetClient) Create() *PlanetCreate

Create returns a create builder for Planet.

func (*PlanetClient) Delete

func (c *PlanetClient) Delete() *PlanetDelete

Delete returns a delete builder for Planet.

func (*PlanetClient) DeleteOne

func (c *PlanetClient) DeleteOne(pl *Planet) *PlanetDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*PlanetClient) DeleteOneID

func (c *PlanetClient) DeleteOneID(id int) *PlanetDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*PlanetClient) Get

func (c *PlanetClient) Get(ctx context.Context, id int) (*Planet, error)

Get returns a Planet entity by its id.

func (*PlanetClient) GetX

func (c *PlanetClient) GetX(ctx context.Context, id int) *Planet

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

func (*PlanetClient) Hooks

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

Hooks returns the client hooks.

func (*PlanetClient) Query

func (c *PlanetClient) Query() *PlanetQuery

Create returns a query builder for Planet.

func (*PlanetClient) QueryNeighbors

func (c *PlanetClient) QueryNeighbors(pl *Planet) *PlanetQuery

QueryNeighbors queries the neighbors edge of a Planet.

func (*PlanetClient) Update

func (c *PlanetClient) Update() *PlanetUpdate

Update returns an update builder for Planet.

func (*PlanetClient) UpdateOne

func (c *PlanetClient) UpdateOne(pl *Planet) *PlanetUpdateOne

UpdateOne returns an update builder for the given entity.

func (*PlanetClient) UpdateOneID

func (c *PlanetClient) UpdateOneID(id int) *PlanetUpdateOne

UpdateOneID returns an update builder for the given id.

func (*PlanetClient) Use

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

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

type PlanetCreate

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

PlanetCreate is the builder for creating a Planet entity.

func (*PlanetCreate) AddNeighborIDs

func (pc *PlanetCreate) AddNeighborIDs(ids ...int) *PlanetCreate

AddNeighborIDs adds the neighbors edge to Planet by ids.

func (*PlanetCreate) AddNeighbors

func (pc *PlanetCreate) AddNeighbors(p ...*Planet) *PlanetCreate

AddNeighbors adds the neighbors edges to Planet.

func (*PlanetCreate) Save

func (pc *PlanetCreate) Save(ctx context.Context) (*Planet, error)

Save creates the Planet in the database.

func (*PlanetCreate) SaveX

func (pc *PlanetCreate) SaveX(ctx context.Context) *Planet

SaveX calls Save and panics if Save returns an error.

func (*PlanetCreate) SetAge

func (pc *PlanetCreate) SetAge(u uint) *PlanetCreate

SetAge sets the age field.

func (*PlanetCreate) SetName

func (pc *PlanetCreate) SetName(s string) *PlanetCreate

SetName sets the name field.

func (*PlanetCreate) SetNillableAge

func (pc *PlanetCreate) SetNillableAge(u *uint) *PlanetCreate

SetNillableAge sets the age field if the given value is not nil.

type PlanetDelete

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

PlanetDelete is the builder for deleting a Planet entity.

func (*PlanetDelete) Exec

func (pd *PlanetDelete) Exec(ctx context.Context) (int, error)

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

func (*PlanetDelete) ExecX

func (pd *PlanetDelete) ExecX(ctx context.Context) int

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

func (*PlanetDelete) Where

func (pd *PlanetDelete) Where(ps ...predicate.Planet) *PlanetDelete

Where adds a new predicate to the delete builder.

type PlanetDeleteOne

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

PlanetDeleteOne is the builder for deleting a single Planet entity.

func (*PlanetDeleteOne) Exec

func (pdo *PlanetDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*PlanetDeleteOne) ExecX

func (pdo *PlanetDeleteOne) ExecX(ctx context.Context)

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

type PlanetEdges

type PlanetEdges struct {
	// Neighbors holds the value of the neighbors edge.
	Neighbors []*Planet
	// contains filtered or unexported fields
}

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

func (PlanetEdges) NeighborsOrErr

func (e PlanetEdges) NeighborsOrErr() ([]*Planet, error)

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

type PlanetGroupBy

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

PlanetGroupBy is the builder for group-by Planet entities.

func (*PlanetGroupBy) Aggregate

func (pgb *PlanetGroupBy) Aggregate(fns ...Aggregate) *PlanetGroupBy

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

func (*PlanetGroupBy) Bools

func (pgb *PlanetGroupBy) 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 (*PlanetGroupBy) BoolsX

func (pgb *PlanetGroupBy) BoolsX(ctx context.Context) []bool

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

func (*PlanetGroupBy) Float64s

func (pgb *PlanetGroupBy) 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 (*PlanetGroupBy) Float64sX

func (pgb *PlanetGroupBy) Float64sX(ctx context.Context) []float64

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

func (*PlanetGroupBy) Ints

func (pgb *PlanetGroupBy) 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 (*PlanetGroupBy) IntsX

func (pgb *PlanetGroupBy) IntsX(ctx context.Context) []int

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

func (*PlanetGroupBy) Scan

func (pgb *PlanetGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*PlanetGroupBy) ScanX

func (pgb *PlanetGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*PlanetGroupBy) Strings

func (pgb *PlanetGroupBy) 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 (*PlanetGroupBy) StringsX

func (pgb *PlanetGroupBy) StringsX(ctx context.Context) []string

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

type PlanetMutation

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

PlanetMutation represents an operation that mutate the Planets nodes in the graph.

func (*PlanetMutation) AddAge

func (m *PlanetMutation) AddAge(u uint)

AddAge adds u to age.

func (*PlanetMutation) AddField

func (m *PlanetMutation) 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 (*PlanetMutation) AddNeighborIDs

func (m *PlanetMutation) AddNeighborIDs(ids ...int)

AddNeighborIDs adds the neighbors edge to Planet by ids.

func (*PlanetMutation) AddedAge

func (m *PlanetMutation) AddedAge() (r uint, exists bool)

AddedAge returns the value that was added to the age field in this mutation.

func (*PlanetMutation) AddedEdges

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

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

func (*PlanetMutation) AddedField

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

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

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

func (*PlanetMutation) AddedIDs

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

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

func (*PlanetMutation) Age

func (m *PlanetMutation) Age() (r uint, exists bool)

Age returns the age value in the mutation.

func (*PlanetMutation) AgeCleared

func (m *PlanetMutation) AgeCleared() bool

AgeCleared returns if the field age was cleared in this mutation.

func (*PlanetMutation) ClearAge

func (m *PlanetMutation) ClearAge()

ClearAge clears the value of age.

func (*PlanetMutation) ClearEdge

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

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

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

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

func (*PlanetMutation) ClearedFields

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

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

func (PlanetMutation) Client

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

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

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

func (*PlanetMutation) Field

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

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

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

func (*PlanetMutation) Fields

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

func (m *PlanetMutation) 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 (*PlanetMutation) Name

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

Name returns the name value in the mutation.

func (*PlanetMutation) NeighborsIDs

func (m *PlanetMutation) NeighborsIDs() (ids []int)

NeighborsIDs returns the neighbors ids in the mutation.

func (*PlanetMutation) Op

func (m *PlanetMutation) Op() Op

Op returns the operation name.

func (*PlanetMutation) RemoveNeighborIDs

func (m *PlanetMutation) RemoveNeighborIDs(ids ...int)

RemoveNeighborIDs removes the neighbors edge to Planet by ids.

func (*PlanetMutation) RemovedEdges

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

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

func (*PlanetMutation) RemovedIDs

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

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

func (*PlanetMutation) RemovedNeighborsIDs

func (m *PlanetMutation) RemovedNeighborsIDs() (ids []int)

RemovedNeighbors returns the removed ids of neighbors.

func (*PlanetMutation) ResetAge

func (m *PlanetMutation) ResetAge()

ResetAge reset all changes of the age field.

func (*PlanetMutation) ResetEdge

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

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

func (m *PlanetMutation) ResetName()

ResetName reset all changes of the name field.

func (*PlanetMutation) ResetNeighbors

func (m *PlanetMutation) ResetNeighbors()

ResetNeighbors reset all changes of the neighbors edge.

func (*PlanetMutation) SetAge

func (m *PlanetMutation) SetAge(u uint)

SetAge sets the age field.

func (*PlanetMutation) SetField

func (m *PlanetMutation) 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 (*PlanetMutation) SetName

func (m *PlanetMutation) SetName(s string)

SetName sets the name field.

func (PlanetMutation) Tx

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

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

func (*PlanetMutation) Type

func (m *PlanetMutation) Type() string

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

type PlanetQuery

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

PlanetQuery is the builder for querying Planet entities.

func (*PlanetQuery) All

func (pq *PlanetQuery) All(ctx context.Context) ([]*Planet, error)

All executes the query and returns a list of Planets.

func (*PlanetQuery) AllX

func (pq *PlanetQuery) AllX(ctx context.Context) []*Planet

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

func (*PlanetQuery) Clone

func (pq *PlanetQuery) Clone() *PlanetQuery

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 (*PlanetQuery) Count

func (pq *PlanetQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*PlanetQuery) CountX

func (pq *PlanetQuery) CountX(ctx context.Context) int

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

func (*PlanetQuery) Exist

func (pq *PlanetQuery) Exist(ctx context.Context) (bool, error)

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

func (*PlanetQuery) ExistX

func (pq *PlanetQuery) ExistX(ctx context.Context) bool

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

func (*PlanetQuery) First

func (pq *PlanetQuery) First(ctx context.Context) (*Planet, error)

First returns the first Planet entity in the query. Returns *NotFoundError when no planet was found.

func (*PlanetQuery) FirstID

func (pq *PlanetQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*PlanetQuery) FirstX

func (pq *PlanetQuery) FirstX(ctx context.Context) *Planet

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

func (*PlanetQuery) FirstXID

func (pq *PlanetQuery) FirstXID(ctx context.Context) int

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

func (*PlanetQuery) GroupBy

func (pq *PlanetQuery) GroupBy(field string, fields ...string) *PlanetGroupBy

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

client.Planet.Query().
	GroupBy(planet.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*PlanetQuery) IDs

func (pq *PlanetQuery) IDs(ctx context.Context) ([]int, error)

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

func (*PlanetQuery) IDsX

func (pq *PlanetQuery) IDsX(ctx context.Context) []int

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

func (*PlanetQuery) Limit

func (pq *PlanetQuery) Limit(limit int) *PlanetQuery

Limit adds a limit step to the query.

func (*PlanetQuery) Offset

func (pq *PlanetQuery) Offset(offset int) *PlanetQuery

Offset adds an offset step to the query.

func (*PlanetQuery) Only

func (pq *PlanetQuery) Only(ctx context.Context) (*Planet, error)

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

func (*PlanetQuery) OnlyID

func (pq *PlanetQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*PlanetQuery) OnlyX

func (pq *PlanetQuery) OnlyX(ctx context.Context) *Planet

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

func (*PlanetQuery) OnlyXID

func (pq *PlanetQuery) OnlyXID(ctx context.Context) int

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

func (*PlanetQuery) Order

func (pq *PlanetQuery) Order(o ...Order) *PlanetQuery

Order adds an order step to the query.

func (*PlanetQuery) QueryNeighbors

func (pq *PlanetQuery) QueryNeighbors() *PlanetQuery

QueryNeighbors chains the current query on the neighbors edge.

func (*PlanetQuery) Select

func (pq *PlanetQuery) Select(field string, fields ...string) *PlanetSelect

Select one or more fields from the given query.

Example:

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

client.Planet.Query().
	Select(planet.FieldName).
	Scan(ctx, &v)

func (*PlanetQuery) Where

func (pq *PlanetQuery) Where(ps ...predicate.Planet) *PlanetQuery

Where adds a new predicate for the builder.

func (*PlanetQuery) WithNeighbors

func (pq *PlanetQuery) WithNeighbors(opts ...func(*PlanetQuery)) *PlanetQuery
WithNeighbors tells the query-builder to eager-loads the nodes that are connected to

the "neighbors" edge. The optional arguments used to configure the query builder of the edge.

type PlanetSelect

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

PlanetSelect is the builder for select fields of Planet entities.

func (*PlanetSelect) Bools

func (ps *PlanetSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*PlanetSelect) BoolsX

func (ps *PlanetSelect) BoolsX(ctx context.Context) []bool

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

func (*PlanetSelect) Float64s

func (ps *PlanetSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*PlanetSelect) Float64sX

func (ps *PlanetSelect) Float64sX(ctx context.Context) []float64

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

func (*PlanetSelect) Ints

func (ps *PlanetSelect) Ints(ctx context.Context) ([]int, error)

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

func (*PlanetSelect) IntsX

func (ps *PlanetSelect) IntsX(ctx context.Context) []int

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

func (*PlanetSelect) Scan

func (ps *PlanetSelect) Scan(ctx context.Context, v interface{}) error

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

func (*PlanetSelect) ScanX

func (ps *PlanetSelect) ScanX(ctx context.Context, v interface{})

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

func (*PlanetSelect) Strings

func (ps *PlanetSelect) Strings(ctx context.Context) ([]string, error)

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

func (*PlanetSelect) StringsX

func (ps *PlanetSelect) StringsX(ctx context.Context) []string

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

type PlanetUpdate

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

PlanetUpdate is the builder for updating Planet entities.

func (*PlanetUpdate) AddAge

func (pu *PlanetUpdate) AddAge(u uint) *PlanetUpdate

AddAge adds u to age.

func (*PlanetUpdate) AddNeighborIDs

func (pu *PlanetUpdate) AddNeighborIDs(ids ...int) *PlanetUpdate

AddNeighborIDs adds the neighbors edge to Planet by ids.

func (*PlanetUpdate) AddNeighbors

func (pu *PlanetUpdate) AddNeighbors(p ...*Planet) *PlanetUpdate

AddNeighbors adds the neighbors edges to Planet.

func (*PlanetUpdate) ClearAge

func (pu *PlanetUpdate) ClearAge() *PlanetUpdate

ClearAge clears the value of age.

func (*PlanetUpdate) Exec

func (pu *PlanetUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*PlanetUpdate) ExecX

func (pu *PlanetUpdate) ExecX(ctx context.Context)

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

func (*PlanetUpdate) RemoveNeighborIDs

func (pu *PlanetUpdate) RemoveNeighborIDs(ids ...int) *PlanetUpdate

RemoveNeighborIDs removes the neighbors edge to Planet by ids.

func (*PlanetUpdate) RemoveNeighbors

func (pu *PlanetUpdate) RemoveNeighbors(p ...*Planet) *PlanetUpdate

RemoveNeighbors removes neighbors edges to Planet.

func (*PlanetUpdate) Save

func (pu *PlanetUpdate) Save(ctx context.Context) (int, error)

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

func (*PlanetUpdate) SaveX

func (pu *PlanetUpdate) SaveX(ctx context.Context) int

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

func (*PlanetUpdate) SetAge

func (pu *PlanetUpdate) SetAge(u uint) *PlanetUpdate

SetAge sets the age field.

func (*PlanetUpdate) SetNillableAge

func (pu *PlanetUpdate) SetNillableAge(u *uint) *PlanetUpdate

SetNillableAge sets the age field if the given value is not nil.

func (*PlanetUpdate) Where

func (pu *PlanetUpdate) Where(ps ...predicate.Planet) *PlanetUpdate

Where adds a new predicate for the builder.

type PlanetUpdateOne

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

PlanetUpdateOne is the builder for updating a single Planet entity.

func (*PlanetUpdateOne) AddAge

func (puo *PlanetUpdateOne) AddAge(u uint) *PlanetUpdateOne

AddAge adds u to age.

func (*PlanetUpdateOne) AddNeighborIDs

func (puo *PlanetUpdateOne) AddNeighborIDs(ids ...int) *PlanetUpdateOne

AddNeighborIDs adds the neighbors edge to Planet by ids.

func (*PlanetUpdateOne) AddNeighbors

func (puo *PlanetUpdateOne) AddNeighbors(p ...*Planet) *PlanetUpdateOne

AddNeighbors adds the neighbors edges to Planet.

func (*PlanetUpdateOne) ClearAge

func (puo *PlanetUpdateOne) ClearAge() *PlanetUpdateOne

ClearAge clears the value of age.

func (*PlanetUpdateOne) Exec

func (puo *PlanetUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*PlanetUpdateOne) ExecX

func (puo *PlanetUpdateOne) ExecX(ctx context.Context)

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

func (*PlanetUpdateOne) RemoveNeighborIDs

func (puo *PlanetUpdateOne) RemoveNeighborIDs(ids ...int) *PlanetUpdateOne

RemoveNeighborIDs removes the neighbors edge to Planet by ids.

func (*PlanetUpdateOne) RemoveNeighbors

func (puo *PlanetUpdateOne) RemoveNeighbors(p ...*Planet) *PlanetUpdateOne

RemoveNeighbors removes neighbors edges to Planet.

func (*PlanetUpdateOne) Save

func (puo *PlanetUpdateOne) Save(ctx context.Context) (*Planet, error)

Save executes the query and returns the updated entity.

func (*PlanetUpdateOne) SaveX

func (puo *PlanetUpdateOne) SaveX(ctx context.Context) *Planet

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

func (*PlanetUpdateOne) SetAge

func (puo *PlanetUpdateOne) SetAge(u uint) *PlanetUpdateOne

SetAge sets the age field.

func (*PlanetUpdateOne) SetNillableAge

func (puo *PlanetUpdateOne) SetNillableAge(u *uint) *PlanetUpdateOne

SetNillableAge sets the age field if the given value is not nil.

type Planets

type Planets []*Planet

Planets is a parsable slice of Planet.

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 Tx

type Tx struct {

	// Galaxy is the client for interacting with the Galaxy builders.
	Galaxy *GalaxyClient
	// Planet is the client for interacting with the Planet builders.
	Planet *PlanetClient
	// 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 func(error))

OnCommit adds a function to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f func(error))

OnRollback adds a function to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

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