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 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 int) *BookDeleteOne
- func (c *BookClient) Get(ctx context.Context, id int) (*Book, error)
- func (c *BookClient) GetX(ctx context.Context, id int) *Book
- func (c *BookClient) Hooks() []Hook
- func (c *BookClient) Query() *BookQuery
- func (c *BookClient) QueryCollection(b *Book) *CollectionQuery
- func (c *BookClient) Update() *BookUpdate
- func (c *BookClient) UpdateOne(b *Book) *BookUpdateOne
- func (c *BookClient) UpdateOneID(id int) *BookUpdateOne
- func (c *BookClient) Use(hooks ...Hook)
- type BookCreate
- func (bc *BookCreate) AddCollection(c ...*Collection) *BookCreate
- func (bc *BookCreate) AddCollectionIDs(ids ...int) *BookCreate
- 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) SetCreatedAt(t time.Time) *BookCreate
- func (bc *BookCreate) SetDescription(s string) *BookCreate
- func (bc *BookCreate) SetNillableCreatedAt(t *time.Time) *BookCreate
- func (bc *BookCreate) SetNillableUpdatedat(t *time.Time) *BookCreate
- func (bc *BookCreate) SetTitle(s string) *BookCreate
- func (bc *BookCreate) SetUpdatedat(t time.Time) *BookCreate
- type BookCreateBulk
- type BookDelete
- type BookDeleteOne
- type BookEdges
- type BookGroupBy
- func (bgb *BookGroupBy) Aggregate(fns ...AggregateFunc) *BookGroupBy
- func (bgb *BookGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (bgb *BookGroupBy) BoolX(ctx context.Context) bool
- func (bgb *BookGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (bgb *BookGroupBy) BoolsX(ctx context.Context) []bool
- func (bgb *BookGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (bgb *BookGroupBy) Float64X(ctx context.Context) float64
- func (bgb *BookGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (bgb *BookGroupBy) Float64sX(ctx context.Context) []float64
- func (bgb *BookGroupBy) Int(ctx context.Context) (_ int, err error)
- func (bgb *BookGroupBy) IntX(ctx context.Context) int
- func (bgb *BookGroupBy) Ints(ctx context.Context) ([]int, error)
- func (bgb *BookGroupBy) IntsX(ctx context.Context) []int
- func (bgb *BookGroupBy) Scan(ctx context.Context, v interface{}) error
- func (bgb *BookGroupBy) ScanX(ctx context.Context, v interface{})
- func (bgb *BookGroupBy) String(ctx context.Context) (_ string, err error)
- func (bgb *BookGroupBy) StringX(ctx context.Context) string
- func (bgb *BookGroupBy) Strings(ctx context.Context) ([]string, error)
- func (bgb *BookGroupBy) StringsX(ctx context.Context) []string
- type BookMutation
- func (m *BookMutation) AddCollectionIDs(ids ...int)
- 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) ClearCollection()
- 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) CollectionCleared() bool
- func (m *BookMutation) CollectionIDs() (ids []int)
- func (m *BookMutation) CreatedAt() (r time.Time, exists bool)
- func (m *BookMutation) Description() (r string, exists bool)
- func (m *BookMutation) EdgeCleared(name string) 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 int, exists bool)
- func (m *BookMutation) OldAuthor(ctx context.Context) (v string, err error)
- func (m *BookMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error)
- func (m *BookMutation) OldDescription(ctx context.Context) (v string, err error)
- func (m *BookMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *BookMutation) OldTitle(ctx context.Context) (v string, err error)
- func (m *BookMutation) OldUpdatedat(ctx context.Context) (v time.Time, err error)
- func (m *BookMutation) Op() Op
- func (m *BookMutation) RemoveCollectionIDs(ids ...int)
- func (m *BookMutation) RemovedCollectionIDs() (ids []int)
- func (m *BookMutation) RemovedEdges() []string
- func (m *BookMutation) RemovedIDs(name string) []ent.Value
- func (m *BookMutation) ResetAuthor()
- func (m *BookMutation) ResetCollection()
- func (m *BookMutation) ResetCreatedAt()
- func (m *BookMutation) ResetDescription()
- func (m *BookMutation) ResetEdge(name string) error
- func (m *BookMutation) ResetField(name string) error
- func (m *BookMutation) ResetTitle()
- func (m *BookMutation) ResetUpdatedat()
- func (m *BookMutation) SetAuthor(s string)
- func (m *BookMutation) SetCreatedAt(t time.Time)
- func (m *BookMutation) SetDescription(s string)
- func (m *BookMutation) SetField(name string, value ent.Value) error
- func (m *BookMutation) SetTitle(s string)
- func (m *BookMutation) SetUpdatedat(t time.Time)
- func (m *BookMutation) Title() (r string, exists bool)
- func (m BookMutation) Tx() (*Tx, error)
- func (m *BookMutation) Type() string
- func (m *BookMutation) Updatedat() (r time.Time, exists bool)
- type BookQuery
- 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 int, err error)
- func (bq *BookQuery) FirstIDX(ctx context.Context) int
- func (bq *BookQuery) FirstX(ctx context.Context) *Book
- func (bq *BookQuery) GroupBy(field string, fields ...string) *BookGroupBy
- func (bq *BookQuery) IDs(ctx context.Context) ([]int, error)
- func (bq *BookQuery) IDsX(ctx context.Context) []int
- 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 int, err error)
- func (bq *BookQuery) OnlyIDX(ctx context.Context) int
- func (bq *BookQuery) OnlyX(ctx context.Context) *Book
- func (bq *BookQuery) Order(o ...OrderFunc) *BookQuery
- func (bq *BookQuery) QueryCollection() *CollectionQuery
- func (bq *BookQuery) Select(field string, fields ...string) *BookSelect
- func (bq *BookQuery) Where(ps ...predicate.Book) *BookQuery
- func (bq *BookQuery) WithCollection(opts ...func(*CollectionQuery)) *BookQuery
- type BookSelect
- func (bs *BookSelect) Bool(ctx context.Context) (_ bool, err error)
- func (bs *BookSelect) BoolX(ctx context.Context) bool
- func (bs *BookSelect) Bools(ctx context.Context) ([]bool, error)
- func (bs *BookSelect) BoolsX(ctx context.Context) []bool
- func (bs *BookSelect) Float64(ctx context.Context) (_ float64, err error)
- func (bs *BookSelect) Float64X(ctx context.Context) float64
- func (bs *BookSelect) Float64s(ctx context.Context) ([]float64, error)
- func (bs *BookSelect) Float64sX(ctx context.Context) []float64
- func (bs *BookSelect) Int(ctx context.Context) (_ int, err error)
- func (bs *BookSelect) IntX(ctx context.Context) int
- func (bs *BookSelect) Ints(ctx context.Context) ([]int, error)
- func (bs *BookSelect) IntsX(ctx context.Context) []int
- func (bs *BookSelect) Scan(ctx context.Context, v interface{}) error
- func (bs *BookSelect) ScanX(ctx context.Context, v interface{})
- func (bs *BookSelect) String(ctx context.Context) (_ string, err error)
- func (bs *BookSelect) StringX(ctx context.Context) string
- func (bs *BookSelect) Strings(ctx context.Context) ([]string, error)
- func (bs *BookSelect) StringsX(ctx context.Context) []string
- type BookUpdate
- func (bu *BookUpdate) AddCollection(c ...*Collection) *BookUpdate
- func (bu *BookUpdate) AddCollectionIDs(ids ...int) *BookUpdate
- func (bu *BookUpdate) ClearCollection() *BookUpdate
- func (bu *BookUpdate) Exec(ctx context.Context) error
- func (bu *BookUpdate) ExecX(ctx context.Context)
- func (bu *BookUpdate) Mutation() *BookMutation
- func (bu *BookUpdate) RemoveCollection(c ...*Collection) *BookUpdate
- func (bu *BookUpdate) RemoveCollectionIDs(ids ...int) *BookUpdate
- 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) SetCreatedAt(t time.Time) *BookUpdate
- func (bu *BookUpdate) SetDescription(s string) *BookUpdate
- func (bu *BookUpdate) SetTitle(s string) *BookUpdate
- func (bu *BookUpdate) SetUpdatedat(t time.Time) *BookUpdate
- func (bu *BookUpdate) Where(ps ...predicate.Book) *BookUpdate
- type BookUpdateOne
- func (buo *BookUpdateOne) AddCollection(c ...*Collection) *BookUpdateOne
- func (buo *BookUpdateOne) AddCollectionIDs(ids ...int) *BookUpdateOne
- func (buo *BookUpdateOne) ClearCollection() *BookUpdateOne
- func (buo *BookUpdateOne) Exec(ctx context.Context) error
- func (buo *BookUpdateOne) ExecX(ctx context.Context)
- func (buo *BookUpdateOne) Mutation() *BookMutation
- func (buo *BookUpdateOne) RemoveCollection(c ...*Collection) *BookUpdateOne
- func (buo *BookUpdateOne) RemoveCollectionIDs(ids ...int) *BookUpdateOne
- func (buo *BookUpdateOne) Save(ctx context.Context) (*Book, error)
- func (buo *BookUpdateOne) SaveX(ctx context.Context) *Book
- func (buo *BookUpdateOne) SetAuthor(s string) *BookUpdateOne
- func (buo *BookUpdateOne) SetCreatedAt(t time.Time) *BookUpdateOne
- func (buo *BookUpdateOne) SetDescription(s string) *BookUpdateOne
- func (buo *BookUpdateOne) SetTitle(s string) *BookUpdateOne
- func (buo *BookUpdateOne) SetUpdatedat(t time.Time) *BookUpdateOne
- type Books
- type Client
- type Collection
- type CollectionClient
- func (c *CollectionClient) Create() *CollectionCreate
- func (c *CollectionClient) CreateBulk(builders ...*CollectionCreate) *CollectionCreateBulk
- func (c *CollectionClient) Delete() *CollectionDelete
- func (c *CollectionClient) DeleteOne(co *Collection) *CollectionDeleteOne
- func (c *CollectionClient) DeleteOneID(id int) *CollectionDeleteOne
- func (c *CollectionClient) Get(ctx context.Context, id int) (*Collection, error)
- func (c *CollectionClient) GetX(ctx context.Context, id int) *Collection
- func (c *CollectionClient) Hooks() []Hook
- func (c *CollectionClient) Query() *CollectionQuery
- func (c *CollectionClient) QueryBooks(co *Collection) *BookQuery
- func (c *CollectionClient) Update() *CollectionUpdate
- func (c *CollectionClient) UpdateOne(co *Collection) *CollectionUpdateOne
- func (c *CollectionClient) UpdateOneID(id int) *CollectionUpdateOne
- func (c *CollectionClient) Use(hooks ...Hook)
- type CollectionCreate
- func (cc *CollectionCreate) AddBookIDs(ids ...int) *CollectionCreate
- func (cc *CollectionCreate) AddBooks(b ...*Book) *CollectionCreate
- func (cc *CollectionCreate) Mutation() *CollectionMutation
- func (cc *CollectionCreate) Save(ctx context.Context) (*Collection, error)
- func (cc *CollectionCreate) SaveX(ctx context.Context) *Collection
- func (cc *CollectionCreate) SetCreatedAt(t time.Time) *CollectionCreate
- func (cc *CollectionCreate) SetName(s string) *CollectionCreate
- func (cc *CollectionCreate) SetNillableCreatedAt(t *time.Time) *CollectionCreate
- func (cc *CollectionCreate) SetNillableUpdatedat(t *time.Time) *CollectionCreate
- func (cc *CollectionCreate) SetUpdatedat(t time.Time) *CollectionCreate
- type CollectionCreateBulk
- type CollectionDelete
- type CollectionDeleteOne
- type CollectionEdges
- type CollectionGroupBy
- func (cgb *CollectionGroupBy) Aggregate(fns ...AggregateFunc) *CollectionGroupBy
- func (cgb *CollectionGroupBy) Bool(ctx context.Context) (_ bool, err error)
- func (cgb *CollectionGroupBy) BoolX(ctx context.Context) bool
- func (cgb *CollectionGroupBy) Bools(ctx context.Context) ([]bool, error)
- func (cgb *CollectionGroupBy) BoolsX(ctx context.Context) []bool
- func (cgb *CollectionGroupBy) Float64(ctx context.Context) (_ float64, err error)
- func (cgb *CollectionGroupBy) Float64X(ctx context.Context) float64
- func (cgb *CollectionGroupBy) Float64s(ctx context.Context) ([]float64, error)
- func (cgb *CollectionGroupBy) Float64sX(ctx context.Context) []float64
- func (cgb *CollectionGroupBy) Int(ctx context.Context) (_ int, err error)
- func (cgb *CollectionGroupBy) IntX(ctx context.Context) int
- func (cgb *CollectionGroupBy) Ints(ctx context.Context) ([]int, error)
- func (cgb *CollectionGroupBy) IntsX(ctx context.Context) []int
- func (cgb *CollectionGroupBy) Scan(ctx context.Context, v interface{}) error
- func (cgb *CollectionGroupBy) ScanX(ctx context.Context, v interface{})
- func (cgb *CollectionGroupBy) String(ctx context.Context) (_ string, err error)
- func (cgb *CollectionGroupBy) StringX(ctx context.Context) string
- func (cgb *CollectionGroupBy) Strings(ctx context.Context) ([]string, error)
- func (cgb *CollectionGroupBy) StringsX(ctx context.Context) []string
- type CollectionMutation
- func (m *CollectionMutation) AddBookIDs(ids ...int)
- func (m *CollectionMutation) AddField(name string, value ent.Value) error
- func (m *CollectionMutation) AddedEdges() []string
- func (m *CollectionMutation) AddedField(name string) (ent.Value, bool)
- func (m *CollectionMutation) AddedFields() []string
- func (m *CollectionMutation) AddedIDs(name string) []ent.Value
- func (m *CollectionMutation) BooksCleared() bool
- func (m *CollectionMutation) BooksIDs() (ids []int)
- func (m *CollectionMutation) ClearBooks()
- func (m *CollectionMutation) ClearEdge(name string) error
- func (m *CollectionMutation) ClearField(name string) error
- func (m *CollectionMutation) ClearedEdges() []string
- func (m *CollectionMutation) ClearedFields() []string
- func (m CollectionMutation) Client() *Client
- func (m *CollectionMutation) CreatedAt() (r time.Time, exists bool)
- func (m *CollectionMutation) EdgeCleared(name string) bool
- func (m *CollectionMutation) Field(name string) (ent.Value, bool)
- func (m *CollectionMutation) FieldCleared(name string) bool
- func (m *CollectionMutation) Fields() []string
- func (m *CollectionMutation) ID() (id int, exists bool)
- func (m *CollectionMutation) Name() (r string, exists bool)
- func (m *CollectionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error)
- func (m *CollectionMutation) OldField(ctx context.Context, name string) (ent.Value, error)
- func (m *CollectionMutation) OldName(ctx context.Context) (v string, err error)
- func (m *CollectionMutation) OldUpdatedat(ctx context.Context) (v time.Time, err error)
- func (m *CollectionMutation) Op() Op
- func (m *CollectionMutation) RemoveBookIDs(ids ...int)
- func (m *CollectionMutation) RemovedBooksIDs() (ids []int)
- func (m *CollectionMutation) RemovedEdges() []string
- func (m *CollectionMutation) RemovedIDs(name string) []ent.Value
- func (m *CollectionMutation) ResetBooks()
- func (m *CollectionMutation) ResetCreatedAt()
- func (m *CollectionMutation) ResetEdge(name string) error
- func (m *CollectionMutation) ResetField(name string) error
- func (m *CollectionMutation) ResetName()
- func (m *CollectionMutation) ResetUpdatedat()
- func (m *CollectionMutation) SetCreatedAt(t time.Time)
- func (m *CollectionMutation) SetField(name string, value ent.Value) error
- func (m *CollectionMutation) SetName(s string)
- func (m *CollectionMutation) SetUpdatedat(t time.Time)
- func (m CollectionMutation) Tx() (*Tx, error)
- func (m *CollectionMutation) Type() string
- func (m *CollectionMutation) Updatedat() (r time.Time, exists bool)
- type CollectionQuery
- func (cq *CollectionQuery) All(ctx context.Context) ([]*Collection, error)
- func (cq *CollectionQuery) AllX(ctx context.Context) []*Collection
- func (cq *CollectionQuery) Clone() *CollectionQuery
- func (cq *CollectionQuery) Count(ctx context.Context) (int, error)
- func (cq *CollectionQuery) CountX(ctx context.Context) int
- func (cq *CollectionQuery) Exist(ctx context.Context) (bool, error)
- func (cq *CollectionQuery) ExistX(ctx context.Context) bool
- func (cq *CollectionQuery) First(ctx context.Context) (*Collection, error)
- func (cq *CollectionQuery) FirstID(ctx context.Context) (id int, err error)
- func (cq *CollectionQuery) FirstIDX(ctx context.Context) int
- func (cq *CollectionQuery) FirstX(ctx context.Context) *Collection
- func (cq *CollectionQuery) GroupBy(field string, fields ...string) *CollectionGroupBy
- func (cq *CollectionQuery) IDs(ctx context.Context) ([]int, error)
- func (cq *CollectionQuery) IDsX(ctx context.Context) []int
- func (cq *CollectionQuery) Limit(limit int) *CollectionQuery
- func (cq *CollectionQuery) Offset(offset int) *CollectionQuery
- func (cq *CollectionQuery) Only(ctx context.Context) (*Collection, error)
- func (cq *CollectionQuery) OnlyID(ctx context.Context) (id int, err error)
- func (cq *CollectionQuery) OnlyIDX(ctx context.Context) int
- func (cq *CollectionQuery) OnlyX(ctx context.Context) *Collection
- func (cq *CollectionQuery) Order(o ...OrderFunc) *CollectionQuery
- func (cq *CollectionQuery) QueryBooks() *BookQuery
- func (cq *CollectionQuery) Select(field string, fields ...string) *CollectionSelect
- func (cq *CollectionQuery) Where(ps ...predicate.Collection) *CollectionQuery
- func (cq *CollectionQuery) WithBooks(opts ...func(*BookQuery)) *CollectionQuery
- type CollectionSelect
- func (cs *CollectionSelect) Bool(ctx context.Context) (_ bool, err error)
- func (cs *CollectionSelect) BoolX(ctx context.Context) bool
- func (cs *CollectionSelect) Bools(ctx context.Context) ([]bool, error)
- func (cs *CollectionSelect) BoolsX(ctx context.Context) []bool
- func (cs *CollectionSelect) Float64(ctx context.Context) (_ float64, err error)
- func (cs *CollectionSelect) Float64X(ctx context.Context) float64
- func (cs *CollectionSelect) Float64s(ctx context.Context) ([]float64, error)
- func (cs *CollectionSelect) Float64sX(ctx context.Context) []float64
- func (cs *CollectionSelect) Int(ctx context.Context) (_ int, err error)
- func (cs *CollectionSelect) IntX(ctx context.Context) int
- func (cs *CollectionSelect) Ints(ctx context.Context) ([]int, error)
- func (cs *CollectionSelect) IntsX(ctx context.Context) []int
- func (cs *CollectionSelect) Scan(ctx context.Context, v interface{}) error
- func (cs *CollectionSelect) ScanX(ctx context.Context, v interface{})
- func (cs *CollectionSelect) String(ctx context.Context) (_ string, err error)
- func (cs *CollectionSelect) StringX(ctx context.Context) string
- func (cs *CollectionSelect) Strings(ctx context.Context) ([]string, error)
- func (cs *CollectionSelect) StringsX(ctx context.Context) []string
- type CollectionUpdate
- func (cu *CollectionUpdate) AddBookIDs(ids ...int) *CollectionUpdate
- func (cu *CollectionUpdate) AddBooks(b ...*Book) *CollectionUpdate
- func (cu *CollectionUpdate) ClearBooks() *CollectionUpdate
- func (cu *CollectionUpdate) Exec(ctx context.Context) error
- func (cu *CollectionUpdate) ExecX(ctx context.Context)
- func (cu *CollectionUpdate) Mutation() *CollectionMutation
- func (cu *CollectionUpdate) RemoveBookIDs(ids ...int) *CollectionUpdate
- func (cu *CollectionUpdate) RemoveBooks(b ...*Book) *CollectionUpdate
- func (cu *CollectionUpdate) Save(ctx context.Context) (int, error)
- func (cu *CollectionUpdate) SaveX(ctx context.Context) int
- func (cu *CollectionUpdate) SetCreatedAt(t time.Time) *CollectionUpdate
- func (cu *CollectionUpdate) SetName(s string) *CollectionUpdate
- func (cu *CollectionUpdate) SetUpdatedat(t time.Time) *CollectionUpdate
- func (cu *CollectionUpdate) Where(ps ...predicate.Collection) *CollectionUpdate
- type CollectionUpdateOne
- func (cuo *CollectionUpdateOne) AddBookIDs(ids ...int) *CollectionUpdateOne
- func (cuo *CollectionUpdateOne) AddBooks(b ...*Book) *CollectionUpdateOne
- func (cuo *CollectionUpdateOne) ClearBooks() *CollectionUpdateOne
- func (cuo *CollectionUpdateOne) Exec(ctx context.Context) error
- func (cuo *CollectionUpdateOne) ExecX(ctx context.Context)
- func (cuo *CollectionUpdateOne) Mutation() *CollectionMutation
- func (cuo *CollectionUpdateOne) RemoveBookIDs(ids ...int) *CollectionUpdateOne
- func (cuo *CollectionUpdateOne) RemoveBooks(b ...*Book) *CollectionUpdateOne
- func (cuo *CollectionUpdateOne) Save(ctx context.Context) (*Collection, error)
- func (cuo *CollectionUpdateOne) SaveX(ctx context.Context) *Collection
- func (cuo *CollectionUpdateOne) SetCreatedAt(t time.Time) *CollectionUpdateOne
- func (cuo *CollectionUpdateOne) SetName(s string) *CollectionUpdateOne
- func (cuo *CollectionUpdateOne) SetUpdatedat(t time.Time) *CollectionUpdateOne
- type Collections
- type CommitFunc
- type CommitHook
- type Committer
- type ConstraintError
- type Hook
- type MutateFunc
- type Mutation
- type Mutator
- type NotFoundError
- type NotLoadedError
- type NotSingularError
- type Op
- type Option
- type OrderFunc
- type Policy
- type Query
- type RollbackFunc
- type RollbackHook
- type Rollbacker
- type 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" TypeCollection = "Collection" )
Variables ¶
This section is empty.
Functions ¶
func IsConstraintError ¶
IsConstraintError returns a boolean indicating whether the error is a constraint failure.
func IsNotFound ¶
IsNotFound returns a boolean indicating whether the error is a not found error.
func IsNotLoaded ¶
IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
func IsNotSingular ¶
IsNotSingular returns a boolean indicating whether the error is a not singular error.
func IsValidationError ¶
IsValidationError returns a boolean indicating whether the error is a validaton error.
func NewContext ¶
NewContext returns a new context with the given Client attached.
Types ¶
type AggregateFunc ¶
AggregateFunc applies an aggregation step on the group-by traversal/selector.
func As ¶
func As(fn AggregateFunc, end string) AggregateFunc
As is a pseudo aggregation function for renaming another other functions with custom names. For example:
GroupBy(field1, field2). Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). Scan(ctx, &v)
func Count ¶
func Count() AggregateFunc
Count applies the "count" aggregation function on each group.
func Max ¶
func Max(field string) AggregateFunc
Max applies the "max" aggregation function on the given field of each group.
func Mean ¶
func Mean(field string) AggregateFunc
Mean applies the "mean" aggregation function on the given field of each group.
func Min ¶
func Min(field string) AggregateFunc
Min applies the "min" aggregation function on the given field of each group.
func Sum ¶
func Sum(field string) AggregateFunc
Sum applies the "sum" aggregation function on the given field of each group.
type Book ¶
type Book struct { // ID of the ent. ID int `json:"id,omitempty"` // CreatedAt holds the value of the "createdAt" field. CreatedAt time.Time `json:"createdAt,omitempty"` // Updatedat holds the value of the "updatedat" field. Updatedat time.Time `json:"updatedat,omitempty"` // Author holds the value of the "author" field. Author string `json:"author,omitempty"` // Description holds the value of the "description" field. Description string `json:"description,omitempty"` // Title holds the value of the "title" field. Title string `json:"title,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the BookQuery when eager-loading is set. Edges BookEdges `json:"edges"` // contains filtered or unexported fields }
Book is the model entity for the Book schema.
func (*Book) QueryCollection ¶
func (b *Book) QueryCollection() *CollectionQuery
QueryCollection queries the "collection" edge of the Book entity.
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 create builder for Book.
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 delete builder for the given entity.
func (*BookClient) DeleteOneID ¶
func (c *BookClient) DeleteOneID(id int) *BookDeleteOne
DeleteOneID returns a delete builder for the given id.
func (*BookClient) GetX ¶
func (c *BookClient) GetX(ctx context.Context, id int) *Book
GetX is like Get, but panics if an error occurs.
func (*BookClient) Query ¶
func (c *BookClient) Query() *BookQuery
Query returns a query builder for Book.
func (*BookClient) QueryCollection ¶
func (c *BookClient) QueryCollection(b *Book) *CollectionQuery
QueryCollection queries the collection edge of a 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 int) *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) AddCollection ¶
func (bc *BookCreate) AddCollection(c ...*Collection) *BookCreate
AddCollection adds the "collection" edges to the Collection entity.
func (*BookCreate) AddCollectionIDs ¶
func (bc *BookCreate) AddCollectionIDs(ids ...int) *BookCreate
AddCollectionIDs adds the "collection" edge to the Collection entity by IDs.
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) SetCreatedAt ¶
func (bc *BookCreate) SetCreatedAt(t time.Time) *BookCreate
SetCreatedAt sets the "createdAt" field.
func (*BookCreate) SetDescription ¶
func (bc *BookCreate) SetDescription(s string) *BookCreate
SetDescription sets the "description" field.
func (*BookCreate) SetNillableCreatedAt ¶
func (bc *BookCreate) SetNillableCreatedAt(t *time.Time) *BookCreate
SetNillableCreatedAt sets the "createdAt" field if the given value is not nil.
func (*BookCreate) SetNillableUpdatedat ¶
func (bc *BookCreate) SetNillableUpdatedat(t *time.Time) *BookCreate
SetNillableUpdatedat sets the "updatedat" field if the given value is not nil.
func (*BookCreate) SetTitle ¶
func (bc *BookCreate) SetTitle(s string) *BookCreate
SetTitle sets the "title" field.
func (*BookCreate) SetUpdatedat ¶
func (bc *BookCreate) SetUpdatedat(t time.Time) *BookCreate
SetUpdatedat sets the "updatedat" field.
type BookCreateBulk ¶
type BookCreateBulk struct {
// contains filtered or unexported fields
}
BookCreateBulk is the builder for creating many Book entities in bulk.
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 adds a new predicate 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.
type BookEdges ¶
type BookEdges struct { // Collection holds the value of the collection edge. Collection []*Collection `json:"collection,omitempty"` // contains filtered or unexported fields }
BookEdges holds the relations/edges for other nodes in the graph.
func (BookEdges) CollectionOrErr ¶
func (e BookEdges) CollectionOrErr() ([]*Collection, error)
CollectionOrErr returns the Collection value or an error if the edge was not loaded in eager-loading.
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 ¶
func (bgb *BookGroupBy) 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 (*BookGroupBy) BoolX ¶
func (bgb *BookGroupBy) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*BookGroupBy) Bools ¶
func (bgb *BookGroupBy) 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 (*BookGroupBy) BoolsX ¶
func (bgb *BookGroupBy) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*BookGroupBy) Float64 ¶
func (bgb *BookGroupBy) 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 (*BookGroupBy) Float64X ¶
func (bgb *BookGroupBy) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*BookGroupBy) Float64s ¶
func (bgb *BookGroupBy) 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 (*BookGroupBy) Float64sX ¶
func (bgb *BookGroupBy) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*BookGroupBy) Int ¶
func (bgb *BookGroupBy) 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 (*BookGroupBy) IntX ¶
func (bgb *BookGroupBy) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*BookGroupBy) Ints ¶
func (bgb *BookGroupBy) 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 (*BookGroupBy) IntsX ¶
func (bgb *BookGroupBy) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*BookGroupBy) Scan ¶
func (bgb *BookGroupBy) Scan(ctx context.Context, v interface{}) error
Scan applies the group-by query and scans the result into the given value.
func (*BookGroupBy) ScanX ¶
func (bgb *BookGroupBy) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*BookGroupBy) String ¶
func (bgb *BookGroupBy) 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 (*BookGroupBy) StringX ¶
func (bgb *BookGroupBy) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type BookMutation ¶
type BookMutation struct {
// contains filtered or unexported fields
}
BookMutation represents an operation that mutates the Book nodes in the graph.
func (*BookMutation) AddCollectionIDs ¶
func (m *BookMutation) AddCollectionIDs(ids ...int)
AddCollectionIDs adds the "collection" edge to the Collection entity by ids.
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) ClearCollection ¶
func (m *BookMutation) ClearCollection()
ClearCollection clears the "collection" edge to the Collection entity.
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) CollectionCleared ¶
func (m *BookMutation) CollectionCleared() bool
CollectionCleared returns if the "collection" edge to the Collection entity was cleared.
func (*BookMutation) CollectionIDs ¶
func (m *BookMutation) CollectionIDs() (ids []int)
CollectionIDs returns the "collection" edge IDs in the mutation.
func (*BookMutation) CreatedAt ¶
func (m *BookMutation) CreatedAt() (r time.Time, exists bool)
CreatedAt returns the value of the "createdAt" field in the mutation.
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) 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 int, exists bool)
ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder.
func (*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) OldCreatedAt ¶
OldCreatedAt returns the old "createdAt" 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) 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) 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) OldUpdatedat ¶
OldUpdatedat returns the old "updatedat" 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) RemoveCollectionIDs ¶
func (m *BookMutation) RemoveCollectionIDs(ids ...int)
RemoveCollectionIDs removes the "collection" edge to the Collection entity by IDs.
func (*BookMutation) RemovedCollectionIDs ¶
func (m *BookMutation) RemovedCollectionIDs() (ids []int)
RemovedCollection returns the removed IDs of the "collection" edge to the Collection entity.
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) ResetCollection ¶
func (m *BookMutation) ResetCollection()
ResetCollection resets all changes to the "collection" edge.
func (*BookMutation) ResetCreatedAt ¶
func (m *BookMutation) ResetCreatedAt()
ResetCreatedAt resets all changes to the "createdAt" 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) 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) ResetTitle ¶
func (m *BookMutation) ResetTitle()
ResetTitle resets all changes to the "title" field.
func (*BookMutation) ResetUpdatedat ¶
func (m *BookMutation) ResetUpdatedat()
ResetUpdatedat resets all changes to the "updatedat" field.
func (*BookMutation) SetAuthor ¶
func (m *BookMutation) SetAuthor(s string)
SetAuthor sets the "author" field.
func (*BookMutation) SetCreatedAt ¶
func (m *BookMutation) SetCreatedAt(t time.Time)
SetCreatedAt sets the "createdAt" field.
func (*BookMutation) SetDescription ¶
func (m *BookMutation) SetDescription(s string)
SetDescription sets the "description" 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) SetTitle ¶
func (m *BookMutation) SetTitle(s string)
SetTitle sets the "title" field.
func (*BookMutation) SetUpdatedat ¶
func (m *BookMutation) SetUpdatedat(t time.Time)
SetUpdatedat sets the "updatedat" field.
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).
type BookQuery ¶
type BookQuery struct {
// contains filtered or unexported fields
}
BookQuery is the builder for querying Book entities.
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 { CreatedAt time.Time `json:"createdAt,omitempty"` Count int `json:"count,omitempty"` } client.Book.Query(). GroupBy(book.FieldCreatedAt). 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 exactly one Book entity is not 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 exactly one Book ID is not found. Returns a *NotFoundError when no entities are found.
func (*BookQuery) QueryCollection ¶
func (bq *BookQuery) QueryCollection() *CollectionQuery
QueryCollection chains the current query on the "collection" edge.
func (*BookQuery) Select ¶
func (bq *BookQuery) Select(field string, 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 { CreatedAt time.Time `json:"createdAt,omitempty"` } client.Book.Query(). Select(book.FieldCreatedAt). Scan(ctx, &v)
func (*BookQuery) WithCollection ¶
func (bq *BookQuery) WithCollection(opts ...func(*CollectionQuery)) *BookQuery
WithCollection tells the query-builder to eager-load the nodes that are connected to the "collection" edge. The optional arguments are used to configure the query builder of the edge.
type BookSelect ¶
type BookSelect struct { *BookQuery // contains filtered or unexported fields }
BookSelect is the builder for selecting fields of Book entities.
func (*BookSelect) Bool ¶
func (bs *BookSelect) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*BookSelect) BoolX ¶
func (bs *BookSelect) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*BookSelect) Bools ¶
func (bs *BookSelect) Bools(ctx context.Context) ([]bool, error)
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*BookSelect) BoolsX ¶
func (bs *BookSelect) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*BookSelect) Float64 ¶
func (bs *BookSelect) Float64(ctx context.Context) (_ float64, err error)
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*BookSelect) Float64X ¶
func (bs *BookSelect) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*BookSelect) Float64s ¶
func (bs *BookSelect) Float64s(ctx context.Context) ([]float64, error)
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*BookSelect) Float64sX ¶
func (bs *BookSelect) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*BookSelect) Int ¶
func (bs *BookSelect) Int(ctx context.Context) (_ int, err error)
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*BookSelect) IntX ¶
func (bs *BookSelect) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*BookSelect) Ints ¶
func (bs *BookSelect) Ints(ctx context.Context) ([]int, error)
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*BookSelect) IntsX ¶
func (bs *BookSelect) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*BookSelect) Scan ¶
func (bs *BookSelect) Scan(ctx context.Context, v interface{}) error
Scan applies the selector query and scans the result into the given value.
func (*BookSelect) ScanX ¶
func (bs *BookSelect) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*BookSelect) String ¶
func (bs *BookSelect) String(ctx context.Context) (_ string, err error)
String returns a single string from a selector. It is only allowed when selecting one field.
func (*BookSelect) StringX ¶
func (bs *BookSelect) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type BookUpdate ¶
type BookUpdate struct {
// contains filtered or unexported fields
}
BookUpdate is the builder for updating Book entities.
func (*BookUpdate) AddCollection ¶
func (bu *BookUpdate) AddCollection(c ...*Collection) *BookUpdate
AddCollection adds the "collection" edges to the Collection entity.
func (*BookUpdate) AddCollectionIDs ¶
func (bu *BookUpdate) AddCollectionIDs(ids ...int) *BookUpdate
AddCollectionIDs adds the "collection" edge to the Collection entity by IDs.
func (*BookUpdate) ClearCollection ¶
func (bu *BookUpdate) ClearCollection() *BookUpdate
ClearCollection clears all "collection" edges to the Collection entity.
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) RemoveCollection ¶
func (bu *BookUpdate) RemoveCollection(c ...*Collection) *BookUpdate
RemoveCollection removes "collection" edges to Collection entities.
func (*BookUpdate) RemoveCollectionIDs ¶
func (bu *BookUpdate) RemoveCollectionIDs(ids ...int) *BookUpdate
RemoveCollectionIDs removes the "collection" edge to Collection entities by IDs.
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) SetCreatedAt ¶
func (bu *BookUpdate) SetCreatedAt(t time.Time) *BookUpdate
SetCreatedAt sets the "createdAt" field.
func (*BookUpdate) SetDescription ¶
func (bu *BookUpdate) SetDescription(s string) *BookUpdate
SetDescription sets the "description" field.
func (*BookUpdate) SetTitle ¶
func (bu *BookUpdate) SetTitle(s string) *BookUpdate
SetTitle sets the "title" field.
func (*BookUpdate) SetUpdatedat ¶
func (bu *BookUpdate) SetUpdatedat(t time.Time) *BookUpdate
SetUpdatedat sets the "updatedat" field.
func (*BookUpdate) Where ¶
func (bu *BookUpdate) Where(ps ...predicate.Book) *BookUpdate
Where adds a new predicate for 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) AddCollection ¶
func (buo *BookUpdateOne) AddCollection(c ...*Collection) *BookUpdateOne
AddCollection adds the "collection" edges to the Collection entity.
func (*BookUpdateOne) AddCollectionIDs ¶
func (buo *BookUpdateOne) AddCollectionIDs(ids ...int) *BookUpdateOne
AddCollectionIDs adds the "collection" edge to the Collection entity by IDs.
func (*BookUpdateOne) ClearCollection ¶
func (buo *BookUpdateOne) ClearCollection() *BookUpdateOne
ClearCollection clears all "collection" edges to the Collection 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) RemoveCollection ¶
func (buo *BookUpdateOne) RemoveCollection(c ...*Collection) *BookUpdateOne
RemoveCollection removes "collection" edges to Collection entities.
func (*BookUpdateOne) RemoveCollectionIDs ¶
func (buo *BookUpdateOne) RemoveCollectionIDs(ids ...int) *BookUpdateOne
RemoveCollectionIDs removes the "collection" edge to Collection entities by IDs.
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) SetAuthor ¶
func (buo *BookUpdateOne) SetAuthor(s string) *BookUpdateOne
SetAuthor sets the "author" field.
func (*BookUpdateOne) SetCreatedAt ¶
func (buo *BookUpdateOne) SetCreatedAt(t time.Time) *BookUpdateOne
SetCreatedAt sets the "createdAt" field.
func (*BookUpdateOne) SetDescription ¶
func (buo *BookUpdateOne) SetDescription(s string) *BookUpdateOne
SetDescription sets the "description" field.
func (*BookUpdateOne) SetTitle ¶
func (buo *BookUpdateOne) SetTitle(s string) *BookUpdateOne
SetTitle sets the "title" field.
func (*BookUpdateOne) SetUpdatedat ¶
func (buo *BookUpdateOne) SetUpdatedat(t time.Time) *BookUpdateOne
SetUpdatedat sets the "updatedat" field.
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 // Collection is the client for interacting with the Collection builders. Collection *CollectionClient // 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)
type Collection ¶
type Collection struct { // ID of the ent. ID int `json:"id,omitempty"` // CreatedAt holds the value of the "createdAt" field. CreatedAt time.Time `json:"createdAt,omitempty"` // Updatedat holds the value of the "updatedat" field. Updatedat time.Time `json:"updatedat,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the CollectionQuery when eager-loading is set. Edges CollectionEdges `json:"edges"` // contains filtered or unexported fields }
Collection is the model entity for the Collection schema.
func (*Collection) QueryBooks ¶
func (c *Collection) QueryBooks() *BookQuery
QueryBooks queries the "books" edge of the Collection entity.
func (*Collection) String ¶
func (c *Collection) String() string
String implements the fmt.Stringer.
func (*Collection) Unwrap ¶
func (c *Collection) Unwrap() *Collection
Unwrap unwraps the Collection 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 (*Collection) Update ¶
func (c *Collection) Update() *CollectionUpdateOne
Update returns a builder for updating this Collection. Note that you need to call Collection.Unwrap() before calling this method if this Collection was returned from a transaction, and the transaction was committed or rolled back.
type CollectionClient ¶
type CollectionClient struct {
// contains filtered or unexported fields
}
CollectionClient is a client for the Collection schema.
func NewCollectionClient ¶
func NewCollectionClient(c config) *CollectionClient
NewCollectionClient returns a client for the Collection from the given config.
func (*CollectionClient) Create ¶
func (c *CollectionClient) Create() *CollectionCreate
Create returns a create builder for Collection.
func (*CollectionClient) CreateBulk ¶
func (c *CollectionClient) CreateBulk(builders ...*CollectionCreate) *CollectionCreateBulk
CreateBulk returns a builder for creating a bulk of Collection entities.
func (*CollectionClient) Delete ¶
func (c *CollectionClient) Delete() *CollectionDelete
Delete returns a delete builder for Collection.
func (*CollectionClient) DeleteOne ¶
func (c *CollectionClient) DeleteOne(co *Collection) *CollectionDeleteOne
DeleteOne returns a delete builder for the given entity.
func (*CollectionClient) DeleteOneID ¶
func (c *CollectionClient) DeleteOneID(id int) *CollectionDeleteOne
DeleteOneID returns a delete builder for the given id.
func (*CollectionClient) Get ¶
func (c *CollectionClient) Get(ctx context.Context, id int) (*Collection, error)
Get returns a Collection entity by its id.
func (*CollectionClient) GetX ¶
func (c *CollectionClient) GetX(ctx context.Context, id int) *Collection
GetX is like Get, but panics if an error occurs.
func (*CollectionClient) Hooks ¶
func (c *CollectionClient) Hooks() []Hook
Hooks returns the client hooks.
func (*CollectionClient) Query ¶
func (c *CollectionClient) Query() *CollectionQuery
Query returns a query builder for Collection.
func (*CollectionClient) QueryBooks ¶
func (c *CollectionClient) QueryBooks(co *Collection) *BookQuery
QueryBooks queries the books edge of a Collection.
func (*CollectionClient) Update ¶
func (c *CollectionClient) Update() *CollectionUpdate
Update returns an update builder for Collection.
func (*CollectionClient) UpdateOne ¶
func (c *CollectionClient) UpdateOne(co *Collection) *CollectionUpdateOne
UpdateOne returns an update builder for the given entity.
func (*CollectionClient) UpdateOneID ¶
func (c *CollectionClient) UpdateOneID(id int) *CollectionUpdateOne
UpdateOneID returns an update builder for the given id.
func (*CollectionClient) Use ¶
func (c *CollectionClient) Use(hooks ...Hook)
Use adds a list of mutation hooks to the hooks stack. A call to `Use(f, g, h)` equals to `collection.Hooks(f(g(h())))`.
type CollectionCreate ¶
type CollectionCreate struct {
// contains filtered or unexported fields
}
CollectionCreate is the builder for creating a Collection entity.
func (*CollectionCreate) AddBookIDs ¶
func (cc *CollectionCreate) AddBookIDs(ids ...int) *CollectionCreate
AddBookIDs adds the "books" edge to the Book entity by IDs.
func (*CollectionCreate) AddBooks ¶
func (cc *CollectionCreate) AddBooks(b ...*Book) *CollectionCreate
AddBooks adds the "books" edges to the Book entity.
func (*CollectionCreate) Mutation ¶
func (cc *CollectionCreate) Mutation() *CollectionMutation
Mutation returns the CollectionMutation object of the builder.
func (*CollectionCreate) Save ¶
func (cc *CollectionCreate) Save(ctx context.Context) (*Collection, error)
Save creates the Collection in the database.
func (*CollectionCreate) SaveX ¶
func (cc *CollectionCreate) SaveX(ctx context.Context) *Collection
SaveX calls Save and panics if Save returns an error.
func (*CollectionCreate) SetCreatedAt ¶
func (cc *CollectionCreate) SetCreatedAt(t time.Time) *CollectionCreate
SetCreatedAt sets the "createdAt" field.
func (*CollectionCreate) SetName ¶
func (cc *CollectionCreate) SetName(s string) *CollectionCreate
SetName sets the "name" field.
func (*CollectionCreate) SetNillableCreatedAt ¶
func (cc *CollectionCreate) SetNillableCreatedAt(t *time.Time) *CollectionCreate
SetNillableCreatedAt sets the "createdAt" field if the given value is not nil.
func (*CollectionCreate) SetNillableUpdatedat ¶
func (cc *CollectionCreate) SetNillableUpdatedat(t *time.Time) *CollectionCreate
SetNillableUpdatedat sets the "updatedat" field if the given value is not nil.
func (*CollectionCreate) SetUpdatedat ¶
func (cc *CollectionCreate) SetUpdatedat(t time.Time) *CollectionCreate
SetUpdatedat sets the "updatedat" field.
type CollectionCreateBulk ¶
type CollectionCreateBulk struct {
// contains filtered or unexported fields
}
CollectionCreateBulk is the builder for creating many Collection entities in bulk.
func (*CollectionCreateBulk) Save ¶
func (ccb *CollectionCreateBulk) Save(ctx context.Context) ([]*Collection, error)
Save creates the Collection entities in the database.
func (*CollectionCreateBulk) SaveX ¶
func (ccb *CollectionCreateBulk) SaveX(ctx context.Context) []*Collection
SaveX is like Save, but panics if an error occurs.
type CollectionDelete ¶
type CollectionDelete struct {
// contains filtered or unexported fields
}
CollectionDelete is the builder for deleting a Collection entity.
func (*CollectionDelete) Exec ¶
func (cd *CollectionDelete) Exec(ctx context.Context) (int, error)
Exec executes the deletion query and returns how many vertices were deleted.
func (*CollectionDelete) ExecX ¶
func (cd *CollectionDelete) ExecX(ctx context.Context) int
ExecX is like Exec, but panics if an error occurs.
func (*CollectionDelete) Where ¶
func (cd *CollectionDelete) Where(ps ...predicate.Collection) *CollectionDelete
Where adds a new predicate to the CollectionDelete builder.
type CollectionDeleteOne ¶
type CollectionDeleteOne struct {
// contains filtered or unexported fields
}
CollectionDeleteOne is the builder for deleting a single Collection entity.
func (*CollectionDeleteOne) Exec ¶
func (cdo *CollectionDeleteOne) Exec(ctx context.Context) error
Exec executes the deletion query.
func (*CollectionDeleteOne) ExecX ¶
func (cdo *CollectionDeleteOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
type CollectionEdges ¶
type CollectionEdges struct { // Books holds the value of the books edge. Books []*Book `json:"books,omitempty"` // contains filtered or unexported fields }
CollectionEdges holds the relations/edges for other nodes in the graph.
func (CollectionEdges) BooksOrErr ¶
func (e CollectionEdges) BooksOrErr() ([]*Book, error)
BooksOrErr returns the Books value or an error if the edge was not loaded in eager-loading.
type CollectionGroupBy ¶
type CollectionGroupBy struct {
// contains filtered or unexported fields
}
CollectionGroupBy is the group-by builder for Collection entities.
func (*CollectionGroupBy) Aggregate ¶
func (cgb *CollectionGroupBy) Aggregate(fns ...AggregateFunc) *CollectionGroupBy
Aggregate adds the given aggregation functions to the group-by query.
func (*CollectionGroupBy) Bool ¶
func (cgb *CollectionGroupBy) 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 (*CollectionGroupBy) BoolX ¶
func (cgb *CollectionGroupBy) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*CollectionGroupBy) Bools ¶
func (cgb *CollectionGroupBy) 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 (*CollectionGroupBy) BoolsX ¶
func (cgb *CollectionGroupBy) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*CollectionGroupBy) Float64 ¶
func (cgb *CollectionGroupBy) 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 (*CollectionGroupBy) Float64X ¶
func (cgb *CollectionGroupBy) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*CollectionGroupBy) Float64s ¶
func (cgb *CollectionGroupBy) 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 (*CollectionGroupBy) Float64sX ¶
func (cgb *CollectionGroupBy) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*CollectionGroupBy) Int ¶
func (cgb *CollectionGroupBy) 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 (*CollectionGroupBy) IntX ¶
func (cgb *CollectionGroupBy) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*CollectionGroupBy) Ints ¶
func (cgb *CollectionGroupBy) 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 (*CollectionGroupBy) IntsX ¶
func (cgb *CollectionGroupBy) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*CollectionGroupBy) Scan ¶
func (cgb *CollectionGroupBy) Scan(ctx context.Context, v interface{}) error
Scan applies the group-by query and scans the result into the given value.
func (*CollectionGroupBy) ScanX ¶
func (cgb *CollectionGroupBy) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*CollectionGroupBy) String ¶
func (cgb *CollectionGroupBy) 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 (*CollectionGroupBy) StringX ¶
func (cgb *CollectionGroupBy) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type CollectionMutation ¶
type CollectionMutation struct {
// contains filtered or unexported fields
}
CollectionMutation represents an operation that mutates the Collection nodes in the graph.
func (*CollectionMutation) AddBookIDs ¶
func (m *CollectionMutation) AddBookIDs(ids ...int)
AddBookIDs adds the "books" edge to the Book entity by ids.
func (*CollectionMutation) AddField ¶
func (m *CollectionMutation) 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 (*CollectionMutation) AddedEdges ¶
func (m *CollectionMutation) AddedEdges() []string
AddedEdges returns all edge names that were set/added in this mutation.
func (*CollectionMutation) AddedField ¶
func (m *CollectionMutation) 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 (*CollectionMutation) AddedFields ¶
func (m *CollectionMutation) AddedFields() []string
AddedFields returns all numeric fields that were incremented/decremented during this mutation.
func (*CollectionMutation) AddedIDs ¶
func (m *CollectionMutation) AddedIDs(name string) []ent.Value
AddedIDs returns all IDs (to other nodes) that were added for the given edge name in this mutation.
func (*CollectionMutation) BooksCleared ¶
func (m *CollectionMutation) BooksCleared() bool
BooksCleared returns if the "books" edge to the Book entity was cleared.
func (*CollectionMutation) BooksIDs ¶
func (m *CollectionMutation) BooksIDs() (ids []int)
BooksIDs returns the "books" edge IDs in the mutation.
func (*CollectionMutation) ClearBooks ¶
func (m *CollectionMutation) ClearBooks()
ClearBooks clears the "books" edge to the Book entity.
func (*CollectionMutation) ClearEdge ¶
func (m *CollectionMutation) 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 (*CollectionMutation) ClearField ¶
func (m *CollectionMutation) 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 (*CollectionMutation) ClearedEdges ¶
func (m *CollectionMutation) ClearedEdges() []string
ClearedEdges returns all edge names that were cleared in this mutation.
func (*CollectionMutation) ClearedFields ¶
func (m *CollectionMutation) ClearedFields() []string
ClearedFields returns all nullable fields that were cleared during this mutation.
func (CollectionMutation) Client ¶
func (m CollectionMutation) 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 (*CollectionMutation) CreatedAt ¶
func (m *CollectionMutation) CreatedAt() (r time.Time, exists bool)
CreatedAt returns the value of the "createdAt" field in the mutation.
func (*CollectionMutation) EdgeCleared ¶
func (m *CollectionMutation) EdgeCleared(name string) bool
EdgeCleared returns a boolean which indicates if the edge with the given name was cleared in this mutation.
func (*CollectionMutation) Field ¶
func (m *CollectionMutation) 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 (*CollectionMutation) FieldCleared ¶
func (m *CollectionMutation) FieldCleared(name string) bool
FieldCleared returns a boolean indicating if a field with the given name was cleared in this mutation.
func (*CollectionMutation) Fields ¶
func (m *CollectionMutation) 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 (*CollectionMutation) ID ¶
func (m *CollectionMutation) ID() (id int, exists bool)
ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder.
func (*CollectionMutation) Name ¶
func (m *CollectionMutation) Name() (r string, exists bool)
Name returns the value of the "name" field in the mutation.
func (*CollectionMutation) OldCreatedAt ¶
OldCreatedAt returns the old "createdAt" field's value of the Collection entity. If the Collection 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 (*CollectionMutation) 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 (*CollectionMutation) OldName ¶
func (m *CollectionMutation) OldName(ctx context.Context) (v string, err error)
OldName returns the old "name" field's value of the Collection entity. If the Collection 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 (*CollectionMutation) OldUpdatedat ¶
OldUpdatedat returns the old "updatedat" field's value of the Collection entity. If the Collection 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 (*CollectionMutation) RemoveBookIDs ¶
func (m *CollectionMutation) RemoveBookIDs(ids ...int)
RemoveBookIDs removes the "books" edge to the Book entity by IDs.
func (*CollectionMutation) RemovedBooksIDs ¶
func (m *CollectionMutation) RemovedBooksIDs() (ids []int)
RemovedBooks returns the removed IDs of the "books" edge to the Book entity.
func (*CollectionMutation) RemovedEdges ¶
func (m *CollectionMutation) RemovedEdges() []string
RemovedEdges returns all edge names that were removed in this mutation.
func (*CollectionMutation) RemovedIDs ¶
func (m *CollectionMutation) 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 (*CollectionMutation) ResetBooks ¶
func (m *CollectionMutation) ResetBooks()
ResetBooks resets all changes to the "books" edge.
func (*CollectionMutation) ResetCreatedAt ¶
func (m *CollectionMutation) ResetCreatedAt()
ResetCreatedAt resets all changes to the "createdAt" field.
func (*CollectionMutation) ResetEdge ¶
func (m *CollectionMutation) 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 (*CollectionMutation) ResetField ¶
func (m *CollectionMutation) 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 (*CollectionMutation) ResetName ¶
func (m *CollectionMutation) ResetName()
ResetName resets all changes to the "name" field.
func (*CollectionMutation) ResetUpdatedat ¶
func (m *CollectionMutation) ResetUpdatedat()
ResetUpdatedat resets all changes to the "updatedat" field.
func (*CollectionMutation) SetCreatedAt ¶
func (m *CollectionMutation) SetCreatedAt(t time.Time)
SetCreatedAt sets the "createdAt" field.
func (*CollectionMutation) SetField ¶
func (m *CollectionMutation) 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 (*CollectionMutation) SetName ¶
func (m *CollectionMutation) SetName(s string)
SetName sets the "name" field.
func (*CollectionMutation) SetUpdatedat ¶
func (m *CollectionMutation) SetUpdatedat(t time.Time)
SetUpdatedat sets the "updatedat" field.
func (CollectionMutation) Tx ¶
func (m CollectionMutation) Tx() (*Tx, error)
Tx returns an `ent.Tx` for mutations that were executed in transactions; it returns an error otherwise.
func (*CollectionMutation) Type ¶
func (m *CollectionMutation) Type() string
Type returns the node type of this mutation (Collection).
type CollectionQuery ¶
type CollectionQuery struct {
// contains filtered or unexported fields
}
CollectionQuery is the builder for querying Collection entities.
func (*CollectionQuery) All ¶
func (cq *CollectionQuery) All(ctx context.Context) ([]*Collection, error)
All executes the query and returns a list of Collections.
func (*CollectionQuery) AllX ¶
func (cq *CollectionQuery) AllX(ctx context.Context) []*Collection
AllX is like All, but panics if an error occurs.
func (*CollectionQuery) Clone ¶
func (cq *CollectionQuery) Clone() *CollectionQuery
Clone returns a duplicate of the CollectionQuery builder, including all associated steps. It can be used to prepare common query builders and use them differently after the clone is made.
func (*CollectionQuery) Count ¶
func (cq *CollectionQuery) Count(ctx context.Context) (int, error)
Count returns the count of the given query.
func (*CollectionQuery) CountX ¶
func (cq *CollectionQuery) CountX(ctx context.Context) int
CountX is like Count, but panics if an error occurs.
func (*CollectionQuery) Exist ¶
func (cq *CollectionQuery) Exist(ctx context.Context) (bool, error)
Exist returns true if the query has elements in the graph.
func (*CollectionQuery) ExistX ¶
func (cq *CollectionQuery) ExistX(ctx context.Context) bool
ExistX is like Exist, but panics if an error occurs.
func (*CollectionQuery) First ¶
func (cq *CollectionQuery) First(ctx context.Context) (*Collection, error)
First returns the first Collection entity from the query. Returns a *NotFoundError when no Collection was found.
func (*CollectionQuery) FirstID ¶
func (cq *CollectionQuery) FirstID(ctx context.Context) (id int, err error)
FirstID returns the first Collection ID from the query. Returns a *NotFoundError when no Collection ID was found.
func (*CollectionQuery) FirstIDX ¶
func (cq *CollectionQuery) FirstIDX(ctx context.Context) int
FirstIDX is like FirstID, but panics if an error occurs.
func (*CollectionQuery) FirstX ¶
func (cq *CollectionQuery) FirstX(ctx context.Context) *Collection
FirstX is like First, but panics if an error occurs.
func (*CollectionQuery) GroupBy ¶
func (cq *CollectionQuery) GroupBy(field string, fields ...string) *CollectionGroupBy
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 { CreatedAt time.Time `json:"createdAt,omitempty"` Count int `json:"count,omitempty"` } client.Collection.Query(). GroupBy(collection.FieldCreatedAt). Aggregate(ent.Count()). Scan(ctx, &v)
func (*CollectionQuery) IDs ¶
func (cq *CollectionQuery) IDs(ctx context.Context) ([]int, error)
IDs executes the query and returns a list of Collection IDs.
func (*CollectionQuery) IDsX ¶
func (cq *CollectionQuery) IDsX(ctx context.Context) []int
IDsX is like IDs, but panics if an error occurs.
func (*CollectionQuery) Limit ¶
func (cq *CollectionQuery) Limit(limit int) *CollectionQuery
Limit adds a limit step to the query.
func (*CollectionQuery) Offset ¶
func (cq *CollectionQuery) Offset(offset int) *CollectionQuery
Offset adds an offset step to the query.
func (*CollectionQuery) Only ¶
func (cq *CollectionQuery) Only(ctx context.Context) (*Collection, error)
Only returns a single Collection entity found by the query, ensuring it only returns one. Returns a *NotSingularError when exactly one Collection entity is not found. Returns a *NotFoundError when no Collection entities are found.
func (*CollectionQuery) OnlyID ¶
func (cq *CollectionQuery) OnlyID(ctx context.Context) (id int, err error)
OnlyID is like Only, but returns the only Collection ID in the query. Returns a *NotSingularError when exactly one Collection ID is not found. Returns a *NotFoundError when no entities are found.
func (*CollectionQuery) OnlyIDX ¶
func (cq *CollectionQuery) OnlyIDX(ctx context.Context) int
OnlyIDX is like OnlyID, but panics if an error occurs.
func (*CollectionQuery) OnlyX ¶
func (cq *CollectionQuery) OnlyX(ctx context.Context) *Collection
OnlyX is like Only, but panics if an error occurs.
func (*CollectionQuery) Order ¶
func (cq *CollectionQuery) Order(o ...OrderFunc) *CollectionQuery
Order adds an order step to the query.
func (*CollectionQuery) QueryBooks ¶
func (cq *CollectionQuery) QueryBooks() *BookQuery
QueryBooks chains the current query on the "books" edge.
func (*CollectionQuery) Select ¶
func (cq *CollectionQuery) Select(field string, fields ...string) *CollectionSelect
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 { CreatedAt time.Time `json:"createdAt,omitempty"` } client.Collection.Query(). Select(collection.FieldCreatedAt). Scan(ctx, &v)
func (*CollectionQuery) Where ¶
func (cq *CollectionQuery) Where(ps ...predicate.Collection) *CollectionQuery
Where adds a new predicate for the CollectionQuery builder.
func (*CollectionQuery) WithBooks ¶
func (cq *CollectionQuery) WithBooks(opts ...func(*BookQuery)) *CollectionQuery
WithBooks tells the query-builder to eager-load the nodes that are connected to the "books" edge. The optional arguments are used to configure the query builder of the edge.
type CollectionSelect ¶
type CollectionSelect struct { *CollectionQuery // contains filtered or unexported fields }
CollectionSelect is the builder for selecting fields of Collection entities.
func (*CollectionSelect) Bool ¶
func (cs *CollectionSelect) Bool(ctx context.Context) (_ bool, err error)
Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (*CollectionSelect) BoolX ¶
func (cs *CollectionSelect) BoolX(ctx context.Context) bool
BoolX is like Bool, but panics if an error occurs.
func (*CollectionSelect) Bools ¶
func (cs *CollectionSelect) Bools(ctx context.Context) ([]bool, error)
Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (*CollectionSelect) BoolsX ¶
func (cs *CollectionSelect) BoolsX(ctx context.Context) []bool
BoolsX is like Bools, but panics if an error occurs.
func (*CollectionSelect) Float64 ¶
func (cs *CollectionSelect) Float64(ctx context.Context) (_ float64, err error)
Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (*CollectionSelect) Float64X ¶
func (cs *CollectionSelect) Float64X(ctx context.Context) float64
Float64X is like Float64, but panics if an error occurs.
func (*CollectionSelect) Float64s ¶
func (cs *CollectionSelect) Float64s(ctx context.Context) ([]float64, error)
Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (*CollectionSelect) Float64sX ¶
func (cs *CollectionSelect) Float64sX(ctx context.Context) []float64
Float64sX is like Float64s, but panics if an error occurs.
func (*CollectionSelect) Int ¶
func (cs *CollectionSelect) Int(ctx context.Context) (_ int, err error)
Int returns a single int from a selector. It is only allowed when selecting one field.
func (*CollectionSelect) IntX ¶
func (cs *CollectionSelect) IntX(ctx context.Context) int
IntX is like Int, but panics if an error occurs.
func (*CollectionSelect) Ints ¶
func (cs *CollectionSelect) Ints(ctx context.Context) ([]int, error)
Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (*CollectionSelect) IntsX ¶
func (cs *CollectionSelect) IntsX(ctx context.Context) []int
IntsX is like Ints, but panics if an error occurs.
func (*CollectionSelect) Scan ¶
func (cs *CollectionSelect) Scan(ctx context.Context, v interface{}) error
Scan applies the selector query and scans the result into the given value.
func (*CollectionSelect) ScanX ¶
func (cs *CollectionSelect) ScanX(ctx context.Context, v interface{})
ScanX is like Scan, but panics if an error occurs.
func (*CollectionSelect) String ¶
func (cs *CollectionSelect) String(ctx context.Context) (_ string, err error)
String returns a single string from a selector. It is only allowed when selecting one field.
func (*CollectionSelect) StringX ¶
func (cs *CollectionSelect) StringX(ctx context.Context) string
StringX is like String, but panics if an error occurs.
type CollectionUpdate ¶
type CollectionUpdate struct {
// contains filtered or unexported fields
}
CollectionUpdate is the builder for updating Collection entities.
func (*CollectionUpdate) AddBookIDs ¶
func (cu *CollectionUpdate) AddBookIDs(ids ...int) *CollectionUpdate
AddBookIDs adds the "books" edge to the Book entity by IDs.
func (*CollectionUpdate) AddBooks ¶
func (cu *CollectionUpdate) AddBooks(b ...*Book) *CollectionUpdate
AddBooks adds the "books" edges to the Book entity.
func (*CollectionUpdate) ClearBooks ¶
func (cu *CollectionUpdate) ClearBooks() *CollectionUpdate
ClearBooks clears all "books" edges to the Book entity.
func (*CollectionUpdate) Exec ¶
func (cu *CollectionUpdate) Exec(ctx context.Context) error
Exec executes the query.
func (*CollectionUpdate) ExecX ¶
func (cu *CollectionUpdate) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CollectionUpdate) Mutation ¶
func (cu *CollectionUpdate) Mutation() *CollectionMutation
Mutation returns the CollectionMutation object of the builder.
func (*CollectionUpdate) RemoveBookIDs ¶
func (cu *CollectionUpdate) RemoveBookIDs(ids ...int) *CollectionUpdate
RemoveBookIDs removes the "books" edge to Book entities by IDs.
func (*CollectionUpdate) RemoveBooks ¶
func (cu *CollectionUpdate) RemoveBooks(b ...*Book) *CollectionUpdate
RemoveBooks removes "books" edges to Book entities.
func (*CollectionUpdate) Save ¶
func (cu *CollectionUpdate) Save(ctx context.Context) (int, error)
Save executes the query and returns the number of nodes affected by the update operation.
func (*CollectionUpdate) SaveX ¶
func (cu *CollectionUpdate) SaveX(ctx context.Context) int
SaveX is like Save, but panics if an error occurs.
func (*CollectionUpdate) SetCreatedAt ¶
func (cu *CollectionUpdate) SetCreatedAt(t time.Time) *CollectionUpdate
SetCreatedAt sets the "createdAt" field.
func (*CollectionUpdate) SetName ¶
func (cu *CollectionUpdate) SetName(s string) *CollectionUpdate
SetName sets the "name" field.
func (*CollectionUpdate) SetUpdatedat ¶
func (cu *CollectionUpdate) SetUpdatedat(t time.Time) *CollectionUpdate
SetUpdatedat sets the "updatedat" field.
func (*CollectionUpdate) Where ¶
func (cu *CollectionUpdate) Where(ps ...predicate.Collection) *CollectionUpdate
Where adds a new predicate for the CollectionUpdate builder.
type CollectionUpdateOne ¶
type CollectionUpdateOne struct {
// contains filtered or unexported fields
}
CollectionUpdateOne is the builder for updating a single Collection entity.
func (*CollectionUpdateOne) AddBookIDs ¶
func (cuo *CollectionUpdateOne) AddBookIDs(ids ...int) *CollectionUpdateOne
AddBookIDs adds the "books" edge to the Book entity by IDs.
func (*CollectionUpdateOne) AddBooks ¶
func (cuo *CollectionUpdateOne) AddBooks(b ...*Book) *CollectionUpdateOne
AddBooks adds the "books" edges to the Book entity.
func (*CollectionUpdateOne) ClearBooks ¶
func (cuo *CollectionUpdateOne) ClearBooks() *CollectionUpdateOne
ClearBooks clears all "books" edges to the Book entity.
func (*CollectionUpdateOne) Exec ¶
func (cuo *CollectionUpdateOne) Exec(ctx context.Context) error
Exec executes the query on the entity.
func (*CollectionUpdateOne) ExecX ¶
func (cuo *CollectionUpdateOne) ExecX(ctx context.Context)
ExecX is like Exec, but panics if an error occurs.
func (*CollectionUpdateOne) Mutation ¶
func (cuo *CollectionUpdateOne) Mutation() *CollectionMutation
Mutation returns the CollectionMutation object of the builder.
func (*CollectionUpdateOne) RemoveBookIDs ¶
func (cuo *CollectionUpdateOne) RemoveBookIDs(ids ...int) *CollectionUpdateOne
RemoveBookIDs removes the "books" edge to Book entities by IDs.
func (*CollectionUpdateOne) RemoveBooks ¶
func (cuo *CollectionUpdateOne) RemoveBooks(b ...*Book) *CollectionUpdateOne
RemoveBooks removes "books" edges to Book entities.
func (*CollectionUpdateOne) Save ¶
func (cuo *CollectionUpdateOne) Save(ctx context.Context) (*Collection, error)
Save executes the query and returns the updated Collection entity.
func (*CollectionUpdateOne) SaveX ¶
func (cuo *CollectionUpdateOne) SaveX(ctx context.Context) *Collection
SaveX is like Save, but panics if an error occurs.
func (*CollectionUpdateOne) SetCreatedAt ¶
func (cuo *CollectionUpdateOne) SetCreatedAt(t time.Time) *CollectionUpdateOne
SetCreatedAt sets the "createdAt" field.
func (*CollectionUpdateOne) SetName ¶
func (cuo *CollectionUpdateOne) SetName(s string) *CollectionUpdateOne
SetName sets the "name" field.
func (*CollectionUpdateOne) SetUpdatedat ¶
func (cuo *CollectionUpdateOne) SetUpdatedat(t time.Time) *CollectionUpdateOne
SetUpdatedat sets the "updatedat" field.
type CommitFunc ¶
The CommitFunc type is an adapter to allow the use of ordinary function as a Committer. If f is a function with the appropriate signature, CommitFunc(f) is a Committer that calls f.
type CommitHook ¶
CommitHook defines the "commit middleware". A function that gets a Committer and returns a Committer. For example:
hook := func(next ent.Committer) ent.Committer { return ent.CommitFunc(func(context.Context, tx *ent.Tx) error { // Do some stuff before. if err := next.Commit(ctx, tx); err != nil { return err } // Do some stuff after. return nil }) }
type ConstraintError ¶
type ConstraintError struct {
// contains filtered or unexported fields
}
ConstraintError returns when trying to create/update one or more entities and one or more of their constraints failed. For example, violation of edge or field uniqueness.
func (ConstraintError) Error ¶
func (e ConstraintError) Error() string
Error implements the error interface.
func (*ConstraintError) Unwrap ¶
func (e *ConstraintError) Unwrap() error
Unwrap implements the errors.Wrapper interface.
type MutateFunc ¶
type MutateFunc = ent.MutateFunc
ent aliases to avoid import 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 RollbackFunc ¶
The RollbackFunc type is an adapter to allow the use of ordinary function as a Rollbacker. If f is a function with the appropriate signature, RollbackFunc(f) is a Rollbacker that calls f.
type RollbackHook ¶
type RollbackHook func(Rollbacker) Rollbacker
RollbackHook defines the "rollback middleware". A function that gets a Rollbacker and returns a Rollbacker. For example:
hook := func(next ent.Rollbacker) ent.Rollbacker { return ent.RollbackFunc(func(context.Context, tx *ent.Tx) error { // Do some stuff before. if err := next.Rollback(ctx, tx); err != nil { return err } // Do some stuff after. return nil }) }
type Rollbacker ¶
Rollbacker is the interface that wraps the Rollbacker method.
type Tx ¶
type Tx struct { // Book is the client for interacting with the Book builders. Book *BookClient // Collection is the client for interacting with the Collection builders. Collection *CollectionClient // 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 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.