Documentation ¶
Index ¶
- Constants
- Variables
- func Asc(fields ...string) func(*sql.Selector)
- func Desc(fields ...string) func(*sql.Selector)
- 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 Book
- type BookClient
- func (c *BookClient) Create() *BookCreate
- func (c *BookClient) CreateBulk(builders ...*BookCreate) *BookCreateBulk
- func (c *BookClient) Delete() *BookDelete
- func (c *BookClient) DeleteOne(b *Book) *BookDeleteOne
- func (c *BookClient) DeleteOneID(id string) *BookDeleteOne
- func (c *BookClient) Get(ctx context.Context, id string) (*Book, error)
- func (c *BookClient) GetX(ctx context.Context, id string) *Book
- func (c *BookClient) Hooks() []Hook
- func (c *BookClient) Intercept(interceptors ...Interceptor)
- func (c *BookClient) Interceptors() []Interceptor
- func (c *BookClient) MapCreateBulk(slice any, setFunc func(*BookCreate, int)) *BookCreateBulk
- func (c *BookClient) Query() *BookQuery
- func (c *BookClient) Update() *BookUpdate
- func (c *BookClient) UpdateOne(b *Book) *BookUpdateOne
- func (c *BookClient) UpdateOneID(id string) *BookUpdateOne
- func (c *BookClient) Use(hooks ...Hook)
- type BookCreate
- func (bc *BookCreate) Exec(ctx context.Context) error
- func (bc *BookCreate) ExecX(ctx context.Context)
- func (bc *BookCreate) Mutation() *BookMutation
- func (bc *BookCreate) Save(ctx context.Context) (*Book, error)
- func (bc *BookCreate) SaveX(ctx context.Context) *Book
- func (bc *BookCreate) SetAuthor(s string) *BookCreate
- func (bc *BookCreate) SetCategory(s string) *BookCreate
- func (bc *BookCreate) SetDescription(s string) *BookCreate
- func (bc *BookCreate) SetFeatured(b bool) *BookCreate
- func (bc *BookCreate) SetID(s string) *BookCreate
- func (bc *BookCreate) SetImageLink(s string) *BookCreate
- func (bc *BookCreate) SetNillableFeatured(b *bool) *BookCreate
- func (bc *BookCreate) SetSummary(s string) *BookCreate
- func (bc *BookCreate) SetTitle(s string) *BookCreate
- type BookCreateBulk
- type BookDelete
- type BookDeleteOne
- type BookGroupBy
- func (bgb *BookGroupBy) Aggregate(fns ...AggregateFunc) *BookGroupBy
- func (s *BookGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (s *BookGroupBy) BoolX(ctx context.Context) bool
- func (s *BookGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (s *BookGroupBy) BoolsX(ctx context.Context) []bool
- func (s *BookGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (s *BookGroupBy) Float64X(ctx context.Context) float64
- func (s *BookGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (s *BookGroupBy) Float64sX(ctx context.Context) []float64
- func (s *BookGroupBy) Int(ctx context.Context) (_ int, err error)
- func (s *BookGroupBy) IntX(ctx context.Context) int
- func (s *BookGroupBy) Ints(ctx context.Context) ([]int, error)
- func (s *BookGroupBy) IntsX(ctx context.Context) []int
- func (bgb *BookGroupBy) Scan(ctx context.Context, v any) error
- func (s *BookGroupBy) ScanX(ctx context.Context, v any)
- func (s *BookGroupBy) String(ctx context.Context) (_ string, err error)
- func (s *BookGroupBy) StringX(ctx context.Context) string
- func (s *BookGroupBy) Strings(ctx context.Context) ([]string, error)
- func (s *BookGroupBy) StringsX(ctx context.Context) []string
- type BookMutation
- func (m *BookMutation) AddField(name string, value ent.Value) error
- func (m *BookMutation) AddedEdges() []string
- func (m *BookMutation) AddedField(name string) (ent.Value, bool)
- func (m *BookMutation) AddedFields() []string
- func (m *BookMutation) AddedIDs(name string) []ent.Value
- func (m *BookMutation) Author() (r string, exists bool)
- func (m *BookMutation) Category() (r string, exists bool)
- func (m *BookMutation) ClearEdge(name string) error
- func (m *BookMutation) ClearField(name string) error
- func (m *BookMutation) ClearedEdges() []string
- func (m *BookMutation) ClearedFields() []string
- func (m BookMutation) Client() *Client
- func (m *BookMutation) Description() (r string, exists bool)
- func (m *BookMutation) EdgeCleared(name string) bool
- func (m *BookMutation) Featured() (r bool, exists bool)
- func (m *BookMutation) Field(name string) (ent.Value, bool)
- func (m *BookMutation) FieldCleared(name string) bool
- func (m *BookMutation) Fields() []string
- func (m *BookMutation) ID() (id string, exists bool)
- func (m *BookMutation) IDs(ctx context.Context) ([]string, error)
- func (m *BookMutation) ImageLink() (r string, exists bool)
- func (m *BookMutation) OldAuthor(ctx context.Context) (v string, err error)
- func (m *BookMutation) OldCategory(ctx context.Context) (v string, err error)
- func (m *BookMutation) OldDescription(ctx context.Context) (v string, err error)
- func (m *BookMutation) OldFeatured(ctx context.Context) (v bool, err error)
- func (m *BookMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *BookMutation) OldImageLink(ctx context.Context) (v string, err error)
- func (m *BookMutation) OldSummary(ctx context.Context) (v string, err error)
- func (m *BookMutation) OldTitle(ctx context.Context) (v string, err error)
- func (m *BookMutation) Op() Op
- func (m *BookMutation) RemovedEdges() []string
- func (m *BookMutation) RemovedIDs(name string) []ent.Value
- func (m *BookMutation) ResetAuthor()
- func (m *BookMutation) ResetCategory()
- func (m *BookMutation) ResetDescription()
- func (m *BookMutation) ResetEdge(name string) error
- func (m *BookMutation) ResetFeatured()
- func (m *BookMutation) ResetField(name string) error
- func (m *BookMutation) ResetImageLink()
- func (m *BookMutation) ResetSummary()
- func (m *BookMutation) ResetTitle()
- func (m *BookMutation) SetAuthor(s string)
- func (m *BookMutation) SetCategory(s string)
- func (m *BookMutation) SetDescription(s string)
- func (m *BookMutation) SetFeatured(b bool)
- func (m *BookMutation) SetField(name string, value ent.Value) error
- func (m *BookMutation) SetID(id string)
- func (m *BookMutation) SetImageLink(s string)
- func (m *BookMutation) SetOp(op Op)
- func (m *BookMutation) SetSummary(s string)
- func (m *BookMutation) SetTitle(s string)
- func (m *BookMutation) Summary() (r string, exists bool)
- func (m *BookMutation) Title() (r string, exists bool)
- func (m BookMutation) Tx() (*Tx, error)
- func (m *BookMutation) Type() string
- func (m *BookMutation) Where(ps ...predicate.Book)
- func (m *BookMutation) WhereP(ps ...func(*sql.Selector))
- type BookQuery
- func (bq *BookQuery) Aggregate(fns ...AggregateFunc) *BookSelect
- func (bq *BookQuery) All(ctx context.Context) ([]*Book, error)
- func (bq *BookQuery) AllX(ctx context.Context) []*Book
- func (bq *BookQuery) Clone() *BookQuery
- func (bq *BookQuery) Count(ctx context.Context) (int, error)
- func (bq *BookQuery) CountX(ctx context.Context) int
- func (bq *BookQuery) Exist(ctx context.Context) (bool, error)
- func (bq *BookQuery) ExistX(ctx context.Context) bool
- func (bq *BookQuery) First(ctx context.Context) (*Book, error)
- func (bq *BookQuery) FirstID(ctx context.Context) (id string, err error)
- func (bq *BookQuery) FirstIDX(ctx context.Context) string
- func (bq *BookQuery) FirstX(ctx context.Context) *Book
- func (bq *BookQuery) GroupBy(field string, fields ...string) *BookGroupBy
- func (bq *BookQuery) IDs(ctx context.Context) (ids []string, err error)
- func (bq *BookQuery) IDsX(ctx context.Context) []string
- func (bq *BookQuery) Limit(limit int) *BookQuery
- func (bq *BookQuery) Offset(offset int) *BookQuery
- func (bq *BookQuery) Only(ctx context.Context) (*Book, error)
- func (bq *BookQuery) OnlyID(ctx context.Context) (id string, err error)
- func (bq *BookQuery) OnlyIDX(ctx context.Context) string
- func (bq *BookQuery) OnlyX(ctx context.Context) *Book
- func (bq *BookQuery) Order(o ...book.OrderOption) *BookQuery
- func (bq *BookQuery) Select(fields ...string) *BookSelect
- func (bq *BookQuery) Unique(unique bool) *BookQuery
- func (bq *BookQuery) Where(ps ...predicate.Book) *BookQuery
- type BookSelect
- func (bs *BookSelect) Aggregate(fns ...AggregateFunc) *BookSelect
- func (s *BookSelect) Bool(ctx context.Context) (_ bool, err error)
- func (s *BookSelect) BoolX(ctx context.Context) bool
- func (s *BookSelect) Bools(ctx context.Context) ([]bool, error)
- func (s *BookSelect) BoolsX(ctx context.Context) []bool
- func (s *BookSelect) Float64(ctx context.Context) (_ float64, err error)
- func (s *BookSelect) Float64X(ctx context.Context) float64
- func (s *BookSelect) Float64s(ctx context.Context) ([]float64, error)
- func (s *BookSelect) Float64sX(ctx context.Context) []float64
- func (s *BookSelect) Int(ctx context.Context) (_ int, err error)
- func (s *BookSelect) IntX(ctx context.Context) int
- func (s *BookSelect) Ints(ctx context.Context) ([]int, error)
- func (s *BookSelect) IntsX(ctx context.Context) []int
- func (bs *BookSelect) Scan(ctx context.Context, v any) error
- func (s *BookSelect) ScanX(ctx context.Context, v any)
- func (s *BookSelect) String(ctx context.Context) (_ string, err error)
- func (s *BookSelect) StringX(ctx context.Context) string
- func (s *BookSelect) Strings(ctx context.Context) ([]string, error)
- func (s *BookSelect) StringsX(ctx context.Context) []string
- type BookUpdate
- func (bu *BookUpdate) Exec(ctx context.Context) error
- func (bu *BookUpdate) ExecX(ctx context.Context)
- func (bu *BookUpdate) Mutation() *BookMutation
- func (bu *BookUpdate) Save(ctx context.Context) (int, error)
- func (bu *BookUpdate) SaveX(ctx context.Context) int
- func (bu *BookUpdate) SetAuthor(s string) *BookUpdate
- func (bu *BookUpdate) SetCategory(s string) *BookUpdate
- func (bu *BookUpdate) SetDescription(s string) *BookUpdate
- func (bu *BookUpdate) SetFeatured(b bool) *BookUpdate
- func (bu *BookUpdate) SetImageLink(s string) *BookUpdate
- func (bu *BookUpdate) SetNillableAuthor(s *string) *BookUpdate
- func (bu *BookUpdate) SetNillableCategory(s *string) *BookUpdate
- func (bu *BookUpdate) SetNillableDescription(s *string) *BookUpdate
- func (bu *BookUpdate) SetNillableFeatured(b *bool) *BookUpdate
- func (bu *BookUpdate) SetNillableImageLink(s *string) *BookUpdate
- func (bu *BookUpdate) SetNillableSummary(s *string) *BookUpdate
- func (bu *BookUpdate) SetNillableTitle(s *string) *BookUpdate
- func (bu *BookUpdate) SetSummary(s string) *BookUpdate
- func (bu *BookUpdate) SetTitle(s string) *BookUpdate
- func (bu *BookUpdate) Where(ps ...predicate.Book) *BookUpdate
- type BookUpdateOne
- func (buo *BookUpdateOne) Exec(ctx context.Context) error
- func (buo *BookUpdateOne) ExecX(ctx context.Context)
- func (buo *BookUpdateOne) Mutation() *BookMutation
- func (buo *BookUpdateOne) Save(ctx context.Context) (*Book, error)
- func (buo *BookUpdateOne) SaveX(ctx context.Context) *Book
- func (buo *BookUpdateOne) Select(field string, fields ...string) *BookUpdateOne
- func (buo *BookUpdateOne) SetAuthor(s string) *BookUpdateOne
- func (buo *BookUpdateOne) SetCategory(s string) *BookUpdateOne
- func (buo *BookUpdateOne) SetDescription(s string) *BookUpdateOne
- func (buo *BookUpdateOne) SetFeatured(b bool) *BookUpdateOne
- func (buo *BookUpdateOne) SetImageLink(s string) *BookUpdateOne
- func (buo *BookUpdateOne) SetNillableAuthor(s *string) *BookUpdateOne
- func (buo *BookUpdateOne) SetNillableCategory(s *string) *BookUpdateOne
- func (buo *BookUpdateOne) SetNillableDescription(s *string) *BookUpdateOne
- func (buo *BookUpdateOne) SetNillableFeatured(b *bool) *BookUpdateOne
- func (buo *BookUpdateOne) SetNillableImageLink(s *string) *BookUpdateOne
- func (buo *BookUpdateOne) SetNillableSummary(s *string) *BookUpdateOne
- func (buo *BookUpdateOne) SetNillableTitle(s *string) *BookUpdateOne
- func (buo *BookUpdateOne) SetSummary(s string) *BookUpdateOne
- func (buo *BookUpdateOne) SetTitle(s string) *BookUpdateOne
- func (buo *BookUpdateOne) Where(ps ...predicate.Book) *BookUpdateOne
- type Books
- type Client
- func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
- func (c *Client) Close() error
- func (c *Client) Debug() *Client
- func (c *Client) Intercept(interceptors ...Interceptor)
- func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error)
- func (c *Client) Tx(ctx context.Context) (*Tx, error)
- func (c *Client) Use(hooks ...Hook)
- type CommitFunc
- type CommitHook
- type Committer
- type ConstraintError
- type Hook
- type InterceptFunc
- type Interceptor
- type MutateFunc
- type Mutation
- type Mutator
- type NotFoundError
- type NotLoadedError
- type NotSingularError
- type Op
- type Option
- type OrderFunc
- type Policy
- type Querier
- type QuerierFunc
- type Query
- type QueryContext
- type RollbackFunc
- type RollbackHook
- type Rollbacker
- type TraverseFunc
- type Traverser
- 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. TypeBook = "Book" )
Variables ¶
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
ErrTxStarted is returned when trying to start a new transaction from a transactional client.
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 Book ¶
type Book struct { // ID of the ent. ID string `json:"id,omitempty"` // Title holds the value of the "title" field. Title string `json:"title,omitempty"` // Author holds the value of the "author" field. Author string `json:"author,omitempty"` // Summary holds the value of the "summary" field. Summary string `json:"summary,omitempty"` // Description holds the value of the "description" field. Description string `json:"description,omitempty"` // Category holds the value of the "category" field. Category string `json:"category,omitempty"` // ImageLink holds the value of the "image_link" field. ImageLink string `json:"image_link,omitempty"` // Featured holds the value of the "featured" field. Featured bool `json:"featured,omitempty"` // contains filtered or unexported fields }
Book is the model entity for the Book schema.
func (*Book) Unwrap ¶
Unwrap unwraps the Book 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 (*Book) Update ¶
func (b *Book) Update() *BookUpdateOne
Update returns a builder for updating this Book. Note that you need to call Book.Unwrap() before calling this method if this Book was returned from a transaction, and the transaction was committed or rolled back.
type BookClient ¶
type BookClient struct {
// contains filtered or unexported fields
}
BookClient is a client for the Book schema.
func NewBookClient ¶
func NewBookClient(c config) *BookClient
NewBookClient returns a client for the Book from the given config.
func (*BookClient) Create ¶
func (c *BookClient) Create() *BookCreate
Create returns a builder for creating a Book entity.
func (*BookClient) CreateBulk ¶
func (c *BookClient) CreateBulk(builders ...*BookCreate) *BookCreateBulk
CreateBulk returns a builder for creating a bulk of Book entities.
func (*BookClient) Delete ¶
func (c *BookClient) Delete() *BookDelete
Delete returns a delete builder for Book.
func (*BookClient) DeleteOne ¶
func (c *BookClient) DeleteOne(b *Book) *BookDeleteOne
DeleteOne returns a builder for deleting the given entity.
func (*BookClient) DeleteOneID ¶
func (c *BookClient) DeleteOneID(id string) *BookDeleteOne
DeleteOneID returns a builder for deleting the given entity by its id.
func (*BookClient) GetX ¶
func (c *BookClient) GetX(ctx context.Context, id string) *Book
GetX is like Get, but panics if an error occurs.
func (*BookClient) Intercept ¶
func (c *BookClient) Intercept(interceptors ...Interceptor)
Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `book.Intercept(f(g(h())))`.
func (*BookClient) Interceptors ¶
func (c *BookClient) Interceptors() []Interceptor
Interceptors returns the client interceptors.
func (*BookClient) MapCreateBulk ¶
func (c *BookClient) MapCreateBulk(slice any, setFunc func(*BookCreate, int)) *BookCreateBulk
MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.
func (*BookClient) Query ¶
func (c *BookClient) Query() *BookQuery
Query returns a query builder for Book.
func (*BookClient) Update ¶
func (c *BookClient) Update() *BookUpdate
Update returns an update builder for Book.
func (*BookClient) UpdateOne ¶
func (c *BookClient) UpdateOne(b *Book) *BookUpdateOne
UpdateOne returns an update builder for the given entity.
func (*BookClient) UpdateOneID ¶
func (c *BookClient) UpdateOneID(id string) *BookUpdateOne
UpdateOneID returns an update builder for the given id.
func (*BookClient) Use ¶
func (c *BookClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `book.Hooks(f(g(h())))`.
type BookCreate ¶
type BookCreate struct {
// contains filtered or unexported fields
}
BookCreate is the builder for creating a Book entity.
func (*BookCreate) Exec ¶
func (bc *BookCreate) Exec(ctx context.Context) error
Exec executes the query.
func (*BookCreate) ExecX ¶
func (bc *BookCreate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*BookCreate) Mutation ¶
func (bc *BookCreate) Mutation() *BookMutation
Mutation returns the BookMutation object of the builder.
func (*BookCreate) Save ¶
func (bc *BookCreate) Save(ctx context.Context) (*Book, error)
Save creates the Book in the database.
func (*BookCreate) SaveX ¶
func (bc *BookCreate) SaveX(ctx context.Context) *Book
SaveX calls Save and panics if Save returns an error.
func (*BookCreate) SetAuthor ¶
func (bc *BookCreate) SetAuthor(s string) *BookCreate
SetAuthor sets the "author" field.
func (*BookCreate) SetCategory ¶
func (bc *BookCreate) SetCategory(s string) *BookCreate
SetCategory sets the "category" field.
func (*BookCreate) SetDescription ¶
func (bc *BookCreate) SetDescription(s string) *BookCreate
SetDescription sets the "description" field.
func (*BookCreate) SetFeatured ¶
func (bc *BookCreate) SetFeatured(b bool) *BookCreate
SetFeatured sets the "featured" field.
func (*BookCreate) SetID ¶
func (bc *BookCreate) SetID(s string) *BookCreate
SetID sets the "id" field.
func (*BookCreate) SetImageLink ¶
func (bc *BookCreate) SetImageLink(s string) *BookCreate
SetImageLink sets the "image_link" field.
func (*BookCreate) SetNillableFeatured ¶
func (bc *BookCreate) SetNillableFeatured(b *bool) *BookCreate
SetNillableFeatured sets the "featured" field if the given value is not nil.
func (*BookCreate) SetSummary ¶
func (bc *BookCreate) SetSummary(s string) *BookCreate
SetSummary sets the "summary" field.
func (*BookCreate) SetTitle ¶
func (bc *BookCreate) SetTitle(s string) *BookCreate
SetTitle sets the "title" field.
type BookCreateBulk ¶
type BookCreateBulk struct {
// contains filtered or unexported fields
}
BookCreateBulk is the builder for creating many Book entities in bulk.
func (*BookCreateBulk) Exec ¶
func (bcb *BookCreateBulk) Exec(ctx context.Context) error
Exec executes the query.
func (*BookCreateBulk) ExecX ¶
func (bcb *BookCreateBulk) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type BookDelete ¶
type BookDelete struct {
// contains filtered or unexported fields
}
BookDelete is the builder for deleting a Book entity.
func (*BookDelete) Exec ¶
func (bd *BookDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*BookDelete) ExecX ¶
func (bd *BookDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*BookDelete) Where ¶
func (bd *BookDelete) Where(ps ...predicate.Book) *BookDelete
Where appends a list predicates to the BookDelete builder.
type BookDeleteOne ¶
type BookDeleteOne struct {
// contains filtered or unexported fields
}
BookDeleteOne is the builder for deleting a single Book entity.
func (*BookDeleteOne) Exec ¶
func (bdo *BookDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*BookDeleteOne) ExecX ¶
func (bdo *BookDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*BookDeleteOne) Where ¶
func (bdo *BookDeleteOne) Where(ps ...predicate.Book) *BookDeleteOne
Where appends a list predicates to the BookDelete builder.
type BookGroupBy ¶
type BookGroupBy struct {
// contains filtered or unexported fields
}
BookGroupBy is the group-by builder for Book entities.
func (*BookGroupBy) Aggregate ¶
func (bgb *BookGroupBy) Aggregate(fns ...AggregateFunc) *BookGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*BookGroupBy) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*BookGroupBy) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*BookGroupBy) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*BookGroupBy) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*BookGroupBy) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*BookGroupBy) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*BookGroupBy) Scan ¶
func (bgb *BookGroupBy) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*BookGroupBy) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type BookMutation ¶
type BookMutation struct {
// contains filtered or unexported fields
}
BookMutation represents an operation that mutates the Book nodes in the graph.
func (*BookMutation) AddField ¶
func (m *BookMutation) 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 (*BookMutation) AddedEdges ¶
func (m *BookMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*BookMutation) AddedField ¶
func (m *BookMutation) 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 (*BookMutation) AddedFields ¶
func (m *BookMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*BookMutation) AddedIDs ¶
func (m *BookMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*BookMutation) Author ¶
func (m *BookMutation) Author() (r string, exists bool)
Author returns the value of the "author" field in the mutation.
func (*BookMutation) Category ¶
func (m *BookMutation) Category() (r string, exists bool)
Category returns the value of the "category" field in the mutation.
func (*BookMutation) ClearEdge ¶
func (m *BookMutation) 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 (*BookMutation) ClearField ¶
func (m *BookMutation) 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 (*BookMutation) ClearedEdges ¶
func (m *BookMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*BookMutation) ClearedFields ¶
func (m *BookMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (BookMutation) Client ¶
func (m BookMutation) 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 (*BookMutation) Description ¶
func (m *BookMutation) Description() (r string, exists bool)
Description returns the value of the "description" field in the mutation.
func (*BookMutation) EdgeCleared ¶
func (m *BookMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*BookMutation) Featured ¶
func (m *BookMutation) Featured() (r bool, exists bool)
Featured returns the value of the "featured" field in the mutation.
func (*BookMutation) Field ¶
func (m *BookMutation) 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 (*BookMutation) FieldCleared ¶
func (m *BookMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*BookMutation) Fields ¶
func (m *BookMutation) 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 (*BookMutation) ID ¶
func (m *BookMutation) ID() (id string, 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 (*BookMutation) IDs ¶
func (m *BookMutation) IDs(ctx context.Context) ([]string, 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 (*BookMutation) ImageLink ¶
func (m *BookMutation) ImageLink() (r string, exists bool)
ImageLink returns the value of the "image_link" field in the mutation.
func (*BookMutation) OldAuthor ¶
func (m *BookMutation) OldAuthor(ctx context.Context) (v string, err error)
OldAuthor returns the old "author" field's value of the Book entity. If the Book 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 (*BookMutation) OldCategory ¶
func (m *BookMutation) OldCategory(ctx context.Context) (v string, err error)
OldCategory returns the old "category" field's value of the Book entity. If the Book 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 (*BookMutation) OldDescription ¶
func (m *BookMutation) OldDescription(ctx context.Context) (v string, err error)
OldDescription returns the old "description" field's value of the Book entity. If the Book 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 (*BookMutation) OldFeatured ¶
func (m *BookMutation) OldFeatured(ctx context.Context) (v bool, err error)
OldFeatured returns the old "featured" field's value of the Book entity. If the Book 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 (*BookMutation) 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 (*BookMutation) OldImageLink ¶
func (m *BookMutation) OldImageLink(ctx context.Context) (v string, err error)
OldImageLink returns the old "image_link" field's value of the Book entity. If the Book 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 (*BookMutation) OldSummary ¶
func (m *BookMutation) OldSummary(ctx context.Context) (v string, err error)
OldSummary returns the old "summary" field's value of the Book entity. If the Book 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 (*BookMutation) OldTitle ¶
func (m *BookMutation) OldTitle(ctx context.Context) (v string, err error)
OldTitle returns the old "title" field's value of the Book entity. If the Book 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 (*BookMutation) RemovedEdges ¶
func (m *BookMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*BookMutation) RemovedIDs ¶
func (m *BookMutation) 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 (*BookMutation) ResetAuthor ¶
func (m *BookMutation) ResetAuthor()
ResetAuthor resets all changes to the "author" field.
func (*BookMutation) ResetCategory ¶
func (m *BookMutation) ResetCategory()
ResetCategory resets all changes to the "category" field.
func (*BookMutation) ResetDescription ¶
func (m *BookMutation) ResetDescription()
ResetDescription resets all changes to the "description" field.
func (*BookMutation) ResetEdge ¶
func (m *BookMutation) 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 (*BookMutation) ResetFeatured ¶
func (m *BookMutation) ResetFeatured()
ResetFeatured resets all changes to the "featured" field.
func (*BookMutation) ResetField ¶
func (m *BookMutation) 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 (*BookMutation) ResetImageLink ¶
func (m *BookMutation) ResetImageLink()
ResetImageLink resets all changes to the "image_link" field.
func (*BookMutation) ResetSummary ¶
func (m *BookMutation) ResetSummary()
ResetSummary resets all changes to the "summary" field.
func (*BookMutation) ResetTitle ¶
func (m *BookMutation) ResetTitle()
ResetTitle resets all changes to the "title" field.
func (*BookMutation) SetAuthor ¶
func (m *BookMutation) SetAuthor(s string)
SetAuthor sets the "author" field.
func (*BookMutation) SetCategory ¶
func (m *BookMutation) SetCategory(s string)
SetCategory sets the "category" field.
func (*BookMutation) SetDescription ¶
func (m *BookMutation) SetDescription(s string)
SetDescription sets the "description" field.
func (*BookMutation) SetFeatured ¶
func (m *BookMutation) SetFeatured(b bool)
SetFeatured sets the "featured" field.
func (*BookMutation) SetField ¶
func (m *BookMutation) 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 (*BookMutation) SetID ¶
func (m *BookMutation) SetID(id string)
SetID sets the value of the id field. Note that this operation is only accepted on creation of Book entities.
func (*BookMutation) SetImageLink ¶
func (m *BookMutation) SetImageLink(s string)
SetImageLink sets the "image_link" field.
func (*BookMutation) SetOp ¶
func (m *BookMutation) SetOp(op Op)
SetOp allows setting the mutation operation.
func (*BookMutation) SetSummary ¶
func (m *BookMutation) SetSummary(s string)
SetSummary sets the "summary" field.
func (*BookMutation) SetTitle ¶
func (m *BookMutation) SetTitle(s string)
SetTitle sets the "title" field.
func (*BookMutation) Summary ¶
func (m *BookMutation) Summary() (r string, exists bool)
Summary returns the value of the "summary" field in the mutation.
func (*BookMutation) Title ¶
func (m *BookMutation) Title() (r string, exists bool)
Title returns the value of the "title" field in the mutation.
func (BookMutation) Tx ¶
func (m BookMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*BookMutation) Type ¶
func (m *BookMutation) Type() string
Type returns the node type of this mutation (Book).
func (*BookMutation) Where ¶
func (m *BookMutation) Where(ps ...predicate.Book)
Where appends a list predicates to the BookMutation builder.
func (*BookMutation) WhereP ¶
func (m *BookMutation) WhereP(ps ...func(*sql.Selector))
WhereP appends storage-level predicates to the BookMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.
type BookQuery ¶
type BookQuery struct {
// contains filtered or unexported fields
}
BookQuery is the builder for querying Book entities.
func (*BookQuery) Aggregate ¶
func (bq *BookQuery) Aggregate(fns ...AggregateFunc) *BookSelect
Aggregate returns a BookSelect configured with the given aggregations.
func (*BookQuery) Clone ¶
Clone returns a duplicate of the BookQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*BookQuery) First ¶
First returns the first Book entity from the query. Returns a *NotFoundError when no Book was found.
func (*BookQuery) FirstID ¶
FirstID returns the first Book ID from the query. Returns a *NotFoundError when no Book ID was found.
func (*BookQuery) GroupBy ¶
func (bq *BookQuery) GroupBy(field string, fields ...string) *BookGroupBy
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 { Title string `json:"title,omitempty"` Count int `json:"count,omitempty"` } client.Book.Query(). GroupBy(book.FieldTitle). Aggregate(ent.Count()). Scan(ctx, &v)
func (*BookQuery) Only ¶
Only returns a single Book entity found by the query, ensuring it only returns one. Returns a *NotSingularError when more than one Book entity is found. Returns a *NotFoundError when no Book entities are found.
func (*BookQuery) OnlyID ¶
OnlyID is like Only, but returns the only Book ID in the query. Returns a *NotSingularError when more than one Book ID is found. Returns a *NotFoundError when no entities are found.
func (*BookQuery) Order ¶
func (bq *BookQuery) Order(o ...book.OrderOption) *BookQuery
Order specifies how the records should be ordered.
func (*BookQuery) Select ¶
func (bq *BookQuery) Select(fields ...string) *BookSelect
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 { Title string `json:"title,omitempty"` } client.Book.Query(). Select(book.FieldTitle). Scan(ctx, &v)
type BookSelect ¶
type BookSelect struct { *BookQuery // contains filtered or unexported fields }
BookSelect is the builder for selecting fields of Book entities.
func (*BookSelect) Aggregate ¶
func (bs *BookSelect) Aggregate(fns ...AggregateFunc) *BookSelect
Aggregate adds the given aggregation functions to the selector query.
func (*BookSelect) Bool ¶
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*BookSelect) Bools ¶
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*BookSelect) Float64 ¶
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*BookSelect) Float64s ¶
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*BookSelect) Int ¶
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*BookSelect) Ints ¶
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*BookSelect) Scan ¶
func (bs *BookSelect) Scan(ctx context.Context, v any) error
Scan applies the selector query and scans the result into the given value.
func (*BookSelect) String ¶
String returns a single string from a selector. It is only allowed when selecting one field.
type BookUpdate ¶
type BookUpdate struct {
// contains filtered or unexported fields
}
BookUpdate is the builder for updating Book entities.
func (*BookUpdate) Exec ¶
func (bu *BookUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*BookUpdate) ExecX ¶
func (bu *BookUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*BookUpdate) Mutation ¶
func (bu *BookUpdate) Mutation() *BookMutation
Mutation returns the BookMutation object of the builder.
func (*BookUpdate) Save ¶
func (bu *BookUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*BookUpdate) SaveX ¶
func (bu *BookUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*BookUpdate) SetAuthor ¶
func (bu *BookUpdate) SetAuthor(s string) *BookUpdate
SetAuthor sets the "author" field.
func (*BookUpdate) SetCategory ¶
func (bu *BookUpdate) SetCategory(s string) *BookUpdate
SetCategory sets the "category" field.
func (*BookUpdate) SetDescription ¶
func (bu *BookUpdate) SetDescription(s string) *BookUpdate
SetDescription sets the "description" field.
func (*BookUpdate) SetFeatured ¶
func (bu *BookUpdate) SetFeatured(b bool) *BookUpdate
SetFeatured sets the "featured" field.
func (*BookUpdate) SetImageLink ¶
func (bu *BookUpdate) SetImageLink(s string) *BookUpdate
SetImageLink sets the "image_link" field.
func (*BookUpdate) SetNillableAuthor ¶
func (bu *BookUpdate) SetNillableAuthor(s *string) *BookUpdate
SetNillableAuthor sets the "author" field if the given value is not nil.
func (*BookUpdate) SetNillableCategory ¶
func (bu *BookUpdate) SetNillableCategory(s *string) *BookUpdate
SetNillableCategory sets the "category" field if the given value is not nil.
func (*BookUpdate) SetNillableDescription ¶
func (bu *BookUpdate) SetNillableDescription(s *string) *BookUpdate
SetNillableDescription sets the "description" field if the given value is not nil.
func (*BookUpdate) SetNillableFeatured ¶
func (bu *BookUpdate) SetNillableFeatured(b *bool) *BookUpdate
SetNillableFeatured sets the "featured" field if the given value is not nil.
func (*BookUpdate) SetNillableImageLink ¶
func (bu *BookUpdate) SetNillableImageLink(s *string) *BookUpdate
SetNillableImageLink sets the "image_link" field if the given value is not nil.
func (*BookUpdate) SetNillableSummary ¶
func (bu *BookUpdate) SetNillableSummary(s *string) *BookUpdate
SetNillableSummary sets the "summary" field if the given value is not nil.
func (*BookUpdate) SetNillableTitle ¶
func (bu *BookUpdate) SetNillableTitle(s *string) *BookUpdate
SetNillableTitle sets the "title" field if the given value is not nil.
func (*BookUpdate) SetSummary ¶
func (bu *BookUpdate) SetSummary(s string) *BookUpdate
SetSummary sets the "summary" field.
func (*BookUpdate) SetTitle ¶
func (bu *BookUpdate) SetTitle(s string) *BookUpdate
SetTitle sets the "title" field.
func (*BookUpdate) Where ¶
func (bu *BookUpdate) Where(ps ...predicate.Book) *BookUpdate
Where appends a list predicates to the BookUpdate builder.
type BookUpdateOne ¶
type BookUpdateOne struct {
// contains filtered or unexported fields
}
BookUpdateOne is the builder for updating a single Book entity.
func (*BookUpdateOne) Exec ¶
func (buo *BookUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*BookUpdateOne) ExecX ¶
func (buo *BookUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*BookUpdateOne) Mutation ¶
func (buo *BookUpdateOne) Mutation() *BookMutation
Mutation returns the BookMutation object of the builder.
func (*BookUpdateOne) Save ¶
func (buo *BookUpdateOne) Save(ctx context.Context) (*Book, error)
Save executes the query and returns the updated Book entity.
func (*BookUpdateOne) SaveX ¶
func (buo *BookUpdateOne) SaveX(ctx context.Context) *Book
SaveX is like Save, but panics if an error occurs.
func (*BookUpdateOne) Select ¶
func (buo *BookUpdateOne) Select(field string, fields ...string) *BookUpdateOne
Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.
func (*BookUpdateOne) SetAuthor ¶
func (buo *BookUpdateOne) SetAuthor(s string) *BookUpdateOne
SetAuthor sets the "author" field.
func (*BookUpdateOne) SetCategory ¶
func (buo *BookUpdateOne) SetCategory(s string) *BookUpdateOne
SetCategory sets the "category" field.
func (*BookUpdateOne) SetDescription ¶
func (buo *BookUpdateOne) SetDescription(s string) *BookUpdateOne
SetDescription sets the "description" field.
func (*BookUpdateOne) SetFeatured ¶
func (buo *BookUpdateOne) SetFeatured(b bool) *BookUpdateOne
SetFeatured sets the "featured" field.
func (*BookUpdateOne) SetImageLink ¶
func (buo *BookUpdateOne) SetImageLink(s string) *BookUpdateOne
SetImageLink sets the "image_link" field.
func (*BookUpdateOne) SetNillableAuthor ¶
func (buo *BookUpdateOne) SetNillableAuthor(s *string) *BookUpdateOne
SetNillableAuthor sets the "author" field if the given value is not nil.
func (*BookUpdateOne) SetNillableCategory ¶
func (buo *BookUpdateOne) SetNillableCategory(s *string) *BookUpdateOne
SetNillableCategory sets the "category" field if the given value is not nil.
func (*BookUpdateOne) SetNillableDescription ¶
func (buo *BookUpdateOne) SetNillableDescription(s *string) *BookUpdateOne
SetNillableDescription sets the "description" field if the given value is not nil.
func (*BookUpdateOne) SetNillableFeatured ¶
func (buo *BookUpdateOne) SetNillableFeatured(b *bool) *BookUpdateOne
SetNillableFeatured sets the "featured" field if the given value is not nil.
func (*BookUpdateOne) SetNillableImageLink ¶
func (buo *BookUpdateOne) SetNillableImageLink(s *string) *BookUpdateOne
SetNillableImageLink sets the "image_link" field if the given value is not nil.
func (*BookUpdateOne) SetNillableSummary ¶
func (buo *BookUpdateOne) SetNillableSummary(s *string) *BookUpdateOne
SetNillableSummary sets the "summary" field if the given value is not nil.
func (*BookUpdateOne) SetNillableTitle ¶
func (buo *BookUpdateOne) SetNillableTitle(s *string) *BookUpdateOne
SetNillableTitle sets the "title" field if the given value is not nil.
func (*BookUpdateOne) SetSummary ¶
func (buo *BookUpdateOne) SetSummary(s string) *BookUpdateOne
SetSummary sets the "summary" field.
func (*BookUpdateOne) SetTitle ¶
func (buo *BookUpdateOne) SetTitle(s string) *BookUpdateOne
SetTitle sets the "title" field.
func (*BookUpdateOne) Where ¶
func (buo *BookUpdateOne) Where(ps ...predicate.Book) *BookUpdateOne
Where appends a list predicates to the BookUpdate builder.
type Client ¶
type Client struct { // Schema is the client for creating, migrating and dropping schema. Schema *migrate.Schema // Book is the client for interacting with the Book builders. Book *BookClient // 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(). Book. Query(). Count(ctx)
func (*Client) Intercept ¶
func (c *Client) Intercept(interceptors ...Interceptor)
Intercept adds the query interceptors to all the entity clients. In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
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 InterceptFunc ¶
type InterceptFunc = ent.InterceptFunc
ent aliases to avoid import conflicts in user's code.
type Interceptor ¶
type Interceptor = ent.Interceptor
ent aliases to avoid import conflicts in user's code.
type MutateFunc ¶
type MutateFunc = ent.MutateFunc
ent aliases to avoid import conflicts in user's code.
type 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 OrderFunc ¶
OrderFunc applies an ordering on the sql selector. Deprecated: Use Asc/Desc functions or the package builders instead.
type QuerierFunc ¶
type QuerierFunc = ent.QuerierFunc
ent aliases to avoid import conflicts in user's code.
type QueryContext ¶
type QueryContext = ent.QueryContext
ent aliases to avoid import conflicts in user's code.
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 TraverseFunc ¶
type TraverseFunc = ent.TraverseFunc
ent aliases to avoid import conflicts in user's code.
type Tx ¶
type Tx struct { // Book is the client for interacting with the Book builders. Book *BookClient // 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.