ent

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 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.
	TypeCity   = "City"
	TypeStreet = "Street"
)

Variables

This section is empty.

Functions

func IsConstraintError

func IsConstraintError(err error) bool

IsConstraintError returns a boolean indicating whether the error is a constraint failure.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns a boolean indicating whether the error is a not found error.

func IsNotLoaded

func IsNotLoaded(err error) bool

IsNotLoaded returns a boolean indicating whether the error is a not loaded error.

func IsNotSingular

func IsNotSingular(err error) bool

IsNotSingular returns a boolean indicating whether the error is a not singular error.

func IsValidationError

func IsValidationError(err error) bool

IsValidationError returns a boolean indicating whether the error is a validaton error.

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

func NewContext(parent context.Context, c *Client) context.Context

NewContext returns a new context with the given Client attached.

func NewTxContext

func NewTxContext(parent context.Context, tx *Tx) context.Context

NewTxContext returns a new context with the given Tx attached.

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

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

func As

As is a pseudo aggregation function for renaming another other functions with custom names. For example:

GroupBy(field1, field2).
Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
Scan(ctx, &v)

func Count

func Count() AggregateFunc

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

func Max

func Max(field string) AggregateFunc

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

func Mean

func Mean(field string) AggregateFunc

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

func Min

func Min(field string) AggregateFunc

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

func Sum

func Sum(field string) AggregateFunc

Sum applies the "sum" aggregation function on the given field of each group.

type Cities

type Cities []*City

Cities is a parsable slice of City.

type City

type City struct {

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

City is the model entity for the City schema.

func (*City) QueryStreets

func (c *City) QueryStreets() *StreetQuery

QueryStreets queries the "streets" edge of the City entity.

func (*City) String

func (c *City) String() string

String implements the fmt.Stringer.

func (*City) Unwrap

func (c *City) Unwrap() *City

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

func (*City) Update

func (c *City) Update() *CityUpdateOne

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

type CityClient

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

CityClient is a client for the City schema.

func NewCityClient

func NewCityClient(c config) *CityClient

NewCityClient returns a client for the City from the given config.

func (*CityClient) Create

func (c *CityClient) Create() *CityCreate

Create returns a create builder for City.

func (*CityClient) CreateBulk

func (c *CityClient) CreateBulk(builders ...*CityCreate) *CityCreateBulk

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

func (*CityClient) Delete

func (c *CityClient) Delete() *CityDelete

Delete returns a delete builder for City.

func (*CityClient) DeleteOne

func (c *CityClient) DeleteOne(ci *City) *CityDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*CityClient) DeleteOneID

func (c *CityClient) DeleteOneID(id int) *CityDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*CityClient) Get

func (c *CityClient) Get(ctx context.Context, id int) (*City, error)

Get returns a City entity by its id.

func (*CityClient) GetX

func (c *CityClient) GetX(ctx context.Context, id int) *City

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

func (*CityClient) Hooks

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

Hooks returns the client hooks.

func (*CityClient) Query

func (c *CityClient) Query() *CityQuery

Query returns a query builder for City.

func (*CityClient) QueryStreets

func (c *CityClient) QueryStreets(ci *City) *StreetQuery

QueryStreets queries the streets edge of a City.

func (*CityClient) Update

func (c *CityClient) Update() *CityUpdate

Update returns an update builder for City.

func (*CityClient) UpdateOne

func (c *CityClient) UpdateOne(ci *City) *CityUpdateOne

UpdateOne returns an update builder for the given entity.

func (*CityClient) UpdateOneID

func (c *CityClient) UpdateOneID(id int) *CityUpdateOne

UpdateOneID returns an update builder for the given id.

func (*CityClient) Use

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

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

type CityCreate

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

CityCreate is the builder for creating a City entity.

func (*CityCreate) AddStreetIDs

func (cc *CityCreate) AddStreetIDs(ids ...int) *CityCreate

AddStreetIDs adds the "streets" edge to the Street entity by IDs.

func (*CityCreate) AddStreets

func (cc *CityCreate) AddStreets(s ...*Street) *CityCreate

AddStreets adds the "streets" edges to the Street entity.

func (*CityCreate) Mutation

func (cc *CityCreate) Mutation() *CityMutation

Mutation returns the CityMutation object of the builder.

func (*CityCreate) Save

func (cc *CityCreate) Save(ctx context.Context) (*City, error)

Save creates the City in the database.

func (*CityCreate) SaveX

func (cc *CityCreate) SaveX(ctx context.Context) *City

SaveX calls Save and panics if Save returns an error.

func (*CityCreate) SetName

func (cc *CityCreate) SetName(s string) *CityCreate

SetName sets the "name" field.

type CityCreateBulk

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

CityCreateBulk is the builder for creating many City entities in bulk.

func (*CityCreateBulk) Save

func (ccb *CityCreateBulk) Save(ctx context.Context) ([]*City, error)

Save creates the City entities in the database.

func (*CityCreateBulk) SaveX

func (ccb *CityCreateBulk) SaveX(ctx context.Context) []*City

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

type CityDelete

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

CityDelete is the builder for deleting a City entity.

func (*CityDelete) Exec

func (cd *CityDelete) Exec(ctx context.Context) (int, error)

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

func (*CityDelete) ExecX

func (cd *CityDelete) ExecX(ctx context.Context) int

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

func (*CityDelete) Where

func (cd *CityDelete) Where(ps ...predicate.City) *CityDelete

Where adds a new predicate to the CityDelete builder.

type CityDeleteOne

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

CityDeleteOne is the builder for deleting a single City entity.

func (*CityDeleteOne) Exec

func (cdo *CityDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*CityDeleteOne) ExecX

func (cdo *CityDeleteOne) ExecX(ctx context.Context)

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

type CityEdges

type CityEdges struct {
	// Streets holds the value of the streets edge.
	Streets []*Street `json:"streets,omitempty"`
	// contains filtered or unexported fields
}

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

func (CityEdges) StreetsOrErr

func (e CityEdges) StreetsOrErr() ([]*Street, error)

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

type CityGroupBy

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

CityGroupBy is the group-by builder for City entities.

func (*CityGroupBy) Aggregate

func (cgb *CityGroupBy) Aggregate(fns ...AggregateFunc) *CityGroupBy

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

func (*CityGroupBy) Bool

func (cgb *CityGroupBy) Bool(ctx context.Context) (_ bool, err error)

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

func (*CityGroupBy) BoolX

func (cgb *CityGroupBy) BoolX(ctx context.Context) bool

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

func (*CityGroupBy) Bools

func (cgb *CityGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*CityGroupBy) BoolsX

func (cgb *CityGroupBy) BoolsX(ctx context.Context) []bool

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

func (*CityGroupBy) Float64

func (cgb *CityGroupBy) Float64(ctx context.Context) (_ float64, err error)

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

func (*CityGroupBy) Float64X

func (cgb *CityGroupBy) Float64X(ctx context.Context) float64

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

func (*CityGroupBy) Float64s

func (cgb *CityGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*CityGroupBy) Float64sX

func (cgb *CityGroupBy) Float64sX(ctx context.Context) []float64

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

func (*CityGroupBy) Int

func (cgb *CityGroupBy) Int(ctx context.Context) (_ int, err error)

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

func (*CityGroupBy) IntX

func (cgb *CityGroupBy) IntX(ctx context.Context) int

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

func (*CityGroupBy) Ints

func (cgb *CityGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*CityGroupBy) IntsX

func (cgb *CityGroupBy) IntsX(ctx context.Context) []int

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

func (*CityGroupBy) Scan

func (cgb *CityGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*CityGroupBy) ScanX

func (cgb *CityGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*CityGroupBy) String

func (cgb *CityGroupBy) String(ctx context.Context) (_ string, err error)

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

func (*CityGroupBy) StringX

func (cgb *CityGroupBy) StringX(ctx context.Context) string

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

func (*CityGroupBy) Strings

func (cgb *CityGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*CityGroupBy) StringsX

func (cgb *CityGroupBy) StringsX(ctx context.Context) []string

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

type CityMutation

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

CityMutation represents an operation that mutates the City nodes in the graph.

func (*CityMutation) AddField

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

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

func (*CityMutation) AddStreetIDs

func (m *CityMutation) AddStreetIDs(ids ...int)

AddStreetIDs adds the "streets" edge to the Street entity by ids.

func (*CityMutation) AddedEdges

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

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

func (*CityMutation) AddedField

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

AddedField returns the numeric value that was incremented/decremented on a field with the given name. The second boolean return value indicates that this field was not set, or was not defined in the schema.

func (*CityMutation) AddedFields

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

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

func (*CityMutation) AddedIDs

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

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

func (*CityMutation) ClearEdge

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

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

func (*CityMutation) ClearField

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

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

func (*CityMutation) ClearStreets

func (m *CityMutation) ClearStreets()

ClearStreets clears the "streets" edge to the Street entity.

func (*CityMutation) ClearedEdges

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

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

func (*CityMutation) ClearedFields

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

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

func (CityMutation) Client

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

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

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

func (*CityMutation) Field

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

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

func (*CityMutation) FieldCleared

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

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

func (*CityMutation) Fields

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

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

func (*CityMutation) ID

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

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

func (*CityMutation) Name

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

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

func (*CityMutation) OldField

func (m *CityMutation) OldField(ctx context.Context, name string) (ent.Value, error)

OldField returns the old value of the field from the database. An error is returned if the mutation operation is not UpdateOne, or the query to the database failed.

func (*CityMutation) OldName

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

OldName returns the old "name" field's value of the City entity. If the City object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*CityMutation) Op

func (m *CityMutation) Op() Op

Op returns the operation name.

func (*CityMutation) RemoveStreetIDs

func (m *CityMutation) RemoveStreetIDs(ids ...int)

RemoveStreetIDs removes the "streets" edge to the Street entity by IDs.

func (*CityMutation) RemovedEdges

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

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

func (*CityMutation) RemovedIDs

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

RemovedIDs returns all IDs (to other nodes) that were removed for the edge with the given name in this mutation.

func (*CityMutation) RemovedStreetsIDs

func (m *CityMutation) RemovedStreetsIDs() (ids []int)

RemovedStreets returns the removed IDs of the "streets" edge to the Street entity.

func (*CityMutation) ResetEdge

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

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

func (*CityMutation) ResetField

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

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

func (*CityMutation) ResetName

func (m *CityMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*CityMutation) ResetStreets

func (m *CityMutation) ResetStreets()

ResetStreets resets all changes to the "streets" edge.

func (*CityMutation) SetField

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

SetField sets the value of a field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

func (*CityMutation) SetName

func (m *CityMutation) SetName(s string)

SetName sets the "name" field.

func (*CityMutation) StreetsCleared

func (m *CityMutation) StreetsCleared() bool

StreetsCleared reports if the "streets" edge to the Street entity was cleared.

func (*CityMutation) StreetsIDs

func (m *CityMutation) StreetsIDs() (ids []int)

StreetsIDs returns the "streets" edge IDs in the mutation.

func (CityMutation) Tx

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

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

func (*CityMutation) Type

func (m *CityMutation) Type() string

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

type CityQuery

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

CityQuery is the builder for querying City entities.

func (*CityQuery) All

func (cq *CityQuery) All(ctx context.Context) ([]*City, error)

All executes the query and returns a list of Cities.

func (*CityQuery) AllX

func (cq *CityQuery) AllX(ctx context.Context) []*City

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

func (*CityQuery) Clone

func (cq *CityQuery) Clone() *CityQuery

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

func (*CityQuery) Count

func (cq *CityQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*CityQuery) CountX

func (cq *CityQuery) CountX(ctx context.Context) int

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

func (*CityQuery) Exist

func (cq *CityQuery) Exist(ctx context.Context) (bool, error)

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

func (*CityQuery) ExistX

func (cq *CityQuery) ExistX(ctx context.Context) bool

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

func (*CityQuery) First

func (cq *CityQuery) First(ctx context.Context) (*City, error)

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

func (*CityQuery) FirstID

func (cq *CityQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*CityQuery) FirstIDX

func (cq *CityQuery) FirstIDX(ctx context.Context) int

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

func (*CityQuery) FirstX

func (cq *CityQuery) FirstX(ctx context.Context) *City

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

func (*CityQuery) GroupBy

func (cq *CityQuery) GroupBy(field string, fields ...string) *CityGroupBy

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

Example:

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

client.City.Query().
	GroupBy(city.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*CityQuery) IDs

func (cq *CityQuery) IDs(ctx context.Context) ([]int, error)

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

func (*CityQuery) IDsX

func (cq *CityQuery) IDsX(ctx context.Context) []int

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

func (*CityQuery) Limit

func (cq *CityQuery) Limit(limit int) *CityQuery

Limit adds a limit step to the query.

func (*CityQuery) Offset

func (cq *CityQuery) Offset(offset int) *CityQuery

Offset adds an offset step to the query.

func (*CityQuery) Only

func (cq *CityQuery) Only(ctx context.Context) (*City, error)

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

func (*CityQuery) OnlyID

func (cq *CityQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*CityQuery) OnlyIDX

func (cq *CityQuery) OnlyIDX(ctx context.Context) int

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

func (*CityQuery) OnlyX

func (cq *CityQuery) OnlyX(ctx context.Context) *City

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

func (*CityQuery) Order

func (cq *CityQuery) Order(o ...OrderFunc) *CityQuery

Order adds an order step to the query.

func (*CityQuery) QueryStreets

func (cq *CityQuery) QueryStreets() *StreetQuery

QueryStreets chains the current query on the "streets" edge.

func (*CityQuery) Select

func (cq *CityQuery) Select(field string, fields ...string) *CitySelect

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

Example:

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

client.City.Query().
	Select(city.FieldName).
	Scan(ctx, &v)

func (*CityQuery) Unique added in v0.8.0

func (cq *CityQuery) Unique(unique bool) *CityQuery

Unique configures the query builder to filter duplicate records on query. By default, unique is set to true, and can be disabled using this method.

func (*CityQuery) Where

func (cq *CityQuery) Where(ps ...predicate.City) *CityQuery

Where adds a new predicate for the CityQuery builder.

func (*CityQuery) WithStreets

func (cq *CityQuery) WithStreets(opts ...func(*StreetQuery)) *CityQuery

WithStreets tells the query-builder to eager-load the nodes that are connected to the "streets" edge. The optional arguments are used to configure the query builder of the edge.

type CitySelect

type CitySelect struct {
	*CityQuery
	// contains filtered or unexported fields
}

CitySelect is the builder for selecting fields of City entities.

func (*CitySelect) Bool

func (cs *CitySelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*CitySelect) BoolX

func (cs *CitySelect) BoolX(ctx context.Context) bool

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

func (*CitySelect) Bools

func (cs *CitySelect) Bools(ctx context.Context) ([]bool, error)

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

func (*CitySelect) BoolsX

func (cs *CitySelect) BoolsX(ctx context.Context) []bool

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

func (*CitySelect) Float64

func (cs *CitySelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*CitySelect) Float64X

func (cs *CitySelect) Float64X(ctx context.Context) float64

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

func (*CitySelect) Float64s

func (cs *CitySelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*CitySelect) Float64sX

func (cs *CitySelect) Float64sX(ctx context.Context) []float64

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

func (*CitySelect) Int

func (cs *CitySelect) Int(ctx context.Context) (_ int, err error)

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

func (*CitySelect) IntX

func (cs *CitySelect) IntX(ctx context.Context) int

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

func (*CitySelect) Ints

func (cs *CitySelect) Ints(ctx context.Context) ([]int, error)

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

func (*CitySelect) IntsX

func (cs *CitySelect) IntsX(ctx context.Context) []int

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

func (*CitySelect) Scan

func (cs *CitySelect) Scan(ctx context.Context, v interface{}) error

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

func (*CitySelect) ScanX

func (cs *CitySelect) ScanX(ctx context.Context, v interface{})

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

func (*CitySelect) String

func (cs *CitySelect) String(ctx context.Context) (_ string, err error)

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

func (*CitySelect) StringX

func (cs *CitySelect) StringX(ctx context.Context) string

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

func (*CitySelect) Strings

func (cs *CitySelect) Strings(ctx context.Context) ([]string, error)

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

func (*CitySelect) StringsX

func (cs *CitySelect) StringsX(ctx context.Context) []string

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

type CityUpdate

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

CityUpdate is the builder for updating City entities.

func (*CityUpdate) AddStreetIDs

func (cu *CityUpdate) AddStreetIDs(ids ...int) *CityUpdate

AddStreetIDs adds the "streets" edge to the Street entity by IDs.

func (*CityUpdate) AddStreets

func (cu *CityUpdate) AddStreets(s ...*Street) *CityUpdate

AddStreets adds the "streets" edges to the Street entity.

func (*CityUpdate) ClearStreets

func (cu *CityUpdate) ClearStreets() *CityUpdate

ClearStreets clears all "streets" edges to the Street entity.

func (*CityUpdate) Exec

func (cu *CityUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*CityUpdate) ExecX

func (cu *CityUpdate) ExecX(ctx context.Context)

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

func (*CityUpdate) Mutation

func (cu *CityUpdate) Mutation() *CityMutation

Mutation returns the CityMutation object of the builder.

func (*CityUpdate) RemoveStreetIDs

func (cu *CityUpdate) RemoveStreetIDs(ids ...int) *CityUpdate

RemoveStreetIDs removes the "streets" edge to Street entities by IDs.

func (*CityUpdate) RemoveStreets

func (cu *CityUpdate) RemoveStreets(s ...*Street) *CityUpdate

RemoveStreets removes "streets" edges to Street entities.

func (*CityUpdate) Save

func (cu *CityUpdate) Save(ctx context.Context) (int, error)

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

func (*CityUpdate) SaveX

func (cu *CityUpdate) SaveX(ctx context.Context) int

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

func (*CityUpdate) SetName

func (cu *CityUpdate) SetName(s string) *CityUpdate

SetName sets the "name" field.

func (*CityUpdate) Where

func (cu *CityUpdate) Where(ps ...predicate.City) *CityUpdate

Where adds a new predicate for the CityUpdate builder.

type CityUpdateOne

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

CityUpdateOne is the builder for updating a single City entity.

func (*CityUpdateOne) AddStreetIDs

func (cuo *CityUpdateOne) AddStreetIDs(ids ...int) *CityUpdateOne

AddStreetIDs adds the "streets" edge to the Street entity by IDs.

func (*CityUpdateOne) AddStreets

func (cuo *CityUpdateOne) AddStreets(s ...*Street) *CityUpdateOne

AddStreets adds the "streets" edges to the Street entity.

func (*CityUpdateOne) ClearStreets

func (cuo *CityUpdateOne) ClearStreets() *CityUpdateOne

ClearStreets clears all "streets" edges to the Street entity.

func (*CityUpdateOne) Exec

func (cuo *CityUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*CityUpdateOne) ExecX

func (cuo *CityUpdateOne) ExecX(ctx context.Context)

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

func (*CityUpdateOne) Mutation

func (cuo *CityUpdateOne) Mutation() *CityMutation

Mutation returns the CityMutation object of the builder.

func (*CityUpdateOne) RemoveStreetIDs

func (cuo *CityUpdateOne) RemoveStreetIDs(ids ...int) *CityUpdateOne

RemoveStreetIDs removes the "streets" edge to Street entities by IDs.

func (*CityUpdateOne) RemoveStreets

func (cuo *CityUpdateOne) RemoveStreets(s ...*Street) *CityUpdateOne

RemoveStreets removes "streets" edges to Street entities.

func (*CityUpdateOne) Save

func (cuo *CityUpdateOne) Save(ctx context.Context) (*City, error)

Save executes the query and returns the updated City entity.

func (*CityUpdateOne) SaveX

func (cuo *CityUpdateOne) SaveX(ctx context.Context) *City

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

func (*CityUpdateOne) Select added in v0.8.0

func (cuo *CityUpdateOne) Select(field string, fields ...string) *CityUpdateOne

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

func (*CityUpdateOne) SetName

func (cuo *CityUpdateOne) SetName(s string) *CityUpdateOne

SetName sets the "name" field.

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// City is the client for interacting with the City builders.
	City *CityClient
	// Street is the client for interacting with the Street builders.
	Street *StreetClient
	// contains filtered or unexported fields
}

Client is the client that holds all ent builders.

func FromContext

func FromContext(ctx context.Context) *Client

FromContext returns a Client stored inside a context, or nil if there isn't one.

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new client configured with the given options.

func Open

func Open(driverName, dataSourceName string, options ...Option) (*Client, error)

Open opens a database/sql.DB specified by the driver name and the data source name, and returns a new client attached to it. Optional parameters can be added for configuring the client.

func (*Client) BeginTx

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

BeginTx returns a transactional client with specified options.

func (*Client) Close

func (c *Client) Close() error

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

func (*Client) Debug

func (c *Client) Debug() *Client

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

client.Debug().
	City.
	Query().
	Count(ctx)

func (*Client) Tx

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

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

func (*Client) Use

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

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

type CommitFunc

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

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

func (CommitFunc) Commit

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

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

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

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

type Committer

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

Committer is the interface that wraps the Committer method.

type ConstraintError

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

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

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

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

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

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

type NotFoundError

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

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

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

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

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

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

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

func Log(fn func(...interface{})) Option

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

OrderFunc applies an ordering on the sql selector.

func Asc

func Asc(fields ...string) OrderFunc

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) OrderFunc

Desc applies the given fields in DESC order.

type Policy

type Policy = ent.Policy

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

type Query

type Query = ent.Query

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

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

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

type Rollbacker

type Rollbacker interface {
	Rollback(context.Context, *Tx) error
}

Rollbacker is the interface that wraps the Rollbacker method.

type Street

type Street struct {

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

Street is the model entity for the Street schema.

func (*Street) QueryCity

func (s *Street) QueryCity() *CityQuery

QueryCity queries the "city" edge of the Street entity.

func (*Street) String

func (s *Street) String() string

String implements the fmt.Stringer.

func (*Street) Unwrap

func (s *Street) Unwrap() *Street

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

func (*Street) Update

func (s *Street) Update() *StreetUpdateOne

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

type StreetClient

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

StreetClient is a client for the Street schema.

func NewStreetClient

func NewStreetClient(c config) *StreetClient

NewStreetClient returns a client for the Street from the given config.

func (*StreetClient) Create

func (c *StreetClient) Create() *StreetCreate

Create returns a create builder for Street.

func (*StreetClient) CreateBulk

func (c *StreetClient) CreateBulk(builders ...*StreetCreate) *StreetCreateBulk

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

func (*StreetClient) Delete

func (c *StreetClient) Delete() *StreetDelete

Delete returns a delete builder for Street.

func (*StreetClient) DeleteOne

func (c *StreetClient) DeleteOne(s *Street) *StreetDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*StreetClient) DeleteOneID

func (c *StreetClient) DeleteOneID(id int) *StreetDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*StreetClient) Get

func (c *StreetClient) Get(ctx context.Context, id int) (*Street, error)

Get returns a Street entity by its id.

func (*StreetClient) GetX

func (c *StreetClient) GetX(ctx context.Context, id int) *Street

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

func (*StreetClient) Hooks

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

Hooks returns the client hooks.

func (*StreetClient) Query

func (c *StreetClient) Query() *StreetQuery

Query returns a query builder for Street.

func (*StreetClient) QueryCity

func (c *StreetClient) QueryCity(s *Street) *CityQuery

QueryCity queries the city edge of a Street.

func (*StreetClient) Update

func (c *StreetClient) Update() *StreetUpdate

Update returns an update builder for Street.

func (*StreetClient) UpdateOne

func (c *StreetClient) UpdateOne(s *Street) *StreetUpdateOne

UpdateOne returns an update builder for the given entity.

func (*StreetClient) UpdateOneID

func (c *StreetClient) UpdateOneID(id int) *StreetUpdateOne

UpdateOneID returns an update builder for the given id.

func (*StreetClient) Use

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

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

type StreetCreate

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

StreetCreate is the builder for creating a Street entity.

func (*StreetCreate) Mutation

func (sc *StreetCreate) Mutation() *StreetMutation

Mutation returns the StreetMutation object of the builder.

func (*StreetCreate) Save

func (sc *StreetCreate) Save(ctx context.Context) (*Street, error)

Save creates the Street in the database.

func (*StreetCreate) SaveX

func (sc *StreetCreate) SaveX(ctx context.Context) *Street

SaveX calls Save and panics if Save returns an error.

func (*StreetCreate) SetCity

func (sc *StreetCreate) SetCity(c *City) *StreetCreate

SetCity sets the "city" edge to the City entity.

func (*StreetCreate) SetCityID

func (sc *StreetCreate) SetCityID(id int) *StreetCreate

SetCityID sets the "city" edge to the City entity by ID.

func (*StreetCreate) SetName

func (sc *StreetCreate) SetName(s string) *StreetCreate

SetName sets the "name" field.

func (*StreetCreate) SetNillableCityID

func (sc *StreetCreate) SetNillableCityID(id *int) *StreetCreate

SetNillableCityID sets the "city" edge to the City entity by ID if the given value is not nil.

type StreetCreateBulk

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

StreetCreateBulk is the builder for creating many Street entities in bulk.

func (*StreetCreateBulk) Save

func (scb *StreetCreateBulk) Save(ctx context.Context) ([]*Street, error)

Save creates the Street entities in the database.

func (*StreetCreateBulk) SaveX

func (scb *StreetCreateBulk) SaveX(ctx context.Context) []*Street

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

type StreetDelete

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

StreetDelete is the builder for deleting a Street entity.

func (*StreetDelete) Exec

func (sd *StreetDelete) Exec(ctx context.Context) (int, error)

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

func (*StreetDelete) ExecX

func (sd *StreetDelete) ExecX(ctx context.Context) int

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

func (*StreetDelete) Where

func (sd *StreetDelete) Where(ps ...predicate.Street) *StreetDelete

Where adds a new predicate to the StreetDelete builder.

type StreetDeleteOne

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

StreetDeleteOne is the builder for deleting a single Street entity.

func (*StreetDeleteOne) Exec

func (sdo *StreetDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*StreetDeleteOne) ExecX

func (sdo *StreetDeleteOne) ExecX(ctx context.Context)

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

type StreetEdges

type StreetEdges struct {
	// City holds the value of the city edge.
	City *City `json:"city,omitempty"`
	// contains filtered or unexported fields
}

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

func (StreetEdges) CityOrErr

func (e StreetEdges) CityOrErr() (*City, error)

CityOrErr returns the City value or an error if the edge was not loaded in eager-loading, or loaded but was not found.

type StreetGroupBy

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

StreetGroupBy is the group-by builder for Street entities.

func (*StreetGroupBy) Aggregate

func (sgb *StreetGroupBy) Aggregate(fns ...AggregateFunc) *StreetGroupBy

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

func (*StreetGroupBy) Bool

func (sgb *StreetGroupBy) Bool(ctx context.Context) (_ bool, err error)

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

func (*StreetGroupBy) BoolX

func (sgb *StreetGroupBy) BoolX(ctx context.Context) bool

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

func (*StreetGroupBy) Bools

func (sgb *StreetGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*StreetGroupBy) BoolsX

func (sgb *StreetGroupBy) BoolsX(ctx context.Context) []bool

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

func (*StreetGroupBy) Float64

func (sgb *StreetGroupBy) Float64(ctx context.Context) (_ float64, err error)

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

func (*StreetGroupBy) Float64X

func (sgb *StreetGroupBy) Float64X(ctx context.Context) float64

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

func (*StreetGroupBy) Float64s

func (sgb *StreetGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*StreetGroupBy) Float64sX

func (sgb *StreetGroupBy) Float64sX(ctx context.Context) []float64

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

func (*StreetGroupBy) Int

func (sgb *StreetGroupBy) Int(ctx context.Context) (_ int, err error)

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

func (*StreetGroupBy) IntX

func (sgb *StreetGroupBy) IntX(ctx context.Context) int

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

func (*StreetGroupBy) Ints

func (sgb *StreetGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*StreetGroupBy) IntsX

func (sgb *StreetGroupBy) IntsX(ctx context.Context) []int

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

func (*StreetGroupBy) Scan

func (sgb *StreetGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*StreetGroupBy) ScanX

func (sgb *StreetGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*StreetGroupBy) String

func (sgb *StreetGroupBy) String(ctx context.Context) (_ string, err error)

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

func (*StreetGroupBy) StringX

func (sgb *StreetGroupBy) StringX(ctx context.Context) string

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

func (*StreetGroupBy) Strings

func (sgb *StreetGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*StreetGroupBy) StringsX

func (sgb *StreetGroupBy) StringsX(ctx context.Context) []string

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

type StreetMutation

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

StreetMutation represents an operation that mutates the Street nodes in the graph.

func (*StreetMutation) AddField

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

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

func (*StreetMutation) AddedEdges

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

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

func (*StreetMutation) AddedField

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

AddedField returns the numeric value that was incremented/decremented on a field with the given name. The second boolean return value indicates that this field was not set, or was not defined in the schema.

func (*StreetMutation) AddedFields

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

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

func (*StreetMutation) AddedIDs

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

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

func (*StreetMutation) CityCleared

func (m *StreetMutation) CityCleared() bool

CityCleared reports if the "city" edge to the City entity was cleared.

func (*StreetMutation) CityID

func (m *StreetMutation) CityID() (id int, exists bool)

CityID returns the "city" edge ID in the mutation.

func (*StreetMutation) CityIDs

func (m *StreetMutation) CityIDs() (ids []int)

CityIDs returns the "city" edge IDs in the mutation. Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use CityID instead. It exists only for internal usage by the builders.

func (*StreetMutation) ClearCity

func (m *StreetMutation) ClearCity()

ClearCity clears the "city" edge to the City entity.

func (*StreetMutation) ClearEdge

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

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

func (*StreetMutation) ClearField

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

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

func (*StreetMutation) ClearedEdges

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

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

func (*StreetMutation) ClearedFields

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

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

func (StreetMutation) Client

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

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

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

func (*StreetMutation) Field

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

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

func (*StreetMutation) FieldCleared

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

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

func (*StreetMutation) Fields

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

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

func (*StreetMutation) ID

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

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

func (*StreetMutation) Name

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

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

func (*StreetMutation) OldField

func (m *StreetMutation) OldField(ctx context.Context, name string) (ent.Value, error)

OldField returns the old value of the field from the database. An error is returned if the mutation operation is not UpdateOne, or the query to the database failed.

func (*StreetMutation) OldName

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

OldName returns the old "name" field's value of the Street entity. If the Street object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*StreetMutation) Op

func (m *StreetMutation) Op() Op

Op returns the operation name.

func (*StreetMutation) RemovedEdges

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

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

func (*StreetMutation) RemovedIDs

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

RemovedIDs returns all IDs (to other nodes) that were removed for the edge with the given name in this mutation.

func (*StreetMutation) ResetCity

func (m *StreetMutation) ResetCity()

ResetCity resets all changes to the "city" edge.

func (*StreetMutation) ResetEdge

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

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

func (*StreetMutation) ResetField

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

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

func (*StreetMutation) ResetName

func (m *StreetMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*StreetMutation) SetCityID

func (m *StreetMutation) SetCityID(id int)

SetCityID sets the "city" edge to the City entity by id.

func (*StreetMutation) SetField

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

SetField sets the value of a field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

func (*StreetMutation) SetName

func (m *StreetMutation) SetName(s string)

SetName sets the "name" field.

func (StreetMutation) Tx

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

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

func (*StreetMutation) Type

func (m *StreetMutation) Type() string

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

type StreetQuery

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

StreetQuery is the builder for querying Street entities.

func (*StreetQuery) All

func (sq *StreetQuery) All(ctx context.Context) ([]*Street, error)

All executes the query and returns a list of Streets.

func (*StreetQuery) AllX

func (sq *StreetQuery) AllX(ctx context.Context) []*Street

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

func (*StreetQuery) Clone

func (sq *StreetQuery) Clone() *StreetQuery

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

func (*StreetQuery) Count

func (sq *StreetQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*StreetQuery) CountX

func (sq *StreetQuery) CountX(ctx context.Context) int

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

func (*StreetQuery) Exist

func (sq *StreetQuery) Exist(ctx context.Context) (bool, error)

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

func (*StreetQuery) ExistX

func (sq *StreetQuery) ExistX(ctx context.Context) bool

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

func (*StreetQuery) First

func (sq *StreetQuery) First(ctx context.Context) (*Street, error)

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

func (*StreetQuery) FirstID

func (sq *StreetQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*StreetQuery) FirstIDX

func (sq *StreetQuery) FirstIDX(ctx context.Context) int

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

func (*StreetQuery) FirstX

func (sq *StreetQuery) FirstX(ctx context.Context) *Street

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

func (*StreetQuery) GroupBy

func (sq *StreetQuery) GroupBy(field string, fields ...string) *StreetGroupBy

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

Example:

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

client.Street.Query().
	GroupBy(street.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*StreetQuery) IDs

func (sq *StreetQuery) IDs(ctx context.Context) ([]int, error)

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

func (*StreetQuery) IDsX

func (sq *StreetQuery) IDsX(ctx context.Context) []int

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

func (*StreetQuery) Limit

func (sq *StreetQuery) Limit(limit int) *StreetQuery

Limit adds a limit step to the query.

func (*StreetQuery) Offset

func (sq *StreetQuery) Offset(offset int) *StreetQuery

Offset adds an offset step to the query.

func (*StreetQuery) Only

func (sq *StreetQuery) Only(ctx context.Context) (*Street, error)

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

func (*StreetQuery) OnlyID

func (sq *StreetQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*StreetQuery) OnlyIDX

func (sq *StreetQuery) OnlyIDX(ctx context.Context) int

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

func (*StreetQuery) OnlyX

func (sq *StreetQuery) OnlyX(ctx context.Context) *Street

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

func (*StreetQuery) Order

func (sq *StreetQuery) Order(o ...OrderFunc) *StreetQuery

Order adds an order step to the query.

func (*StreetQuery) QueryCity

func (sq *StreetQuery) QueryCity() *CityQuery

QueryCity chains the current query on the "city" edge.

func (*StreetQuery) Select

func (sq *StreetQuery) Select(field string, fields ...string) *StreetSelect

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

Example:

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

client.Street.Query().
	Select(street.FieldName).
	Scan(ctx, &v)

func (*StreetQuery) Unique added in v0.8.0

func (sq *StreetQuery) Unique(unique bool) *StreetQuery

Unique configures the query builder to filter duplicate records on query. By default, unique is set to true, and can be disabled using this method.

func (*StreetQuery) Where

func (sq *StreetQuery) Where(ps ...predicate.Street) *StreetQuery

Where adds a new predicate for the StreetQuery builder.

func (*StreetQuery) WithCity

func (sq *StreetQuery) WithCity(opts ...func(*CityQuery)) *StreetQuery

WithCity tells the query-builder to eager-load the nodes that are connected to the "city" edge. The optional arguments are used to configure the query builder of the edge.

type StreetSelect

type StreetSelect struct {
	*StreetQuery
	// contains filtered or unexported fields
}

StreetSelect is the builder for selecting fields of Street entities.

func (*StreetSelect) Bool

func (ss *StreetSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*StreetSelect) BoolX

func (ss *StreetSelect) BoolX(ctx context.Context) bool

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

func (*StreetSelect) Bools

func (ss *StreetSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*StreetSelect) BoolsX

func (ss *StreetSelect) BoolsX(ctx context.Context) []bool

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

func (*StreetSelect) Float64

func (ss *StreetSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*StreetSelect) Float64X

func (ss *StreetSelect) Float64X(ctx context.Context) float64

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

func (*StreetSelect) Float64s

func (ss *StreetSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*StreetSelect) Float64sX

func (ss *StreetSelect) Float64sX(ctx context.Context) []float64

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

func (*StreetSelect) Int

func (ss *StreetSelect) Int(ctx context.Context) (_ int, err error)

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

func (*StreetSelect) IntX

func (ss *StreetSelect) IntX(ctx context.Context) int

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

func (*StreetSelect) Ints

func (ss *StreetSelect) Ints(ctx context.Context) ([]int, error)

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

func (*StreetSelect) IntsX

func (ss *StreetSelect) IntsX(ctx context.Context) []int

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

func (*StreetSelect) Scan

func (ss *StreetSelect) Scan(ctx context.Context, v interface{}) error

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

func (*StreetSelect) ScanX

func (ss *StreetSelect) ScanX(ctx context.Context, v interface{})

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

func (*StreetSelect) String

func (ss *StreetSelect) String(ctx context.Context) (_ string, err error)

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

func (*StreetSelect) StringX

func (ss *StreetSelect) StringX(ctx context.Context) string

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

func (*StreetSelect) Strings

func (ss *StreetSelect) Strings(ctx context.Context) ([]string, error)

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

func (*StreetSelect) StringsX

func (ss *StreetSelect) StringsX(ctx context.Context) []string

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

type StreetUpdate

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

StreetUpdate is the builder for updating Street entities.

func (*StreetUpdate) ClearCity

func (su *StreetUpdate) ClearCity() *StreetUpdate

ClearCity clears the "city" edge to the City entity.

func (*StreetUpdate) Exec

func (su *StreetUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*StreetUpdate) ExecX

func (su *StreetUpdate) ExecX(ctx context.Context)

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

func (*StreetUpdate) Mutation

func (su *StreetUpdate) Mutation() *StreetMutation

Mutation returns the StreetMutation object of the builder.

func (*StreetUpdate) Save

func (su *StreetUpdate) Save(ctx context.Context) (int, error)

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

func (*StreetUpdate) SaveX

func (su *StreetUpdate) SaveX(ctx context.Context) int

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

func (*StreetUpdate) SetCity

func (su *StreetUpdate) SetCity(c *City) *StreetUpdate

SetCity sets the "city" edge to the City entity.

func (*StreetUpdate) SetCityID

func (su *StreetUpdate) SetCityID(id int) *StreetUpdate

SetCityID sets the "city" edge to the City entity by ID.

func (*StreetUpdate) SetName

func (su *StreetUpdate) SetName(s string) *StreetUpdate

SetName sets the "name" field.

func (*StreetUpdate) SetNillableCityID

func (su *StreetUpdate) SetNillableCityID(id *int) *StreetUpdate

SetNillableCityID sets the "city" edge to the City entity by ID if the given value is not nil.

func (*StreetUpdate) Where

func (su *StreetUpdate) Where(ps ...predicate.Street) *StreetUpdate

Where adds a new predicate for the StreetUpdate builder.

type StreetUpdateOne

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

StreetUpdateOne is the builder for updating a single Street entity.

func (*StreetUpdateOne) ClearCity

func (suo *StreetUpdateOne) ClearCity() *StreetUpdateOne

ClearCity clears the "city" edge to the City entity.

func (*StreetUpdateOne) Exec

func (suo *StreetUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*StreetUpdateOne) ExecX

func (suo *StreetUpdateOne) ExecX(ctx context.Context)

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

func (*StreetUpdateOne) Mutation

func (suo *StreetUpdateOne) Mutation() *StreetMutation

Mutation returns the StreetMutation object of the builder.

func (*StreetUpdateOne) Save

func (suo *StreetUpdateOne) Save(ctx context.Context) (*Street, error)

Save executes the query and returns the updated Street entity.

func (*StreetUpdateOne) SaveX

func (suo *StreetUpdateOne) SaveX(ctx context.Context) *Street

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

func (*StreetUpdateOne) Select added in v0.8.0

func (suo *StreetUpdateOne) Select(field string, fields ...string) *StreetUpdateOne

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

func (*StreetUpdateOne) SetCity

func (suo *StreetUpdateOne) SetCity(c *City) *StreetUpdateOne

SetCity sets the "city" edge to the City entity.

func (*StreetUpdateOne) SetCityID

func (suo *StreetUpdateOne) SetCityID(id int) *StreetUpdateOne

SetCityID sets the "city" edge to the City entity by ID.

func (*StreetUpdateOne) SetName

func (suo *StreetUpdateOne) SetName(s string) *StreetUpdateOne

SetName sets the "name" field.

func (*StreetUpdateOne) SetNillableCityID

func (suo *StreetUpdateOne) SetNillableCityID(id *int) *StreetUpdateOne

SetNillableCityID sets the "city" edge to the City entity by ID if the given value is not nil.

type Streets

type Streets []*Street

Streets is a parsable slice of Street.

type Tx

type Tx struct {

	// City is the client for interacting with the City builders.
	City *CityClient
	// Street is the client for interacting with the Street builders.
	Street *StreetClient
	// contains filtered or unexported fields
}

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

func TxFromContext

func TxFromContext(ctx context.Context) *Tx

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

func (*Tx) Client

func (tx *Tx) Client() *Client

Client returns a Client that binds to current transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) OnCommit

func (tx *Tx) OnCommit(f CommitHook)

OnCommit adds a hook to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f RollbackHook)

OnRollback adds a hook to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

type ValidationError

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

ValidationError returns when validating a field fails.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Value

type Value = ent.Value

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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