ent

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 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 ¶ added in v0.1.5

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) BeginTx ¶ added in v0.1.5

func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

BeginTx returns a transactional client with options.

func (*Client) Close ¶

func (c *Client) Close() error

Close closes the database connection and prevents new queries from starting.

func (*Client) Debug ¶

func (c *Client) Debug() *Client

Debug returns a new debug-client. It's used to get verbose logging on specific operations.

client.Debug().
	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 ¶ added in v0.1.5

type Galaxies []*Galaxy

Galaxies is a parsable slice of Galaxy.

type Galaxy ¶ added in v0.1.5

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 ¶ added in v0.1.5

func (ga *Galaxy) QueryPlanets() *PlanetQuery

QueryPlanets queries the planets edge of the Galaxy.

func (*Galaxy) String ¶ added in v0.1.5

func (ga *Galaxy) String() string

String implements the fmt.Stringer.

func (*Galaxy) Unwrap ¶ added in v0.1.5

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 ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

GalaxyClient is a client for the Galaxy schema.

func NewGalaxyClient ¶ added in v0.1.5

func NewGalaxyClient(c config) *GalaxyClient

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

func (*GalaxyClient) Create ¶ added in v0.1.5

func (c *GalaxyClient) Create() *GalaxyCreate

Create returns a create builder for Galaxy.

func (*GalaxyClient) Delete ¶ added in v0.1.5

func (c *GalaxyClient) Delete() *GalaxyDelete

Delete returns a delete builder for Galaxy.

func (*GalaxyClient) DeleteOne ¶ added in v0.1.5

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

DeleteOne returns a delete builder for the given entity.

func (*GalaxyClient) DeleteOneID ¶ added in v0.1.5

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

DeleteOneID returns a delete builder for the given id.

func (*GalaxyClient) Get ¶ added in v0.1.5

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

Get returns a Galaxy entity by its id.

func (*GalaxyClient) GetX ¶ added in v0.1.5

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

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

func (*GalaxyClient) Hooks ¶ added in v0.1.5

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

Hooks returns the client hooks.

func (*GalaxyClient) Query ¶ added in v0.1.5

func (c *GalaxyClient) Query() *GalaxyQuery

Create returns a query builder for Galaxy.

func (*GalaxyClient) QueryPlanets ¶ added in v0.1.5

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

QueryPlanets queries the planets edge of a Galaxy.

func (*GalaxyClient) Update ¶ added in v0.1.5

func (c *GalaxyClient) Update() *GalaxyUpdate

Update returns an update builder for Galaxy.

func (*GalaxyClient) UpdateOne ¶ added in v0.1.5

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

UpdateOne returns an update builder for the given entity.

func (*GalaxyClient) UpdateOneID ¶ added in v0.1.5

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

UpdateOneID returns an update builder for the given id.

func (*GalaxyClient) Use ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

GalaxyCreate is the builder for creating a Galaxy entity.

func (*GalaxyCreate) AddPlanetIDs ¶ added in v0.1.5

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

AddPlanetIDs adds the planets edge to Planet by ids.

func (*GalaxyCreate) AddPlanets ¶ added in v0.1.5

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

AddPlanets adds the planets edges to Planet.

func (*GalaxyCreate) Save ¶ added in v0.1.5

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

Save creates the Galaxy in the database.

func (*GalaxyCreate) SaveX ¶ added in v0.1.5

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

SaveX calls Save and panics if Save returns an error.

func (*GalaxyCreate) SetName ¶ added in v0.1.5

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

SetName sets the name field.

func (*GalaxyCreate) SetType ¶ added in v0.1.5

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

SetType sets the type field.

type GalaxyDelete ¶ added in v0.1.5

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

GalaxyDelete is the builder for deleting a Galaxy entity.

func (*GalaxyDelete) Exec ¶ added in v0.1.5

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

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

func (*GalaxyDelete) ExecX ¶ added in v0.1.5

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

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

func (*GalaxyDelete) Where ¶ added in v0.1.5

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

Where adds a new predicate to the delete builder.

type GalaxyDeleteOne ¶ added in v0.1.5

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

GalaxyDeleteOne is the builder for deleting a single Galaxy entity.

func (*GalaxyDeleteOne) Exec ¶ added in v0.1.5

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

Exec executes the deletion query.

func (*GalaxyDeleteOne) ExecX ¶ added in v0.1.5

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

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

type GalaxyEdges ¶ added in v0.1.5

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 ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

GalaxyGroupBy is the builder for group-by Galaxy entities.

func (*GalaxyGroupBy) Aggregate ¶ added in v0.1.5

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

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

func (*GalaxyGroupBy) Bools ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyGroupBy) Float64s ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyGroupBy) Ints ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyGroupBy) Scan ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyGroupBy) Strings ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

type GalaxyMutation ¶ added in v0.1.5

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

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

func (*GalaxyMutation) AddField ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

AddPlanetIDs adds the planets edge to Planet by ids.

func (*GalaxyMutation) AddedEdges ¶ added in v0.1.5

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

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

func (*GalaxyMutation) AddedField ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyMutation) AddedIDs ¶ added in v0.1.5

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 ¶ added in v0.1.5

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 ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyMutation) ClearedFields ¶ added in v0.1.5

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

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

func (GalaxyMutation) Client ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyMutation) Field ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyMutation) Fields ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

GetType returns the type value in the mutation.

func (*GalaxyMutation) ID ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

Name returns the name value in the mutation.

func (*GalaxyMutation) Op ¶ added in v0.1.5

func (m *GalaxyMutation) Op() Op

Op returns the operation name.

func (*GalaxyMutation) PlanetsIDs ¶ added in v0.1.5

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

PlanetsIDs returns the planets ids in the mutation.

func (*GalaxyMutation) RemovePlanetIDs ¶ added in v0.1.5

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

RemovePlanetIDs removes the planets edge to Planet by ids.

func (*GalaxyMutation) RemovedEdges ¶ added in v0.1.5

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

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

func (*GalaxyMutation) RemovedIDs ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

RemovedPlanets returns the removed ids of planets.

func (*GalaxyMutation) ResetEdge ¶ added in v0.1.5

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 ¶ added in v0.1.5

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 ¶ added in v0.1.5

func (m *GalaxyMutation) ResetName()

ResetName reset all changes of the name field.

func (*GalaxyMutation) ResetPlanets ¶ added in v0.1.5

func (m *GalaxyMutation) ResetPlanets()

ResetPlanets reset all changes of the planets edge.

func (*GalaxyMutation) ResetType ¶ added in v0.1.5

func (m *GalaxyMutation) ResetType()

ResetType reset all changes of the type field.

func (*GalaxyMutation) SetField ¶ added in v0.1.5

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 ¶ added in v0.1.5

func (m *GalaxyMutation) SetName(s string)

SetName sets the name field.

func (*GalaxyMutation) SetType ¶ added in v0.1.5

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

SetType sets the type field.

func (GalaxyMutation) Tx ¶ added in v0.1.5

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 ¶ added in v0.1.5

func (m *GalaxyMutation) Type() string

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

type GalaxyQuery ¶ added in v0.1.5

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

GalaxyQuery is the builder for querying Galaxy entities.

func (*GalaxyQuery) All ¶ added in v0.1.5

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

All executes the query and returns a list of Galaxies.

func (*GalaxyQuery) AllX ¶ added in v0.1.5

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

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

func (*GalaxyQuery) Clone ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

Count returns the count of the given query.

func (*GalaxyQuery) CountX ¶ added in v0.1.5

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

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

func (*GalaxyQuery) Exist ¶ added in v0.1.5

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

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

func (*GalaxyQuery) ExistX ¶ added in v0.1.5

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

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

func (*GalaxyQuery) First ¶ added in v0.1.5

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 ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyQuery) FirstXID ¶ added in v0.1.5

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

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

func (*GalaxyQuery) GroupBy ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyQuery) IDsX ¶ added in v0.1.5

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

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

func (*GalaxyQuery) Limit ¶ added in v0.1.5

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

Limit adds a limit step to the query.

func (*GalaxyQuery) Offset ¶ added in v0.1.5

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

Offset adds an offset step to the query.

func (*GalaxyQuery) Only ¶ added in v0.1.5

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 ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyQuery) OnlyXID ¶ added in v0.1.5

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

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

func (*GalaxyQuery) Order ¶ added in v0.1.5

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

Order adds an order step to the query.

func (*GalaxyQuery) QueryPlanets ¶ added in v0.1.5

func (gq *GalaxyQuery) QueryPlanets() *PlanetQuery

QueryPlanets chains the current query on the planets edge.

func (*GalaxyQuery) Select ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

Where adds a new predicate for the builder.

func (*GalaxyQuery) WithPlanets ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

GalaxySelect is the builder for select fields of Galaxy entities.

func (*GalaxySelect) Bools ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxySelect) Float64s ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxySelect) Ints ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxySelect) Scan ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxySelect) Strings ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

type GalaxyUpdate ¶ added in v0.1.5

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

GalaxyUpdate is the builder for updating Galaxy entities.

func (*GalaxyUpdate) AddPlanetIDs ¶ added in v0.1.5

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

AddPlanetIDs adds the planets edge to Planet by ids.

func (*GalaxyUpdate) AddPlanets ¶ added in v0.1.5

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

AddPlanets adds the planets edges to Planet.

func (*GalaxyUpdate) Exec ¶ added in v0.1.5

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

Exec executes the query.

func (*GalaxyUpdate) ExecX ¶ added in v0.1.5

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

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

func (*GalaxyUpdate) RemovePlanetIDs ¶ added in v0.1.5

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

RemovePlanetIDs removes the planets edge to Planet by ids.

func (*GalaxyUpdate) RemovePlanets ¶ added in v0.1.5

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

RemovePlanets removes planets edges to Planet.

func (*GalaxyUpdate) Save ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

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

func (*GalaxyUpdate) SetName ¶ added in v0.1.5

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

SetName sets the name field.

func (*GalaxyUpdate) SetType ¶ added in v0.1.5

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

SetType sets the type field.

func (*GalaxyUpdate) Where ¶ added in v0.1.5

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

Where adds a new predicate for the builder.

type GalaxyUpdateOne ¶ added in v0.1.5

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

GalaxyUpdateOne is the builder for updating a single Galaxy entity.

func (*GalaxyUpdateOne) AddPlanetIDs ¶ added in v0.1.5

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

AddPlanetIDs adds the planets edge to Planet by ids.

func (*GalaxyUpdateOne) AddPlanets ¶ added in v0.1.5

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

AddPlanets adds the planets edges to Planet.

func (*GalaxyUpdateOne) Exec ¶ added in v0.1.5

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

Exec executes the query on the entity.

func (*GalaxyUpdateOne) ExecX ¶ added in v0.1.5

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

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

func (*GalaxyUpdateOne) RemovePlanetIDs ¶ added in v0.1.5

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

RemovePlanetIDs removes the planets edge to Planet by ids.

func (*GalaxyUpdateOne) RemovePlanets ¶ added in v0.1.5

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

RemovePlanets removes planets edges to Planet.

func (*GalaxyUpdateOne) Save ¶ added in v0.1.5

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

Save executes the query and returns the updated entity.

func (*GalaxyUpdateOne) SaveX ¶ added in v0.1.5

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

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

func (*GalaxyUpdateOne) SetName ¶ added in v0.1.5

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

SetName sets the name field.

func (*GalaxyUpdateOne) SetType ¶ added in v0.1.5

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 ¶ added in v0.1.5

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 ¶ added in v0.1.5

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 ¶ added in v0.1.5

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

OnCommit adds a function to call on commit.

func (*Tx) OnRollback ¶ added in v0.1.5

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