Documentation ¶
Index ¶
- Constants
- func IsConstraintError(err error) bool
- func IsNotFound(err error) bool
- func IsNotLoaded(err error) bool
- func IsNotSingular(err error) bool
- func IsValidationError(err error) bool
- func MaskNotFound(err error) error
- func NewContext(parent context.Context, c *Client) context.Context
- func NewTxContext(parent context.Context, tx *Tx) context.Context
- type AggregateFunc
- type Cities
- type City
- type CityClient
- func (c *CityClient) Create() *CityCreate
- func (c *CityClient) CreateBulk(builders ...*CityCreate) *CityCreateBulk
- func (c *CityClient) Delete() *CityDelete
- func (c *CityClient) DeleteOne(ci *City) *CityDeleteOne
- func (c *CityClient) DeleteOneID(id int) *CityDeleteOne
- func (c *CityClient) Get(ctx context.Context, id int) (*City, error)
- func (c *CityClient) GetX(ctx context.Context, id int) *City
- func (c *CityClient) Hooks() []Hook
- func (c *CityClient) Query() *CityQuery
- func (c *CityClient) QueryStreets(ci *City) *StreetQuery
- func (c *CityClient) Update() *CityUpdate
- func (c *CityClient) UpdateOne(ci *City) *CityUpdateOne
- func (c *CityClient) UpdateOneID(id int) *CityUpdateOne
- func (c *CityClient) Use(hooks ...Hook)
- type CityCreate
- func (cc *CityCreate) AddStreetIDs(ids ...int) *CityCreate
- func (cc *CityCreate) AddStreets(s ...*Street) *CityCreate
- func (cc *CityCreate) Mutation() *CityMutation
- func (cc *CityCreate) Save(ctx context.Context) (*City, error)
- func (cc *CityCreate) SaveX(ctx context.Context) *City
- func (cc *CityCreate) SetName(s string) *CityCreate
- type CityCreateBulk
- type CityDelete
- type CityDeleteOne
- type CityEdges
- type CityGroupBy
- func (cgb *CityGroupBy) Aggregate(fns ...AggregateFunc) *CityGroupBy
- func (cgb *CityGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (cgb *CityGroupBy) BoolX(ctx context.Context) bool
- func (cgb *CityGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (cgb *CityGroupBy) BoolsX(ctx context.Context) []bool
- func (cgb *CityGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (cgb *CityGroupBy) Float64X(ctx context.Context) float64
- func (cgb *CityGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (cgb *CityGroupBy) Float64sX(ctx context.Context) []float64
- func (cgb *CityGroupBy) Int(ctx context.Context) (_ int, err error)
- func (cgb *CityGroupBy) IntX(ctx context.Context) int
- func (cgb *CityGroupBy) Ints(ctx context.Context) ([]int, error)
- func (cgb *CityGroupBy) IntsX(ctx context.Context) []int
- func (cgb *CityGroupBy) Scan(ctx context.Context, v interface{}) error
- func (cgb *CityGroupBy) ScanX(ctx context.Context, v interface{})
- func (cgb *CityGroupBy) String(ctx context.Context) (_ string, err error)
- func (cgb *CityGroupBy) StringX(ctx context.Context) string
- func (cgb *CityGroupBy) Strings(ctx context.Context) ([]string, error)
- func (cgb *CityGroupBy) StringsX(ctx context.Context) []string
- type CityMutation
- func (m *CityMutation) AddField(name string, value ent.Value) error
- func (m *CityMutation) AddStreetIDs(ids ...int)
- func (m *CityMutation) AddedEdges() []string
- func (m *CityMutation) AddedField(name string) (ent.Value, bool)
- func (m *CityMutation) AddedFields() []string
- func (m *CityMutation) AddedIDs(name string) []ent.Value
- func (m *CityMutation) ClearEdge(name string) error
- func (m *CityMutation) ClearField(name string) error
- func (m *CityMutation) ClearStreets()
- func (m *CityMutation) ClearedEdges() []string
- func (m *CityMutation) ClearedFields() []string
- func (m CityMutation) Client() *Client
- func (m *CityMutation) EdgeCleared(name string) bool
- func (m *CityMutation) Field(name string) (ent.Value, bool)
- func (m *CityMutation) FieldCleared(name string) bool
- func (m *CityMutation) Fields() []string
- func (m *CityMutation) ID() (id int, exists bool)
- func (m *CityMutation) Name() (r string, exists bool)
- func (m *CityMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *CityMutation) OldName(ctx context.Context) (v string, err error)
- func (m *CityMutation) Op() Op
- func (m *CityMutation) RemoveStreetIDs(ids ...int)
- func (m *CityMutation) RemovedEdges() []string
- func (m *CityMutation) RemovedIDs(name string) []ent.Value
- func (m *CityMutation) RemovedStreetsIDs() (ids []int)
- func (m *CityMutation) ResetEdge(name string) error
- func (m *CityMutation) ResetField(name string) error
- func (m *CityMutation) ResetName()
- func (m *CityMutation) ResetStreets()
- func (m *CityMutation) SetField(name string, value ent.Value) error
- func (m *CityMutation) SetName(s string)
- func (m *CityMutation) StreetsCleared() bool
- func (m *CityMutation) StreetsIDs() (ids []int)
- func (m CityMutation) Tx() (*Tx, error)
- func (m *CityMutation) Type() string
- type CityQuery
- func (cq *CityQuery) All(ctx context.Context) ([]*City, error)
- func (cq *CityQuery) AllX(ctx context.Context) []*City
- func (cq *CityQuery) Clone() *CityQuery
- func (cq *CityQuery) Count(ctx context.Context) (int, error)
- func (cq *CityQuery) CountX(ctx context.Context) int
- func (cq *CityQuery) Exist(ctx context.Context) (bool, error)
- func (cq *CityQuery) ExistX(ctx context.Context) bool
- func (cq *CityQuery) First(ctx context.Context) (*City, error)
- func (cq *CityQuery) FirstID(ctx context.Context) (id int, err error)
- func (cq *CityQuery) FirstIDX(ctx context.Context) int
- func (cq *CityQuery) FirstX(ctx context.Context) *City
- func (cq *CityQuery) GroupBy(field string, fields ...string) *CityGroupBy
- func (cq *CityQuery) IDs(ctx context.Context) ([]int, error)
- func (cq *CityQuery) IDsX(ctx context.Context) []int
- func (cq *CityQuery) Limit(limit int) *CityQuery
- func (cq *CityQuery) Offset(offset int) *CityQuery
- func (cq *CityQuery) Only(ctx context.Context) (*City, error)
- func (cq *CityQuery) OnlyID(ctx context.Context) (id int, err error)
- func (cq *CityQuery) OnlyIDX(ctx context.Context) int
- func (cq *CityQuery) OnlyX(ctx context.Context) *City
- func (cq *CityQuery) Order(o ...OrderFunc) *CityQuery
- func (cq *CityQuery) QueryStreets() *StreetQuery
- func (cq *CityQuery) Select(field string, fields ...string) *CitySelect
- func (cq *CityQuery) Where(ps ...predicate.City) *CityQuery
- func (cq *CityQuery) WithStreets(opts ...func(*StreetQuery)) *CityQuery
- type CitySelect
- func (cs *CitySelect) Bool(ctx context.Context) (_ bool, err error)
- func (cs *CitySelect) BoolX(ctx context.Context) bool
- func (cs *CitySelect) Bools(ctx context.Context) ([]bool, error)
- func (cs *CitySelect) BoolsX(ctx context.Context) []bool
- func (cs *CitySelect) Float64(ctx context.Context) (_ float64, err error)
- func (cs *CitySelect) Float64X(ctx context.Context) float64
- func (cs *CitySelect) Float64s(ctx context.Context) ([]float64, error)
- func (cs *CitySelect) Float64sX(ctx context.Context) []float64
- func (cs *CitySelect) Int(ctx context.Context) (_ int, err error)
- func (cs *CitySelect) IntX(ctx context.Context) int
- func (cs *CitySelect) Ints(ctx context.Context) ([]int, error)
- func (cs *CitySelect) IntsX(ctx context.Context) []int
- func (cs *CitySelect) Scan(ctx context.Context, v interface{}) error
- func (cs *CitySelect) ScanX(ctx context.Context, v interface{})
- func (cs *CitySelect) String(ctx context.Context) (_ string, err error)
- func (cs *CitySelect) StringX(ctx context.Context) string
- func (cs *CitySelect) Strings(ctx context.Context) ([]string, error)
- func (cs *CitySelect) StringsX(ctx context.Context) []string
- type CityUpdate
- func (cu *CityUpdate) AddStreetIDs(ids ...int) *CityUpdate
- func (cu *CityUpdate) AddStreets(s ...*Street) *CityUpdate
- func (cu *CityUpdate) ClearStreets() *CityUpdate
- func (cu *CityUpdate) Exec(ctx context.Context) error
- func (cu *CityUpdate) ExecX(ctx context.Context)
- func (cu *CityUpdate) Mutation() *CityMutation
- func (cu *CityUpdate) RemoveStreetIDs(ids ...int) *CityUpdate
- func (cu *CityUpdate) RemoveStreets(s ...*Street) *CityUpdate
- func (cu *CityUpdate) Save(ctx context.Context) (int, error)
- func (cu *CityUpdate) SaveX(ctx context.Context) int
- func (cu *CityUpdate) SetName(s string) *CityUpdate
- func (cu *CityUpdate) Where(ps ...predicate.City) *CityUpdate
- type CityUpdateOne
- func (cuo *CityUpdateOne) AddStreetIDs(ids ...int) *CityUpdateOne
- func (cuo *CityUpdateOne) AddStreets(s ...*Street) *CityUpdateOne
- func (cuo *CityUpdateOne) ClearStreets() *CityUpdateOne
- func (cuo *CityUpdateOne) Exec(ctx context.Context) error
- func (cuo *CityUpdateOne) ExecX(ctx context.Context)
- func (cuo *CityUpdateOne) Mutation() *CityMutation
- func (cuo *CityUpdateOne) RemoveStreetIDs(ids ...int) *CityUpdateOne
- func (cuo *CityUpdateOne) RemoveStreets(s ...*Street) *CityUpdateOne
- func (cuo *CityUpdateOne) Save(ctx context.Context) (*City, error)
- func (cuo *CityUpdateOne) SaveX(ctx context.Context) *City
- func (cuo *CityUpdateOne) SetName(s string) *CityUpdateOne
- type Client
- type CommitFunc
- type CommitHook
- type Committer
- type ConstraintError
- type Hook
- type MutateFunc
- type Mutation
- type Mutator
- type NotFoundError
- type NotLoadedError
- type NotSingularError
- type Op
- type Option
- type OrderFunc
- type Policy
- type Query
- type RollbackFunc
- type RollbackHook
- type Rollbacker
- type Street
- type StreetClient
- func (c *StreetClient) Create() *StreetCreate
- func (c *StreetClient) CreateBulk(builders ...*StreetCreate) *StreetCreateBulk
- func (c *StreetClient) Delete() *StreetDelete
- func (c *StreetClient) DeleteOne(s *Street) *StreetDeleteOne
- func (c *StreetClient) DeleteOneID(id int) *StreetDeleteOne
- func (c *StreetClient) Get(ctx context.Context, id int) (*Street, error)
- func (c *StreetClient) GetX(ctx context.Context, id int) *Street
- func (c *StreetClient) Hooks() []Hook
- func (c *StreetClient) Query() *StreetQuery
- func (c *StreetClient) QueryCity(s *Street) *CityQuery
- func (c *StreetClient) Update() *StreetUpdate
- func (c *StreetClient) UpdateOne(s *Street) *StreetUpdateOne
- func (c *StreetClient) UpdateOneID(id int) *StreetUpdateOne
- func (c *StreetClient) Use(hooks ...Hook)
- type StreetCreate
- func (sc *StreetCreate) Mutation() *StreetMutation
- func (sc *StreetCreate) Save(ctx context.Context) (*Street, error)
- func (sc *StreetCreate) SaveX(ctx context.Context) *Street
- func (sc *StreetCreate) SetCity(c *City) *StreetCreate
- func (sc *StreetCreate) SetCityID(id int) *StreetCreate
- func (sc *StreetCreate) SetName(s string) *StreetCreate
- func (sc *StreetCreate) SetNillableCityID(id *int) *StreetCreate
- type StreetCreateBulk
- type StreetDelete
- type StreetDeleteOne
- type StreetEdges
- type StreetGroupBy
- func (sgb *StreetGroupBy) Aggregate(fns ...AggregateFunc) *StreetGroupBy
- func (sgb *StreetGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (sgb *StreetGroupBy) BoolX(ctx context.Context) bool
- func (sgb *StreetGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (sgb *StreetGroupBy) BoolsX(ctx context.Context) []bool
- func (sgb *StreetGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (sgb *StreetGroupBy) Float64X(ctx context.Context) float64
- func (sgb *StreetGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (sgb *StreetGroupBy) Float64sX(ctx context.Context) []float64
- func (sgb *StreetGroupBy) Int(ctx context.Context) (_ int, err error)
- func (sgb *StreetGroupBy) IntX(ctx context.Context) int
- func (sgb *StreetGroupBy) Ints(ctx context.Context) ([]int, error)
- func (sgb *StreetGroupBy) IntsX(ctx context.Context) []int
- func (sgb *StreetGroupBy) Scan(ctx context.Context, v interface{}) error
- func (sgb *StreetGroupBy) ScanX(ctx context.Context, v interface{})
- func (sgb *StreetGroupBy) String(ctx context.Context) (_ string, err error)
- func (sgb *StreetGroupBy) StringX(ctx context.Context) string
- func (sgb *StreetGroupBy) Strings(ctx context.Context) ([]string, error)
- func (sgb *StreetGroupBy) StringsX(ctx context.Context) []string
- type StreetMutation
- func (m *StreetMutation) AddField(name string, value ent.Value) error
- func (m *StreetMutation) AddedEdges() []string
- func (m *StreetMutation) AddedField(name string) (ent.Value, bool)
- func (m *StreetMutation) AddedFields() []string
- func (m *StreetMutation) AddedIDs(name string) []ent.Value
- func (m *StreetMutation) CityCleared() bool
- func (m *StreetMutation) CityID() (id int, exists bool)
- func (m *StreetMutation) CityIDs() (ids []int)
- func (m *StreetMutation) ClearCity()
- func (m *StreetMutation) ClearEdge(name string) error
- func (m *StreetMutation) ClearField(name string) error
- func (m *StreetMutation) ClearedEdges() []string
- func (m *StreetMutation) ClearedFields() []string
- func (m StreetMutation) Client() *Client
- func (m *StreetMutation) EdgeCleared(name string) bool
- func (m *StreetMutation) Field(name string) (ent.Value, bool)
- func (m *StreetMutation) FieldCleared(name string) bool
- func (m *StreetMutation) Fields() []string
- func (m *StreetMutation) ID() (id int, exists bool)
- func (m *StreetMutation) Name() (r string, exists bool)
- func (m *StreetMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *StreetMutation) OldName(ctx context.Context) (v string, err error)
- func (m *StreetMutation) Op() Op
- func (m *StreetMutation) RemovedEdges() []string
- func (m *StreetMutation) RemovedIDs(name string) []ent.Value
- func (m *StreetMutation) ResetCity()
- func (m *StreetMutation) ResetEdge(name string) error
- func (m *StreetMutation) ResetField(name string) error
- func (m *StreetMutation) ResetName()
- func (m *StreetMutation) SetCityID(id int)
- func (m *StreetMutation) SetField(name string, value ent.Value) error
- func (m *StreetMutation) SetName(s string)
- func (m StreetMutation) Tx() (*Tx, error)
- func (m *StreetMutation) Type() string
- type StreetQuery
- func (sq *StreetQuery) All(ctx context.Context) ([]*Street, error)
- func (sq *StreetQuery) AllX(ctx context.Context) []*Street
- func (sq *StreetQuery) Clone() *StreetQuery
- func (sq *StreetQuery) Count(ctx context.Context) (int, error)
- func (sq *StreetQuery) CountX(ctx context.Context) int
- func (sq *StreetQuery) Exist(ctx context.Context) (bool, error)
- func (sq *StreetQuery) ExistX(ctx context.Context) bool
- func (sq *StreetQuery) First(ctx context.Context) (*Street, error)
- func (sq *StreetQuery) FirstID(ctx context.Context) (id int, err error)
- func (sq *StreetQuery) FirstIDX(ctx context.Context) int
- func (sq *StreetQuery) FirstX(ctx context.Context) *Street
- func (sq *StreetQuery) GroupBy(field string, fields ...string) *StreetGroupBy
- func (sq *StreetQuery) IDs(ctx context.Context) ([]int, error)
- func (sq *StreetQuery) IDsX(ctx context.Context) []int
- func (sq *StreetQuery) Limit(limit int) *StreetQuery
- func (sq *StreetQuery) Offset(offset int) *StreetQuery
- func (sq *StreetQuery) Only(ctx context.Context) (*Street, error)
- func (sq *StreetQuery) OnlyID(ctx context.Context) (id int, err error)
- func (sq *StreetQuery) OnlyIDX(ctx context.Context) int
- func (sq *StreetQuery) OnlyX(ctx context.Context) *Street
- func (sq *StreetQuery) Order(o ...OrderFunc) *StreetQuery
- func (sq *StreetQuery) QueryCity() *CityQuery
- func (sq *StreetQuery) Select(field string, fields ...string) *StreetSelect
- func (sq *StreetQuery) Where(ps ...predicate.Street) *StreetQuery
- func (sq *StreetQuery) WithCity(opts ...func(*CityQuery)) *StreetQuery
- type StreetSelect
- func (ss *StreetSelect) Bool(ctx context.Context) (_ bool, err error)
- func (ss *StreetSelect) BoolX(ctx context.Context) bool
- func (ss *StreetSelect) Bools(ctx context.Context) ([]bool, error)
- func (ss *StreetSelect) BoolsX(ctx context.Context) []bool
- func (ss *StreetSelect) Float64(ctx context.Context) (_ float64, err error)
- func (ss *StreetSelect) Float64X(ctx context.Context) float64
- func (ss *StreetSelect) Float64s(ctx context.Context) ([]float64, error)
- func (ss *StreetSelect) Float64sX(ctx context.Context) []float64
- func (ss *StreetSelect) Int(ctx context.Context) (_ int, err error)
- func (ss *StreetSelect) IntX(ctx context.Context) int
- func (ss *StreetSelect) Ints(ctx context.Context) ([]int, error)
- func (ss *StreetSelect) IntsX(ctx context.Context) []int
- func (ss *StreetSelect) Scan(ctx context.Context, v interface{}) error
- func (ss *StreetSelect) ScanX(ctx context.Context, v interface{})
- func (ss *StreetSelect) String(ctx context.Context) (_ string, err error)
- func (ss *StreetSelect) StringX(ctx context.Context) string
- func (ss *StreetSelect) Strings(ctx context.Context) ([]string, error)
- func (ss *StreetSelect) StringsX(ctx context.Context) []string
- type StreetUpdate
- func (su *StreetUpdate) ClearCity() *StreetUpdate
- func (su *StreetUpdate) Exec(ctx context.Context) error
- func (su *StreetUpdate) ExecX(ctx context.Context)
- func (su *StreetUpdate) Mutation() *StreetMutation
- func (su *StreetUpdate) Save(ctx context.Context) (int, error)
- func (su *StreetUpdate) SaveX(ctx context.Context) int
- func (su *StreetUpdate) SetCity(c *City) *StreetUpdate
- func (su *StreetUpdate) SetCityID(id int) *StreetUpdate
- func (su *StreetUpdate) SetName(s string) *StreetUpdate
- func (su *StreetUpdate) SetNillableCityID(id *int) *StreetUpdate
- func (su *StreetUpdate) Where(ps ...predicate.Street) *StreetUpdate
- type StreetUpdateOne
- func (suo *StreetUpdateOne) ClearCity() *StreetUpdateOne
- func (suo *StreetUpdateOne) Exec(ctx context.Context) error
- func (suo *StreetUpdateOne) ExecX(ctx context.Context)
- func (suo *StreetUpdateOne) Mutation() *StreetMutation
- func (suo *StreetUpdateOne) Save(ctx context.Context) (*Street, error)
- func (suo *StreetUpdateOne) SaveX(ctx context.Context) *Street
- func (suo *StreetUpdateOne) SetCity(c *City) *StreetUpdateOne
- func (suo *StreetUpdateOne) SetCityID(id int) *StreetUpdateOne
- func (suo *StreetUpdateOne) SetName(s string) *StreetUpdateOne
- func (suo *StreetUpdateOne) SetNillableCityID(id *int) *StreetUpdateOne
- type Streets
- type Tx
- type ValidationError
- type Value
Constants ¶
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 ¶
IsConstraintError returns a boolean indicating whether the error is a constraint failure.
func IsNotFound ¶
IsNotFound returns a boolean indicating whether the error is a not found error.
func IsNotLoaded ¶
IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
func IsNotSingular ¶
IsNotSingular returns a boolean indicating whether the error is a not singular error.
func IsValidationError ¶
IsValidationError returns a boolean indicating whether the error is a validaton error.
func NewContext ¶
NewContext returns a new context with the given Client attached.
Types ¶
type AggregateFunc ¶
AggregateFunc applies an aggregation step on the group-by traversal/selector.
func As ¶
func As(fn AggregateFunc, end string) AggregateFunc
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 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.
func (*City) Unwrap ¶
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 (*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) GetX ¶
func (c *CityClient) GetX(ctx context.Context, id int) *City
GetX is like Get, but panics if an error occurs.
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 Street by ids.
func (*CityCreate) AddStreets ¶
func (cc *CityCreate) AddStreets(s ...*Street) *CityCreate
AddStreets adds the streets edges to Street.
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 a bulk of City entities.
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 delete 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 // contains filtered or unexported fields }
CityEdges holds the relations/edges for other nodes in the graph.
func (CityEdges) StreetsOrErr ¶
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 builder for group-by 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 group-by. It is only allowed when querying group-by 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 querying group-by 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 group-by. It is only allowed when querying group-by 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 querying group-by 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 group-by. It is only allowed when querying group-by 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 querying group-by 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 scan 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 group-by. It is only allowed when querying group-by with one field.
func (*CityGroupBy) StringX ¶
func (cgb *CityGroupBy) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type CityMutation ¶
type CityMutation struct {
// contains filtered or unexported fields
}
CityMutation represents an operation that mutate the Cities nodes in the graph.
func (*CityMutation) AddField ¶
func (m *CityMutation) 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 (*CityMutation) AddStreetIDs ¶
func (m *CityMutation) AddStreetIDs(ids ...int)
AddStreetIDs adds the streets edge to Street 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 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 (*CityMutation) AddedFields ¶
func (m *CityMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented or 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.
func (*CityMutation) ClearEdge ¶
func (m *CityMutation) 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 (*CityMutation) ClearField ¶
func (m *CityMutation) 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 (*CityMutation) ClearStreets ¶ added in v0.4.3
func (m *CityMutation) ClearStreets()
ClearStreets clears the streets edge to Street.
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 indicates if this edge 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 value indicates that this field was not set, or was not define in the schema.
func (*CityMutation) FieldCleared ¶
func (m *CityMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicates if this field 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 in/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 available only if it was provided to the builder.
func (*CityMutation) Name ¶
func (m *CityMutation) Name() (r string, exists bool)
Name returns the name value in the mutation.
func (*CityMutation) OldField ¶
OldField returns the old value of the field from the database. An error is returned if the mutation operation is not UpdateOne, or the query to the database was failed.
func (*CityMutation) OldName ¶
func (m *CityMutation) OldName(ctx context.Context) (v string, err error)
OldName returns the old name value of the City. 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 database query fails.
func (*CityMutation) RemoveStreetIDs ¶
func (m *CityMutation) RemoveStreetIDs(ids ...int)
RemoveStreetIDs removes the streets edge to Street 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 given edge name.
func (*CityMutation) RemovedStreetsIDs ¶
func (m *CityMutation) RemovedStreetsIDs() (ids []int)
RemovedStreets returns the removed ids of streets.
func (*CityMutation) ResetEdge ¶
func (m *CityMutation) 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 (*CityMutation) ResetField ¶
func (m *CityMutation) 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 (*CityMutation) ResetName ¶
func (m *CityMutation) ResetName()
ResetName reset all changes of the "name" field.
func (*CityMutation) ResetStreets ¶
func (m *CityMutation) ResetStreets()
ResetStreets reset all changes of the "streets" edge.
func (*CityMutation) SetField ¶
func (m *CityMutation) 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 (*CityMutation) SetName ¶
func (m *CityMutation) SetName(s string)
SetName sets the name field.
func (*CityMutation) StreetsCleared ¶ added in v0.4.3
func (m *CityMutation) StreetsCleared() bool
StreetsCleared returns if the edge streets was cleared.
func (*CityMutation) StreetsIDs ¶
func (m *CityMutation) StreetsIDs() (ids []int)
StreetsIDs returns the streets 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) Clone ¶
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 (*CityQuery) First ¶
First returns the first City entity in the query. Returns *NotFoundError when no city was found.
func (*CityQuery) FirstID ¶
FirstID returns the first City id in the query. Returns *NotFoundError when no id was found.
func (*CityQuery) FirstIDX ¶ added in v0.5.0
FirstIDX is like FirstID, but panics if an error occurs.
func (*CityQuery) GroupBy ¶
func (cq *CityQuery) GroupBy(field string, fields ...string) *CityGroupBy
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.City.Query(). GroupBy(city.FieldName). Aggregate(ent.Count()). Scan(ctx, &v)
func (*CityQuery) Only ¶
Only returns the only City entity in the query, returns an error if not exactly one entity was returned.
func (*CityQuery) OnlyID ¶
OnlyID returns the only City id in the query, returns an error if not exactly one id was returned.
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 one or more fields from the given query.
Example:
var v []struct { Name string `json:"name,omitempty"` } client.City.Query(). Select(city.FieldName). Scan(ctx, &v)
func (*CityQuery) WithStreets ¶
func (cq *CityQuery) WithStreets(opts ...func(*StreetQuery)) *CityQuery
WithStreets tells the query-builder to eager-loads the nodes that are connected to
the "streets" edge. The optional arguments used to configure the query builder of the edge.
type CitySelect ¶
type CitySelect struct {
// contains filtered or unexported fields
}
CitySelect is the builder for select fields of City entities.
func (*CitySelect) Bool ¶
func (cs *CitySelect) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from 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 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 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 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 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 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 scan 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 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.
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 Street by ids.
func (*CityUpdate) AddStreets ¶
func (cu *CityUpdate) AddStreets(s ...*Street) *CityUpdate
AddStreets adds the streets edges to Street.
func (*CityUpdate) ClearStreets ¶ added in v0.4.3
func (cu *CityUpdate) ClearStreets() *CityUpdate
ClearStreets clears all "streets" edges to type Street.
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 by ids.
func (*CityUpdate) RemoveStreets ¶
func (cu *CityUpdate) RemoveStreets(s ...*Street) *CityUpdate
RemoveStreets removes streets edges to Street.
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 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 Street by ids.
func (*CityUpdateOne) AddStreets ¶
func (cuo *CityUpdateOne) AddStreets(s ...*Street) *CityUpdateOne
AddStreets adds the streets edges to Street.
func (*CityUpdateOne) ClearStreets ¶ added in v0.4.3
func (cuo *CityUpdateOne) ClearStreets() *CityUpdateOne
ClearStreets clears all "streets" edges to type Street.
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 by ids.
func (*CityUpdateOne) RemoveStreets ¶
func (cuo *CityUpdateOne) RemoveStreets(s ...*Street) *CityUpdateOne
RemoveStreets removes streets edges to Street.
func (*CityUpdateOne) Save ¶
func (cuo *CityUpdateOne) Save(ctx context.Context) (*City, error)
Save executes the query and returns the updated entity.
func (*CityUpdateOne) SaveX ¶
func (cuo *CityUpdateOne) SaveX(ctx context.Context) *City
SaveX is like Save, but panics if an error occurs.
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 ¶
FromContext returns the Client stored in a context, or nil if there isn't one.
func Open ¶
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) Debug ¶
Debug returns a new debug-client. It's used to get verbose logging on specific operations.
client.Debug(). City. Query(). Count(ctx)
type CommitFunc ¶
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.
type CommitHook ¶
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 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 MutateFunc ¶
type MutateFunc = ent.MutateFunc
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 RollbackFunc ¶
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.
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 ¶
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) Unwrap ¶
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 (*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) GetX ¶
func (c *StreetClient) GetX(ctx context.Context, id int) *Street
GetX is like Get, but panics if an error occurs.
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 City.
func (*StreetCreate) SetCityID ¶
func (sc *StreetCreate) SetCityID(id int) *StreetCreate
SetCityID sets the city edge to City 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 City 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 a bulk of Street entities.
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 delete 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 // 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 builder for group-by 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 group-by. It is only allowed when querying group-by 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 querying group-by 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 group-by. It is only allowed when querying group-by 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 querying group-by 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 group-by. It is only allowed when querying group-by 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 querying group-by 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 scan 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 group-by. It is only allowed when querying group-by with one field.
func (*StreetGroupBy) StringX ¶
func (sgb *StreetGroupBy) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type StreetMutation ¶
type StreetMutation struct {
// contains filtered or unexported fields
}
StreetMutation represents an operation that mutate the Streets nodes in the graph.
func (*StreetMutation) AddField ¶
func (m *StreetMutation) 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 (*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 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 (*StreetMutation) AddedFields ¶
func (m *StreetMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented or 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.
func (*StreetMutation) CityCleared ¶
func (m *StreetMutation) CityCleared() bool
CityCleared returns if the edge city was cleared.
func (*StreetMutation) CityID ¶
func (m *StreetMutation) CityID() (id int, exists bool)
CityID returns the city id in the mutation.
func (*StreetMutation) CityIDs ¶
func (m *StreetMutation) CityIDs() (ids []int)
CityIDs returns the city 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 City.
func (*StreetMutation) ClearEdge ¶
func (m *StreetMutation) 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 (*StreetMutation) ClearField ¶
func (m *StreetMutation) 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 (*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 indicates if this edge 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 value indicates that this field was not set, or was not define in the schema.
func (*StreetMutation) FieldCleared ¶
func (m *StreetMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicates if this field 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 in/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 available only if it was provided to the builder.
func (*StreetMutation) Name ¶
func (m *StreetMutation) Name() (r string, exists bool)
Name returns the name value in the mutation.
func (*StreetMutation) OldField ¶
OldField returns the old value of the field from the database. An error is returned if the mutation operation is not UpdateOne, or the query to the database was failed.
func (*StreetMutation) OldName ¶
func (m *StreetMutation) OldName(ctx context.Context) (v string, err error)
OldName returns the old name value of the Street. 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 database query fails.
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 given edge name.
func (*StreetMutation) ResetCity ¶
func (m *StreetMutation) ResetCity()
ResetCity reset all changes of the "city" edge.
func (*StreetMutation) ResetEdge ¶
func (m *StreetMutation) 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 (*StreetMutation) ResetField ¶
func (m *StreetMutation) 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 (*StreetMutation) ResetName ¶
func (m *StreetMutation) ResetName()
ResetName reset all changes of the "name" field.
func (*StreetMutation) SetCityID ¶
func (m *StreetMutation) SetCityID(id int)
SetCityID sets the city edge to City by id.
func (*StreetMutation) SetField ¶
func (m *StreetMutation) 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 (*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 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 (*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 in the query. Returns *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 in the query. Returns *NotFoundError when no id was found.
func (*StreetQuery) FirstIDX ¶ added in v0.5.0
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 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 the only Street entity in the query, returns an error if not exactly one entity was returned.
func (*StreetQuery) OnlyID ¶
func (sq *StreetQuery) OnlyID(ctx context.Context) (id int, err error)
OnlyID returns the only Street id in the query, returns an error if not exactly one id was returned.
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 one or more fields from the given query.
Example:
var v []struct { Name string `json:"name,omitempty"` } client.Street.Query(). Select(street.FieldName). Scan(ctx, &v)
func (*StreetQuery) Where ¶
func (sq *StreetQuery) Where(ps ...predicate.Street) *StreetQuery
Where adds a new predicate for the builder.
func (*StreetQuery) WithCity ¶
func (sq *StreetQuery) WithCity(opts ...func(*CityQuery)) *StreetQuery
WithCity tells the query-builder to eager-loads the nodes that are connected to
the "city" edge. The optional arguments used to configure the query builder of the edge.
type StreetSelect ¶
type StreetSelect struct {
// contains filtered or unexported fields
}
StreetSelect is the builder for select fields of Street entities.
func (*StreetSelect) Bool ¶
func (ss *StreetSelect) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from 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 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 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 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 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 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 scan 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 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.
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 type City.
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 City.
func (*StreetUpdate) SetCityID ¶
func (su *StreetUpdate) SetCityID(id int) *StreetUpdate
SetCityID sets the city edge to City 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 City 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 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 type City.
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 entity.
func (*StreetUpdateOne) SaveX ¶
func (suo *StreetUpdateOne) SaveX(ctx context.Context) *Street
SaveX is like Save, but panics if an error occurs.
func (*StreetUpdateOne) SetCity ¶
func (suo *StreetUpdateOne) SetCity(c *City) *StreetUpdateOne
SetCity sets the city edge to City.
func (*StreetUpdateOne) SetCityID ¶
func (suo *StreetUpdateOne) SetCityID(id int) *StreetUpdateOne
SetCityID sets the city edge to City 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 City by id if the given value is not nil.
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 ¶
TxFromContext returns the Tx stored in a context, or nil if there isn't one.
func (*Tx) OnRollback ¶
func (tx *Tx) OnRollback(f RollbackHook)
OnRollback adds a hook to call on rollback.
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.