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 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 Post
- type PostClient
- func (c *PostClient) Create() *PostCreate
- func (c *PostClient) CreateBulk(builders ...*PostCreate) *PostCreateBulk
- func (c *PostClient) Delete() *PostDelete
- func (c *PostClient) DeleteOne(po *Post) *PostDeleteOne
- func (c *PostClient) DeleteOneID(id int) *PostDeleteOne
- func (c *PostClient) Get(ctx context.Context, id int) (*Post, error)
- func (c *PostClient) GetX(ctx context.Context, id int) *Post
- func (c *PostClient) Hooks() []Hook
- func (c *PostClient) Query() *PostQuery
- func (c *PostClient) Update() *PostUpdate
- func (c *PostClient) UpdateOne(po *Post) *PostUpdateOne
- func (c *PostClient) UpdateOneID(id int) *PostUpdateOne
- func (c *PostClient) Use(hooks ...Hook)
- type PostCreate
- func (pc *PostCreate) Exec(ctx context.Context) error
- func (pc *PostCreate) ExecX(ctx context.Context)
- func (pc *PostCreate) Mutation() *PostMutation
- func (pc *PostCreate) OnConflict(opts ...sql.ConflictOption) *PostUpsertOne
- func (pc *PostCreate) OnConflictColumns(columns ...string) *PostUpsertOne
- func (pc *PostCreate) Save(ctx context.Context) (*Post, error)
- func (pc *PostCreate) SaveX(ctx context.Context) *Post
- func (pc *PostCreate) SetDescription(s string) *PostCreate
- func (pc *PostCreate) SetDsn(s string) *PostCreate
- func (pc *PostCreate) SetID(i int) *PostCreate
- func (pc *PostCreate) SetNillableDescription(s *string) *PostCreate
- func (pc *PostCreate) SetNillableDsn(s *string) *PostCreate
- func (pc *PostCreate) SetTenantID(ss *sql.NullString) *PostCreate
- func (pc *PostCreate) SetTitle(s string) *PostCreate
- type PostCreateBulk
- func (pcb *PostCreateBulk) Exec(ctx context.Context) error
- func (pcb *PostCreateBulk) ExecX(ctx context.Context)
- func (pcb *PostCreateBulk) OnConflict(opts ...sql.ConflictOption) *PostUpsertBulk
- func (pcb *PostCreateBulk) OnConflictColumns(columns ...string) *PostUpsertBulk
- func (pcb *PostCreateBulk) Save(ctx context.Context) ([]*Post, error)
- func (pcb *PostCreateBulk) SaveX(ctx context.Context) []*Post
- type PostDelete
- type PostDeleteOne
- type PostFilter
- type PostGroupBy
- func (pgb *PostGroupBy) Aggregate(fns ...AggregateFunc) *PostGroupBy
- func (pgb *PostGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (pgb *PostGroupBy) BoolX(ctx context.Context) bool
- func (pgb *PostGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (pgb *PostGroupBy) BoolsX(ctx context.Context) []bool
- func (pgb *PostGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (pgb *PostGroupBy) Float64X(ctx context.Context) float64
- func (pgb *PostGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (pgb *PostGroupBy) Float64sX(ctx context.Context) []float64
- func (pgb *PostGroupBy) Int(ctx context.Context) (_ int, err error)
- func (pgb *PostGroupBy) IntX(ctx context.Context) int
- func (pgb *PostGroupBy) Ints(ctx context.Context) ([]int, error)
- func (pgb *PostGroupBy) IntsX(ctx context.Context) []int
- func (pgb *PostGroupBy) Scan(ctx context.Context, v interface{}) error
- func (pgb *PostGroupBy) ScanX(ctx context.Context, v interface{})
- func (pgb *PostGroupBy) String(ctx context.Context) (_ string, err error)
- func (pgb *PostGroupBy) StringX(ctx context.Context) string
- func (pgb *PostGroupBy) Strings(ctx context.Context) ([]string, error)
- func (pgb *PostGroupBy) StringsX(ctx context.Context) []string
- type PostMutation
- func (m *PostMutation) AddField(name string, value ent.Value) error
- func (m *PostMutation) AddedEdges() []string
- func (m *PostMutation) AddedField(name string) (ent.Value, bool)
- func (m *PostMutation) AddedFields() []string
- func (m *PostMutation) AddedIDs(name string) []ent.Value
- func (m *PostMutation) ClearDescription()
- func (m *PostMutation) ClearDsn()
- func (m *PostMutation) ClearEdge(name string) error
- func (m *PostMutation) ClearField(name string) error
- func (m *PostMutation) ClearTenantID()
- func (m *PostMutation) ClearedEdges() []string
- func (m *PostMutation) ClearedFields() []string
- func (m PostMutation) Client() *Client
- func (m *PostMutation) Description() (r string, exists bool)
- func (m *PostMutation) DescriptionCleared() bool
- func (m *PostMutation) Dsn() (r string, exists bool)
- func (m *PostMutation) DsnCleared() bool
- func (m *PostMutation) EdgeCleared(name string) bool
- func (m *PostMutation) Field(name string) (ent.Value, bool)
- func (m *PostMutation) FieldCleared(name string) bool
- func (m *PostMutation) Fields() []string
- func (m *PostMutation) Filter() *PostFilter
- func (m *PostMutation) ID() (id int, exists bool)
- func (m *PostMutation) IDs(ctx context.Context) ([]int, error)
- func (m *PostMutation) OldDescription(ctx context.Context) (v string, err error)
- func (m *PostMutation) OldDsn(ctx context.Context) (v string, err error)
- func (m *PostMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *PostMutation) OldTenantID(ctx context.Context) (v *sql.NullString, err error)
- func (m *PostMutation) OldTitle(ctx context.Context) (v string, err error)
- func (m *PostMutation) Op() Op
- func (m *PostMutation) RemovedEdges() []string
- func (m *PostMutation) RemovedIDs(name string) []ent.Value
- func (m *PostMutation) ResetDescription()
- func (m *PostMutation) ResetDsn()
- func (m *PostMutation) ResetEdge(name string) error
- func (m *PostMutation) ResetField(name string) error
- func (m *PostMutation) ResetTenantID()
- func (m *PostMutation) ResetTitle()
- func (m *PostMutation) SetDescription(s string)
- func (m *PostMutation) SetDsn(s string)
- func (m *PostMutation) SetField(name string, value ent.Value) error
- func (m *PostMutation) SetID(id int)
- func (m *PostMutation) SetTenantID(ss *sql.NullString)
- func (m *PostMutation) SetTitle(s string)
- func (m *PostMutation) TenantID() (r *sql.NullString, exists bool)
- func (m *PostMutation) TenantIDCleared() bool
- func (m *PostMutation) Title() (r string, exists bool)
- func (m PostMutation) Tx() (*Tx, error)
- func (m *PostMutation) Type() string
- func (m *PostMutation) Where(ps ...predicate.Post)
- type PostQuery
- func (pq *PostQuery) All(ctx context.Context) ([]*Post, error)
- func (pq *PostQuery) AllX(ctx context.Context) []*Post
- func (pq *PostQuery) Clone() *PostQuery
- func (pq *PostQuery) Count(ctx context.Context) (int, error)
- func (pq *PostQuery) CountX(ctx context.Context) int
- func (pq *PostQuery) Exist(ctx context.Context) (bool, error)
- func (pq *PostQuery) ExistX(ctx context.Context) bool
- func (pq *PostQuery) Filter() *PostFilter
- func (pq *PostQuery) First(ctx context.Context) (*Post, error)
- func (pq *PostQuery) FirstID(ctx context.Context) (id int, err error)
- func (pq *PostQuery) FirstIDX(ctx context.Context) int
- func (pq *PostQuery) FirstX(ctx context.Context) *Post
- func (pq *PostQuery) GroupBy(field string, fields ...string) *PostGroupBy
- func (pq *PostQuery) IDs(ctx context.Context) ([]int, error)
- func (pq *PostQuery) IDsX(ctx context.Context) []int
- func (pq *PostQuery) Limit(limit int) *PostQuery
- func (pq *PostQuery) Offset(offset int) *PostQuery
- func (pq *PostQuery) Only(ctx context.Context) (*Post, error)
- func (pq *PostQuery) OnlyID(ctx context.Context) (id int, err error)
- func (pq *PostQuery) OnlyIDX(ctx context.Context) int
- func (pq *PostQuery) OnlyX(ctx context.Context) *Post
- func (pq *PostQuery) Order(o ...OrderFunc) *PostQuery
- func (pq *PostQuery) Select(fields ...string) *PostSelect
- func (pq *PostQuery) Unique(unique bool) *PostQuery
- func (pq *PostQuery) Where(ps ...predicate.Post) *PostQuery
- type PostSelect
- func (ps *PostSelect) Bool(ctx context.Context) (_ bool, err error)
- func (ps *PostSelect) BoolX(ctx context.Context) bool
- func (ps *PostSelect) Bools(ctx context.Context) ([]bool, error)
- func (ps *PostSelect) BoolsX(ctx context.Context) []bool
- func (ps *PostSelect) Float64(ctx context.Context) (_ float64, err error)
- func (ps *PostSelect) Float64X(ctx context.Context) float64
- func (ps *PostSelect) Float64s(ctx context.Context) ([]float64, error)
- func (ps *PostSelect) Float64sX(ctx context.Context) []float64
- func (ps *PostSelect) Int(ctx context.Context) (_ int, err error)
- func (ps *PostSelect) IntX(ctx context.Context) int
- func (ps *PostSelect) Ints(ctx context.Context) ([]int, error)
- func (ps *PostSelect) IntsX(ctx context.Context) []int
- func (ps *PostSelect) Scan(ctx context.Context, v interface{}) error
- func (ps *PostSelect) ScanX(ctx context.Context, v interface{})
- func (ps *PostSelect) String(ctx context.Context) (_ string, err error)
- func (ps *PostSelect) StringX(ctx context.Context) string
- func (ps *PostSelect) Strings(ctx context.Context) ([]string, error)
- func (ps *PostSelect) StringsX(ctx context.Context) []string
- type PostUpdate
- func (pu *PostUpdate) ClearDescription() *PostUpdate
- func (pu *PostUpdate) ClearDsn() *PostUpdate
- func (pu *PostUpdate) ClearTenantID() *PostUpdate
- func (pu *PostUpdate) Exec(ctx context.Context) error
- func (pu *PostUpdate) ExecX(ctx context.Context)
- func (pu *PostUpdate) Mutation() *PostMutation
- func (pu *PostUpdate) Save(ctx context.Context) (int, error)
- func (pu *PostUpdate) SaveX(ctx context.Context) int
- func (pu *PostUpdate) SetDescription(s string) *PostUpdate
- func (pu *PostUpdate) SetDsn(s string) *PostUpdate
- func (pu *PostUpdate) SetNillableDescription(s *string) *PostUpdate
- func (pu *PostUpdate) SetNillableDsn(s *string) *PostUpdate
- func (pu *PostUpdate) SetTenantID(ss *sql.NullString) *PostUpdate
- func (pu *PostUpdate) SetTitle(s string) *PostUpdate
- func (pu *PostUpdate) Where(ps ...predicate.Post) *PostUpdate
- type PostUpdateOne
- func (puo *PostUpdateOne) ClearDescription() *PostUpdateOne
- func (puo *PostUpdateOne) ClearDsn() *PostUpdateOne
- func (puo *PostUpdateOne) ClearTenantID() *PostUpdateOne
- func (puo *PostUpdateOne) Exec(ctx context.Context) error
- func (puo *PostUpdateOne) ExecX(ctx context.Context)
- func (puo *PostUpdateOne) Mutation() *PostMutation
- func (puo *PostUpdateOne) Save(ctx context.Context) (*Post, error)
- func (puo *PostUpdateOne) SaveX(ctx context.Context) *Post
- func (puo *PostUpdateOne) Select(field string, fields ...string) *PostUpdateOne
- func (puo *PostUpdateOne) SetDescription(s string) *PostUpdateOne
- func (puo *PostUpdateOne) SetDsn(s string) *PostUpdateOne
- func (puo *PostUpdateOne) SetNillableDescription(s *string) *PostUpdateOne
- func (puo *PostUpdateOne) SetNillableDsn(s *string) *PostUpdateOne
- func (puo *PostUpdateOne) SetTenantID(ss *sql.NullString) *PostUpdateOne
- func (puo *PostUpdateOne) SetTitle(s string) *PostUpdateOne
- type PostUpsert
- func (u *PostUpsert) ClearDescription() *PostUpsert
- func (u *PostUpsert) ClearDsn() *PostUpsert
- func (u *PostUpsert) ClearTenantID() *PostUpsert
- func (u *PostUpsert) SetDescription(v string) *PostUpsert
- func (u *PostUpsert) SetDsn(v string) *PostUpsert
- func (u *PostUpsert) SetTenantID(v *sql.NullString) *PostUpsert
- func (u *PostUpsert) SetTitle(v string) *PostUpsert
- func (u *PostUpsert) UpdateDescription() *PostUpsert
- func (u *PostUpsert) UpdateDsn() *PostUpsert
- func (u *PostUpsert) UpdateTenantID() *PostUpsert
- func (u *PostUpsert) UpdateTitle() *PostUpsert
- type PostUpsertBulk
- func (u *PostUpsertBulk) ClearDescription() *PostUpsertBulk
- func (u *PostUpsertBulk) ClearDsn() *PostUpsertBulk
- func (u *PostUpsertBulk) ClearTenantID() *PostUpsertBulk
- func (u *PostUpsertBulk) DoNothing() *PostUpsertBulk
- func (u *PostUpsertBulk) Exec(ctx context.Context) error
- func (u *PostUpsertBulk) ExecX(ctx context.Context)
- func (u *PostUpsertBulk) Ignore() *PostUpsertBulk
- func (u *PostUpsertBulk) SetDescription(v string) *PostUpsertBulk
- func (u *PostUpsertBulk) SetDsn(v string) *PostUpsertBulk
- func (u *PostUpsertBulk) SetTenantID(v *sql.NullString) *PostUpsertBulk
- func (u *PostUpsertBulk) SetTitle(v string) *PostUpsertBulk
- func (u *PostUpsertBulk) Update(set func(*PostUpsert)) *PostUpsertBulk
- func (u *PostUpsertBulk) UpdateDescription() *PostUpsertBulk
- func (u *PostUpsertBulk) UpdateDsn() *PostUpsertBulk
- func (u *PostUpsertBulk) UpdateNewValues() *PostUpsertBulk
- func (u *PostUpsertBulk) UpdateTenantID() *PostUpsertBulk
- func (u *PostUpsertBulk) UpdateTitle() *PostUpsertBulk
- type PostUpsertOne
- func (u *PostUpsertOne) ClearDescription() *PostUpsertOne
- func (u *PostUpsertOne) ClearDsn() *PostUpsertOne
- func (u *PostUpsertOne) ClearTenantID() *PostUpsertOne
- func (u *PostUpsertOne) DoNothing() *PostUpsertOne
- func (u *PostUpsertOne) Exec(ctx context.Context) error
- func (u *PostUpsertOne) ExecX(ctx context.Context)
- func (u *PostUpsertOne) ID(ctx context.Context) (id int, err error)
- func (u *PostUpsertOne) IDX(ctx context.Context) int
- func (u *PostUpsertOne) Ignore() *PostUpsertOne
- func (u *PostUpsertOne) SetDescription(v string) *PostUpsertOne
- func (u *PostUpsertOne) SetDsn(v string) *PostUpsertOne
- func (u *PostUpsertOne) SetTenantID(v *sql.NullString) *PostUpsertOne
- func (u *PostUpsertOne) SetTitle(v string) *PostUpsertOne
- func (u *PostUpsertOne) Update(set func(*PostUpsert)) *PostUpsertOne
- func (u *PostUpsertOne) UpdateDescription() *PostUpsertOne
- func (u *PostUpsertOne) UpdateDsn() *PostUpsertOne
- func (u *PostUpsertOne) UpdateNewValues() *PostUpsertOne
- func (u *PostUpsertOne) UpdateTenantID() *PostUpsertOne
- func (u *PostUpsertOne) UpdateTitle() *PostUpsertOne
- type Posts
- type Query
- type RollbackFunc
- type RollbackHook
- type Rollbacker
- 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. TypePost = "Post" )
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 validation 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 Client ¶
type Client struct { // Schema is the client for creating, migrating and dropping schema. Schema *migrate.Schema // Post is the client for interacting with the Post builders. Post *PostClient // contains filtered or unexported fields }
Client is the client that holds all ent builders.
func FromContext ¶
FromContext returns a Client stored inside 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(). Post. 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(ctx context.Context, tx *ent.Tx) error { // Do some stuff before. if err := next.Commit(ctx, tx); err != nil { return err } // Do some stuff after. return nil }) }
type 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 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 Post ¶
type Post struct { // ID of the ent. ID int `json:"id,omitempty"` // TenantID holds the value of the "tenant_id" field. TenantID *sql.NullString `json:"tenant_id,omitempty"` // Title holds the value of the "title" field. Title string `json:"title,omitempty"` // Description holds the value of the "description" field. Description string `json:"description,omitempty"` // Dsn holds the value of the "dsn" field. Dsn string `json:"dsn,omitempty"` // contains filtered or unexported fields }
Post is the model entity for the Post schema.
func (*Post) Unwrap ¶
Unwrap unwraps the Post 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 (*Post) Update ¶
func (po *Post) Update() *PostUpdateOne
Update returns a builder for updating this Post. Note that you need to call Post.Unwrap() before calling this method if this Post was returned from a transaction, and the transaction was committed or rolled back.
type PostClient ¶
type PostClient struct {
// contains filtered or unexported fields
}
PostClient is a client for the Post schema.
func NewPostClient ¶
func NewPostClient(c config) *PostClient
NewPostClient returns a client for the Post from the given config.
func (*PostClient) Create ¶
func (c *PostClient) Create() *PostCreate
Create returns a create builder for Post.
func (*PostClient) CreateBulk ¶
func (c *PostClient) CreateBulk(builders ...*PostCreate) *PostCreateBulk
CreateBulk returns a builder for creating a bulk of Post entities.
func (*PostClient) Delete ¶
func (c *PostClient) Delete() *PostDelete
Delete returns a delete builder for Post.
func (*PostClient) DeleteOne ¶
func (c *PostClient) DeleteOne(po *Post) *PostDeleteOne
DeleteOne returns a delete builder for the given entity.
func (*PostClient) DeleteOneID ¶
func (c *PostClient) DeleteOneID(id int) *PostDeleteOne
DeleteOneID returns a delete builder for the given id.
func (*PostClient) GetX ¶
func (c *PostClient) GetX(ctx context.Context, id int) *Post
GetX is like Get, but panics if an error occurs.
func (*PostClient) Query ¶
func (c *PostClient) Query() *PostQuery
Query returns a query builder for Post.
func (*PostClient) Update ¶
func (c *PostClient) Update() *PostUpdate
Update returns an update builder for Post.
func (*PostClient) UpdateOne ¶
func (c *PostClient) UpdateOne(po *Post) *PostUpdateOne
UpdateOne returns an update builder for the given entity.
func (*PostClient) UpdateOneID ¶
func (c *PostClient) UpdateOneID(id int) *PostUpdateOne
UpdateOneID returns an update builder for the given id.
func (*PostClient) Use ¶
func (c *PostClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `post.Hooks(f(g(h())))`.
type PostCreate ¶
type PostCreate struct {
// contains filtered or unexported fields
}
PostCreate is the builder for creating a Post entity.
func (*PostCreate) Exec ¶
func (pc *PostCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*PostCreate) ExecX ¶
func (pc *PostCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*PostCreate) Mutation ¶
func (pc *PostCreate) Mutation() *PostMutation
Mutation returns the PostMutation object of the builder.
func (*PostCreate) OnConflict ¶
func (pc *PostCreate) OnConflict(opts ...sql.ConflictOption) *PostUpsertOne
OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause of the `INSERT` statement. For example:
client.Post.Create(). SetTenantID(v). OnConflict( // Update the row with the new values // the was proposed for insertion. sql.ResolveWithNewValues(), ). // Override some of the fields with custom // update values. Update(func(u *ent.PostUpsert) { SetTenantID(v+v). }). Exec(ctx)
func (*PostCreate) OnConflictColumns ¶
func (pc *PostCreate) OnConflictColumns(columns ...string) *PostUpsertOne
OnConflictColumns calls `OnConflict` and configures the columns as conflict target. Using this option is equivalent to using:
client.Post.Create(). OnConflict(sql.ConflictColumns(columns...)). Exec(ctx)
func (*PostCreate) Save ¶
func (pc *PostCreate) Save(ctx context.Context) (*Post, error)
Save creates the Post in the database.
func (*PostCreate) SaveX ¶
func (pc *PostCreate) SaveX(ctx context.Context) *Post
SaveX calls Save and panics if Save returns an error.
func (*PostCreate) SetDescription ¶
func (pc *PostCreate) SetDescription(s string) *PostCreate
SetDescription sets the "description" field.
func (*PostCreate) SetDsn ¶
func (pc *PostCreate) SetDsn(s string) *PostCreate
SetDsn sets the "dsn" field.
func (*PostCreate) SetID ¶
func (pc *PostCreate) SetID(i int) *PostCreate
SetID sets the "id" field.
func (*PostCreate) SetNillableDescription ¶
func (pc *PostCreate) SetNillableDescription(s *string) *PostCreate
SetNillableDescription sets the "description" field if the given value is not nil.
func (*PostCreate) SetNillableDsn ¶
func (pc *PostCreate) SetNillableDsn(s *string) *PostCreate
SetNillableDsn sets the "dsn" field if the given value is not nil.
func (*PostCreate) SetTenantID ¶
func (pc *PostCreate) SetTenantID(ss *sql.NullString) *PostCreate
SetTenantID sets the "tenant_id" field.
func (*PostCreate) SetTitle ¶
func (pc *PostCreate) SetTitle(s string) *PostCreate
SetTitle sets the "title" field.
type PostCreateBulk ¶
type PostCreateBulk struct {
// contains filtered or unexported fields
}
PostCreateBulk is the builder for creating many Post entities in bulk.
func (*PostCreateBulk) Exec ¶
func (pcb *PostCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*PostCreateBulk) ExecX ¶
func (pcb *PostCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*PostCreateBulk) OnConflict ¶
func (pcb *PostCreateBulk) OnConflict(opts ...sql.ConflictOption) *PostUpsertBulk
OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause of the `INSERT` statement. For example:
client.Post.CreateBulk(builders...). OnConflict( // Update the row with the new values // the was proposed for insertion. sql.ResolveWithNewValues(), ). // Override some of the fields with custom // update values. Update(func(u *ent.PostUpsert) { SetTenantID(v+v). }). Exec(ctx)
func (*PostCreateBulk) OnConflictColumns ¶
func (pcb *PostCreateBulk) OnConflictColumns(columns ...string) *PostUpsertBulk
OnConflictColumns calls `OnConflict` and configures the columns as conflict target. Using this option is equivalent to using:
client.Post.Create(). OnConflict(sql.ConflictColumns(columns...)). Exec(ctx)
type PostDelete ¶
type PostDelete struct {
// contains filtered or unexported fields
}
PostDelete is the builder for deleting a Post entity.
func (*PostDelete) Exec ¶
func (pd *PostDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*PostDelete) ExecX ¶
func (pd *PostDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*PostDelete) Where ¶
func (pd *PostDelete) Where(ps ...predicate.Post) *PostDelete
Where appends a list predicates to the PostDelete builder.
type PostDeleteOne ¶
type PostDeleteOne struct {
// contains filtered or unexported fields
}
PostDeleteOne is the builder for deleting a single Post entity.
func (*PostDeleteOne) Exec ¶
func (pdo *PostDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*PostDeleteOne) ExecX ¶
func (pdo *PostDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type PostFilter ¶
type PostFilter struct {
// contains filtered or unexported fields
}
PostFilter provides a generic filtering capability at runtime for PostQuery.
func (*PostFilter) Where ¶
func (f *PostFilter) Where(p entql.P)
Where applies the entql predicate on the query filter.
func (*PostFilter) WhereDescription ¶
func (f *PostFilter) WhereDescription(p entql.StringP)
WhereDescription applies the entql string predicate on the description field.
func (*PostFilter) WhereDsn ¶
func (f *PostFilter) WhereDsn(p entql.StringP)
WhereDsn applies the entql string predicate on the dsn field.
func (*PostFilter) WhereID ¶
func (f *PostFilter) WhereID(p entql.IntP)
WhereID applies the entql int predicate on the id field.
func (*PostFilter) WhereTenantID ¶
func (f *PostFilter) WhereTenantID(p entql.StringP)
WhereTenantID applies the entql string predicate on the tenant_id field.
func (*PostFilter) WhereTitle ¶
func (f *PostFilter) WhereTitle(p entql.StringP)
WhereTitle applies the entql string predicate on the title field.
type PostGroupBy ¶
type PostGroupBy struct {
// contains filtered or unexported fields
}
PostGroupBy is the group-by builder for Post entities.
func (*PostGroupBy) Aggregate ¶
func (pgb *PostGroupBy) Aggregate(fns ...AggregateFunc) *PostGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*PostGroupBy) Bool ¶
func (pgb *PostGroupBy) 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 (*PostGroupBy) BoolX ¶
func (pgb *PostGroupBy) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*PostGroupBy) Bools ¶
func (pgb *PostGroupBy) 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 (*PostGroupBy) BoolsX ¶
func (pgb *PostGroupBy) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*PostGroupBy) Float64 ¶
func (pgb *PostGroupBy) 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 (*PostGroupBy) Float64X ¶
func (pgb *PostGroupBy) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*PostGroupBy) Float64s ¶
func (pgb *PostGroupBy) 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 (*PostGroupBy) Float64sX ¶
func (pgb *PostGroupBy) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*PostGroupBy) Int ¶
func (pgb *PostGroupBy) 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 (*PostGroupBy) IntX ¶
func (pgb *PostGroupBy) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*PostGroupBy) Ints ¶
func (pgb *PostGroupBy) 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 (*PostGroupBy) IntsX ¶
func (pgb *PostGroupBy) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*PostGroupBy) Scan ¶
func (pgb *PostGroupBy) Scan(ctx context.Context, v interface{}) error
Scan applies the group-by query and scans the result into the given value.
func (*PostGroupBy) ScanX ¶
func (pgb *PostGroupBy) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*PostGroupBy) String ¶
func (pgb *PostGroupBy) 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 (*PostGroupBy) StringX ¶
func (pgb *PostGroupBy) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type PostMutation ¶
type PostMutation struct {
// contains filtered or unexported fields
}
PostMutation represents an operation that mutates the Post nodes in the graph.
func (*PostMutation) AddField ¶
func (m *PostMutation) 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 (*PostMutation) AddedEdges ¶
func (m *PostMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*PostMutation) AddedField ¶
func (m *PostMutation) 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 (*PostMutation) AddedFields ¶
func (m *PostMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*PostMutation) AddedIDs ¶
func (m *PostMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*PostMutation) ClearDescription ¶
func (m *PostMutation) ClearDescription()
ClearDescription clears the value of the "description" field.
func (*PostMutation) ClearDsn ¶
func (m *PostMutation) ClearDsn()
ClearDsn clears the value of the "dsn" field.
func (*PostMutation) ClearEdge ¶
func (m *PostMutation) 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 (*PostMutation) ClearField ¶
func (m *PostMutation) 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 (*PostMutation) ClearTenantID ¶
func (m *PostMutation) ClearTenantID()
ClearTenantID clears the value of the "tenant_id" field.
func (*PostMutation) ClearedEdges ¶
func (m *PostMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*PostMutation) ClearedFields ¶
func (m *PostMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (PostMutation) Client ¶
func (m PostMutation) 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 (*PostMutation) Description ¶
func (m *PostMutation) Description() (r string, exists bool)
Description returns the value of the "description" field in the mutation.
func (*PostMutation) DescriptionCleared ¶
func (m *PostMutation) DescriptionCleared() bool
DescriptionCleared returns if the "description" field was cleared in this mutation.
func (*PostMutation) Dsn ¶
func (m *PostMutation) Dsn() (r string, exists bool)
Dsn returns the value of the "dsn" field in the mutation.
func (*PostMutation) DsnCleared ¶
func (m *PostMutation) DsnCleared() bool
DsnCleared returns if the "dsn" field was cleared in this mutation.
func (*PostMutation) EdgeCleared ¶
func (m *PostMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*PostMutation) Field ¶
func (m *PostMutation) 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 (*PostMutation) FieldCleared ¶
func (m *PostMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*PostMutation) Fields ¶
func (m *PostMutation) 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 (*PostMutation) Filter ¶
func (m *PostMutation) Filter() *PostFilter
Filter returns an entql.Where implementation to apply filters on the PostMutation builder.
func (*PostMutation) ID ¶
func (m *PostMutation) ID() (id int, exists bool)
ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder or after it was returned from the database.
func (*PostMutation) IDs ¶
func (m *PostMutation) IDs(ctx context.Context) ([]int, error)
IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.
func (*PostMutation) OldDescription ¶
func (m *PostMutation) OldDescription(ctx context.Context) (v string, err error)
OldDescription returns the old "description" field's value of the Post entity. If the Post 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 (*PostMutation) OldDsn ¶
func (m *PostMutation) OldDsn(ctx context.Context) (v string, err error)
OldDsn returns the old "dsn" field's value of the Post entity. If the Post 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 (*PostMutation) 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 failed.
func (*PostMutation) OldTenantID ¶
func (m *PostMutation) OldTenantID(ctx context.Context) (v *sql.NullString, err error)
OldTenantID returns the old "tenant_id" field's value of the Post entity. If the Post 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 (*PostMutation) OldTitle ¶
func (m *PostMutation) OldTitle(ctx context.Context) (v string, err error)
OldTitle returns the old "title" field's value of the Post entity. If the Post 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 (*PostMutation) RemovedEdges ¶
func (m *PostMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*PostMutation) RemovedIDs ¶
func (m *PostMutation) 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 (*PostMutation) ResetDescription ¶
func (m *PostMutation) ResetDescription()
ResetDescription resets all changes to the "description" field.
func (*PostMutation) ResetDsn ¶
func (m *PostMutation) ResetDsn()
ResetDsn resets all changes to the "dsn" field.
func (*PostMutation) ResetEdge ¶
func (m *PostMutation) 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 (*PostMutation) ResetField ¶
func (m *PostMutation) 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 (*PostMutation) ResetTenantID ¶
func (m *PostMutation) ResetTenantID()
ResetTenantID resets all changes to the "tenant_id" field.
func (*PostMutation) ResetTitle ¶
func (m *PostMutation) ResetTitle()
ResetTitle resets all changes to the "title" field.
func (*PostMutation) SetDescription ¶
func (m *PostMutation) SetDescription(s string)
SetDescription sets the "description" field.
func (*PostMutation) SetField ¶
func (m *PostMutation) 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 (*PostMutation) SetID ¶
func (m *PostMutation) SetID(id int)
SetID sets the value of the id field. Note that this operation is only accepted on creation of Post entities.
func (*PostMutation) SetTenantID ¶
func (m *PostMutation) SetTenantID(ss *sql.NullString)
SetTenantID sets the "tenant_id" field.
func (*PostMutation) SetTitle ¶
func (m *PostMutation) SetTitle(s string)
SetTitle sets the "title" field.
func (*PostMutation) TenantID ¶
func (m *PostMutation) TenantID() (r *sql.NullString, exists bool)
TenantID returns the value of the "tenant_id" field in the mutation.
func (*PostMutation) TenantIDCleared ¶
func (m *PostMutation) TenantIDCleared() bool
TenantIDCleared returns if the "tenant_id" field was cleared in this mutation.
func (*PostMutation) Title ¶
func (m *PostMutation) Title() (r string, exists bool)
Title returns the value of the "title" field in the mutation.
func (PostMutation) Tx ¶
func (m PostMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*PostMutation) Type ¶
func (m *PostMutation) Type() string
Type returns the node type of this mutation (Post).
func (*PostMutation) Where ¶
func (m *PostMutation) Where(ps ...predicate.Post)
Where appends a list predicates to the PostMutation builder.
type PostQuery ¶
type PostQuery struct {
// contains filtered or unexported fields
}
PostQuery is the builder for querying Post entities.
func (*PostQuery) Clone ¶
Clone returns a duplicate of the PostQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*PostQuery) Filter ¶
func (pq *PostQuery) Filter() *PostFilter
Filter returns a Filter implementation to apply filters on the PostQuery builder.
func (*PostQuery) First ¶
First returns the first Post entity from the query. Returns a *NotFoundError when no Post was found.
func (*PostQuery) FirstID ¶
FirstID returns the first Post ID from the query. Returns a *NotFoundError when no Post ID was found.
func (*PostQuery) GroupBy ¶
func (pq *PostQuery) GroupBy(field string, fields ...string) *PostGroupBy
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 { TenantID *sql.NullString `json:"tenant_id,omitempty"` Count int `json:"count,omitempty"` } client.Post.Query(). GroupBy(post.FieldTenantID). Aggregate(ent.Count()). Scan(ctx, &v)
func (*PostQuery) Only ¶
Only returns a single Post entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Post entity is found. Returns a *NotFoundError when no Post entities are found.
func (*PostQuery) OnlyID ¶
OnlyID is like Only, but returns the only Post ID in the query. Returns a *NotSingularError when more than one Post ID is found. Returns a *NotFoundError when no entities are found.
func (*PostQuery) Select ¶
func (pq *PostQuery) Select(fields ...string) *PostSelect
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 { TenantID *sql.NullString `json:"tenant_id,omitempty"` } client.Post.Query(). Select(post.FieldTenantID). Scan(ctx, &v)
type PostSelect ¶
type PostSelect struct { *PostQuery // contains filtered or unexported fields }
PostSelect is the builder for selecting fields of Post entities.
func (*PostSelect) Bool ¶
func (ps *PostSelect) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*PostSelect) BoolX ¶
func (ps *PostSelect) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*PostSelect) Bools ¶
func (ps *PostSelect) Bools(ctx context.Context) ([]bool, error)
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*PostSelect) BoolsX ¶
func (ps *PostSelect) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*PostSelect) Float64 ¶
func (ps *PostSelect) Float64(ctx context.Context) (_ float64, err error)
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*PostSelect) Float64X ¶
func (ps *PostSelect) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*PostSelect) Float64s ¶
func (ps *PostSelect) Float64s(ctx context.Context) ([]float64, error)
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*PostSelect) Float64sX ¶
func (ps *PostSelect) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*PostSelect) Int ¶
func (ps *PostSelect) Int(ctx context.Context) (_ int, err error)
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*PostSelect) IntX ¶
func (ps *PostSelect) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*PostSelect) Ints ¶
func (ps *PostSelect) Ints(ctx context.Context) ([]int, error)
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*PostSelect) IntsX ¶
func (ps *PostSelect) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*PostSelect) Scan ¶
func (ps *PostSelect) Scan(ctx context.Context, v interface{}) error
Scan applies the selector query and scans the result into the given value.
func (*PostSelect) ScanX ¶
func (ps *PostSelect) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*PostSelect) String ¶
func (ps *PostSelect) String(ctx context.Context) (_ string, err error)
String returns a single string from a selector. It is only allowed when selecting one field.
func (*PostSelect) StringX ¶
func (ps *PostSelect) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type PostUpdate ¶
type PostUpdate struct {
// contains filtered or unexported fields
}
PostUpdate is the builder for updating Post entities.
func (*PostUpdate) ClearDescription ¶
func (pu *PostUpdate) ClearDescription() *PostUpdate
ClearDescription clears the value of the "description" field.
func (*PostUpdate) ClearDsn ¶
func (pu *PostUpdate) ClearDsn() *PostUpdate
ClearDsn clears the value of the "dsn" field.
func (*PostUpdate) ClearTenantID ¶
func (pu *PostUpdate) ClearTenantID() *PostUpdate
ClearTenantID clears the value of the "tenant_id" field.
func (*PostUpdate) Exec ¶
func (pu *PostUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*PostUpdate) ExecX ¶
func (pu *PostUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*PostUpdate) Mutation ¶
func (pu *PostUpdate) Mutation() *PostMutation
Mutation returns the PostMutation object of the builder.
func (*PostUpdate) Save ¶
func (pu *PostUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*PostUpdate) SaveX ¶
func (pu *PostUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*PostUpdate) SetDescription ¶
func (pu *PostUpdate) SetDescription(s string) *PostUpdate
SetDescription sets the "description" field.
func (*PostUpdate) SetDsn ¶
func (pu *PostUpdate) SetDsn(s string) *PostUpdate
SetDsn sets the "dsn" field.
func (*PostUpdate) SetNillableDescription ¶
func (pu *PostUpdate) SetNillableDescription(s *string) *PostUpdate
SetNillableDescription sets the "description" field if the given value is not nil.
func (*PostUpdate) SetNillableDsn ¶
func (pu *PostUpdate) SetNillableDsn(s *string) *PostUpdate
SetNillableDsn sets the "dsn" field if the given value is not nil.
func (*PostUpdate) SetTenantID ¶
func (pu *PostUpdate) SetTenantID(ss *sql.NullString) *PostUpdate
SetTenantID sets the "tenant_id" field.
func (*PostUpdate) SetTitle ¶
func (pu *PostUpdate) SetTitle(s string) *PostUpdate
SetTitle sets the "title" field.
func (*PostUpdate) Where ¶
func (pu *PostUpdate) Where(ps ...predicate.Post) *PostUpdate
Where appends a list predicates to the PostUpdate builder.
type PostUpdateOne ¶
type PostUpdateOne struct {
// contains filtered or unexported fields
}
PostUpdateOne is the builder for updating a single Post entity.
func (*PostUpdateOne) ClearDescription ¶
func (puo *PostUpdateOne) ClearDescription() *PostUpdateOne
ClearDescription clears the value of the "description" field.
func (*PostUpdateOne) ClearDsn ¶
func (puo *PostUpdateOne) ClearDsn() *PostUpdateOne
ClearDsn clears the value of the "dsn" field.
func (*PostUpdateOne) ClearTenantID ¶
func (puo *PostUpdateOne) ClearTenantID() *PostUpdateOne
ClearTenantID clears the value of the "tenant_id" field.
func (*PostUpdateOne) Exec ¶
func (puo *PostUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*PostUpdateOne) ExecX ¶
func (puo *PostUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*PostUpdateOne) Mutation ¶
func (puo *PostUpdateOne) Mutation() *PostMutation
Mutation returns the PostMutation object of the builder.
func (*PostUpdateOne) Save ¶
func (puo *PostUpdateOne) Save(ctx context.Context) (*Post, error)
Save executes the query and returns the updated Post entity.
func (*PostUpdateOne) SaveX ¶
func (puo *PostUpdateOne) SaveX(ctx context.Context) *Post
SaveX is like Save, but panics if an error occurs.
func (*PostUpdateOne) Select ¶
func (puo *PostUpdateOne) Select(field string, fields ...string) *PostUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*PostUpdateOne) SetDescription ¶
func (puo *PostUpdateOne) SetDescription(s string) *PostUpdateOne
SetDescription sets the "description" field.
func (*PostUpdateOne) SetDsn ¶
func (puo *PostUpdateOne) SetDsn(s string) *PostUpdateOne
SetDsn sets the "dsn" field.
func (*PostUpdateOne) SetNillableDescription ¶
func (puo *PostUpdateOne) SetNillableDescription(s *string) *PostUpdateOne
SetNillableDescription sets the "description" field if the given value is not nil.
func (*PostUpdateOne) SetNillableDsn ¶
func (puo *PostUpdateOne) SetNillableDsn(s *string) *PostUpdateOne
SetNillableDsn sets the "dsn" field if the given value is not nil.
func (*PostUpdateOne) SetTenantID ¶
func (puo *PostUpdateOne) SetTenantID(ss *sql.NullString) *PostUpdateOne
SetTenantID sets the "tenant_id" field.
func (*PostUpdateOne) SetTitle ¶
func (puo *PostUpdateOne) SetTitle(s string) *PostUpdateOne
SetTitle sets the "title" field.
type PostUpsert ¶
PostUpsert is the "OnConflict" setter.
func (*PostUpsert) ClearDescription ¶
func (u *PostUpsert) ClearDescription() *PostUpsert
ClearDescription clears the value of the "description" field.
func (*PostUpsert) ClearDsn ¶
func (u *PostUpsert) ClearDsn() *PostUpsert
ClearDsn clears the value of the "dsn" field.
func (*PostUpsert) ClearTenantID ¶
func (u *PostUpsert) ClearTenantID() *PostUpsert
ClearTenantID clears the value of the "tenant_id" field.
func (*PostUpsert) SetDescription ¶
func (u *PostUpsert) SetDescription(v string) *PostUpsert
SetDescription sets the "description" field.
func (*PostUpsert) SetDsn ¶
func (u *PostUpsert) SetDsn(v string) *PostUpsert
SetDsn sets the "dsn" field.
func (*PostUpsert) SetTenantID ¶
func (u *PostUpsert) SetTenantID(v *sql.NullString) *PostUpsert
SetTenantID sets the "tenant_id" field.
func (*PostUpsert) SetTitle ¶
func (u *PostUpsert) SetTitle(v string) *PostUpsert
SetTitle sets the "title" field.
func (*PostUpsert) UpdateDescription ¶
func (u *PostUpsert) UpdateDescription() *PostUpsert
UpdateDescription sets the "description" field to the value that was provided on create.
func (*PostUpsert) UpdateDsn ¶
func (u *PostUpsert) UpdateDsn() *PostUpsert
UpdateDsn sets the "dsn" field to the value that was provided on create.
func (*PostUpsert) UpdateTenantID ¶
func (u *PostUpsert) UpdateTenantID() *PostUpsert
UpdateTenantID sets the "tenant_id" field to the value that was provided on create.
func (*PostUpsert) UpdateTitle ¶
func (u *PostUpsert) UpdateTitle() *PostUpsert
UpdateTitle sets the "title" field to the value that was provided on create.
type PostUpsertBulk ¶
type PostUpsertBulk struct {
// contains filtered or unexported fields
}
PostUpsertBulk is the builder for "upsert"-ing a bulk of Post nodes.
func (*PostUpsertBulk) ClearDescription ¶
func (u *PostUpsertBulk) ClearDescription() *PostUpsertBulk
ClearDescription clears the value of the "description" field.
func (*PostUpsertBulk) ClearDsn ¶
func (u *PostUpsertBulk) ClearDsn() *PostUpsertBulk
ClearDsn clears the value of the "dsn" field.
func (*PostUpsertBulk) ClearTenantID ¶
func (u *PostUpsertBulk) ClearTenantID() *PostUpsertBulk
ClearTenantID clears the value of the "tenant_id" field.
func (*PostUpsertBulk) DoNothing ¶
func (u *PostUpsertBulk) DoNothing() *PostUpsertBulk
DoNothing configures the conflict_action to `DO NOTHING`. Supported only by SQLite and PostgreSQL.
func (*PostUpsertBulk) Exec ¶
func (u *PostUpsertBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*PostUpsertBulk) ExecX ¶
func (u *PostUpsertBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*PostUpsertBulk) Ignore ¶
func (u *PostUpsertBulk) Ignore() *PostUpsertBulk
Ignore sets each column to itself in case of conflict. Using this option is equivalent to using:
client.Post.Create(). OnConflict(sql.ResolveWithIgnore()). Exec(ctx)
func (*PostUpsertBulk) SetDescription ¶
func (u *PostUpsertBulk) SetDescription(v string) *PostUpsertBulk
SetDescription sets the "description" field.
func (*PostUpsertBulk) SetDsn ¶
func (u *PostUpsertBulk) SetDsn(v string) *PostUpsertBulk
SetDsn sets the "dsn" field.
func (*PostUpsertBulk) SetTenantID ¶
func (u *PostUpsertBulk) SetTenantID(v *sql.NullString) *PostUpsertBulk
SetTenantID sets the "tenant_id" field.
func (*PostUpsertBulk) SetTitle ¶
func (u *PostUpsertBulk) SetTitle(v string) *PostUpsertBulk
SetTitle sets the "title" field.
func (*PostUpsertBulk) Update ¶
func (u *PostUpsertBulk) Update(set func(*PostUpsert)) *PostUpsertBulk
Update allows overriding fields `UPDATE` values. See the PostCreateBulk.OnConflict documentation for more info.
func (*PostUpsertBulk) UpdateDescription ¶
func (u *PostUpsertBulk) UpdateDescription() *PostUpsertBulk
UpdateDescription sets the "description" field to the value that was provided on create.
func (*PostUpsertBulk) UpdateDsn ¶
func (u *PostUpsertBulk) UpdateDsn() *PostUpsertBulk
UpdateDsn sets the "dsn" field to the value that was provided on create.
func (*PostUpsertBulk) UpdateNewValues ¶
func (u *PostUpsertBulk) UpdateNewValues() *PostUpsertBulk
UpdateNewValues updates the mutable fields using the new values that were set on create. Using this option is equivalent to using:
client.Post.Create(). OnConflict( sql.ResolveWithNewValues(), sql.ResolveWith(func(u *sql.UpdateSet) { u.SetIgnore(post.FieldID) }), ). Exec(ctx)
func (*PostUpsertBulk) UpdateTenantID ¶
func (u *PostUpsertBulk) UpdateTenantID() *PostUpsertBulk
UpdateTenantID sets the "tenant_id" field to the value that was provided on create.
func (*PostUpsertBulk) UpdateTitle ¶
func (u *PostUpsertBulk) UpdateTitle() *PostUpsertBulk
UpdateTitle sets the "title" field to the value that was provided on create.
type PostUpsertOne ¶
type PostUpsertOne struct {
// contains filtered or unexported fields
}
PostUpsertOne is the builder for "upsert"-ing
one Post node.
func (*PostUpsertOne) ClearDescription ¶
func (u *PostUpsertOne) ClearDescription() *PostUpsertOne
ClearDescription clears the value of the "description" field.
func (*PostUpsertOne) ClearDsn ¶
func (u *PostUpsertOne) ClearDsn() *PostUpsertOne
ClearDsn clears the value of the "dsn" field.
func (*PostUpsertOne) ClearTenantID ¶
func (u *PostUpsertOne) ClearTenantID() *PostUpsertOne
ClearTenantID clears the value of the "tenant_id" field.
func (*PostUpsertOne) DoNothing ¶
func (u *PostUpsertOne) DoNothing() *PostUpsertOne
DoNothing configures the conflict_action to `DO NOTHING`. Supported only by SQLite and PostgreSQL.
func (*PostUpsertOne) Exec ¶
func (u *PostUpsertOne) Exec(ctx context.Context) error
Exec executes the query.
func (*PostUpsertOne) ExecX ¶
func (u *PostUpsertOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*PostUpsertOne) ID ¶
func (u *PostUpsertOne) ID(ctx context.Context) (id int, err error)
Exec executes the UPSERT query and returns the inserted/updated ID.
func (*PostUpsertOne) IDX ¶
func (u *PostUpsertOne) IDX(ctx context.Context) int
IDX is like ID, but panics if an error occurs.
func (*PostUpsertOne) Ignore ¶
func (u *PostUpsertOne) Ignore() *PostUpsertOne
Ignore sets each column to itself in case of conflict. Using this option is equivalent to using:
client.Post.Create(). OnConflict(sql.ResolveWithIgnore()). Exec(ctx)
func (*PostUpsertOne) SetDescription ¶
func (u *PostUpsertOne) SetDescription(v string) *PostUpsertOne
SetDescription sets the "description" field.
func (*PostUpsertOne) SetDsn ¶
func (u *PostUpsertOne) SetDsn(v string) *PostUpsertOne
SetDsn sets the "dsn" field.
func (*PostUpsertOne) SetTenantID ¶
func (u *PostUpsertOne) SetTenantID(v *sql.NullString) *PostUpsertOne
SetTenantID sets the "tenant_id" field.
func (*PostUpsertOne) SetTitle ¶
func (u *PostUpsertOne) SetTitle(v string) *PostUpsertOne
SetTitle sets the "title" field.
func (*PostUpsertOne) Update ¶
func (u *PostUpsertOne) Update(set func(*PostUpsert)) *PostUpsertOne
Update allows overriding fields `UPDATE` values. See the PostCreate.OnConflict documentation for more info.
func (*PostUpsertOne) UpdateDescription ¶
func (u *PostUpsertOne) UpdateDescription() *PostUpsertOne
UpdateDescription sets the "description" field to the value that was provided on create.
func (*PostUpsertOne) UpdateDsn ¶
func (u *PostUpsertOne) UpdateDsn() *PostUpsertOne
UpdateDsn sets the "dsn" field to the value that was provided on create.
func (*PostUpsertOne) UpdateNewValues ¶
func (u *PostUpsertOne) UpdateNewValues() *PostUpsertOne
UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. Using this option is equivalent to using:
client.Post.Create(). OnConflict( sql.ResolveWithNewValues(), sql.ResolveWith(func(u *sql.UpdateSet) { u.SetIgnore(post.FieldID) }), ). Exec(ctx)
func (*PostUpsertOne) UpdateTenantID ¶
func (u *PostUpsertOne) UpdateTenantID() *PostUpsertOne
UpdateTenantID sets the "tenant_id" field to the value that was provided on create.
func (*PostUpsertOne) UpdateTitle ¶
func (u *PostUpsertOne) UpdateTitle() *PostUpsertOne
UpdateTitle sets the "title" field to the value that was provided on create.
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(ctx context.Context, tx *ent.Tx) error { // Do some stuff before. if err := next.Rollback(ctx, tx); err != nil { return err } // Do some stuff after. return nil }) }
type Rollbacker ¶
Rollbacker is the interface that wraps the Rollback method.
type Tx ¶
type Tx struct { // Post is the client for interacting with the Post builders. Post *PostClient // contains filtered or unexported fields }
Tx is a transactional client that is created by calling Client.Tx().
func TxFromContext ¶
TxFromContext returns a Tx stored inside 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 or edge fails.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error implements the error interface.
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
Unwrap implements the errors.Wrapper interface.