ent

package
v0.0.0-...-397b8aa Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Operation types.
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne

	// Node types.
	TypeBook     = "Book"
	TypeBookLoan = "BookLoan"
	TypeUser     = "User"
)

Variables

This section is empty.

Functions

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func IsValidationError

func IsValidationError(err error) bool

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

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

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

NewContext returns a new context with the given Client attached.

func NewTxContext

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

NewTxContext returns a new context with the given Tx attached.

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

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

func As

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

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

func Count

func Count() AggregateFunc

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

func Max

func Max(field string) AggregateFunc

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

func Mean

func Mean(field string) AggregateFunc

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

func Min

func Min(field string) AggregateFunc

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

func Sum

func Sum(field string) AggregateFunc

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

type Book

type Book struct {

	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// CreateAt holds the value of the "create_at" field.
	CreateAt time.Time `json:"create_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// Title holds the value of the "title" field.
	Title string `json:"title,omitempty"`
	// Pages holds the value of the "pages" field.
	Pages uint16 `json:"pages,omitempty"`
	// Abstract holds the value of the "abstract" field.
	Abstract string `json:"abstract,omitempty"`
	// Category holds the value of the "category" field.
	Category book.Category `json:"category,omitempty"`
	// CoverURL holds the value of the "cover_url" field.
	CoverURL string `json:"cover_url,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) QueryAuthor

func (b *Book) QueryAuthor() *UserQuery

QueryAuthor queries the "author" edge of the Book entity.

func (*Book) QueryOnLoans

func (b *Book) QueryOnLoans() *BookLoanQuery

QueryOnLoans queries the "on_loans" edge of the Book entity.

func (*Book) String

func (b *Book) String() string

String implements the fmt.Stringer.

func (*Book) Unwrap

func (b *Book) Unwrap() *Book

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 uuid.UUID) *BookDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*BookClient) Get

func (c *BookClient) Get(ctx context.Context, id uuid.UUID) (*Book, error)

Get returns a Book entity by its id.

func (*BookClient) GetX

func (c *BookClient) GetX(ctx context.Context, id uuid.UUID) *Book

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

func (*BookClient) Hooks

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

Hooks returns the client hooks.

func (*BookClient) Query

func (c *BookClient) Query() *BookQuery

Query returns a query builder for Book.

func (*BookClient) QueryAuthor

func (c *BookClient) QueryAuthor(b *Book) *UserQuery

QueryAuthor queries the author edge of a Book.

func (*BookClient) QueryOnLoans

func (c *BookClient) QueryOnLoans(b *Book) *BookLoanQuery

QueryOnLoans queries the on_loans 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 uuid.UUID) *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) AddOnLoanIDs

func (bc *BookCreate) AddOnLoanIDs(ids ...uuid.UUID) *BookCreate

AddOnLoanIDs adds the "on_loans" edge to the BookLoan entity by IDs.

func (*BookCreate) AddOnLoans

func (bc *BookCreate) AddOnLoans(b ...*BookLoan) *BookCreate

AddOnLoans adds the "on_loans" edges to the BookLoan 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) SetAbstract

func (bc *BookCreate) SetAbstract(s string) *BookCreate

SetAbstract sets the "abstract" field.

func (*BookCreate) SetAuthor

func (bc *BookCreate) SetAuthor(u *User) *BookCreate

SetAuthor sets the "author" edge to the User entity.

func (*BookCreate) SetAuthorID

func (bc *BookCreate) SetAuthorID(id uuid.UUID) *BookCreate

SetAuthorID sets the "author" edge to the User entity by ID.

func (*BookCreate) SetCategory

func (bc *BookCreate) SetCategory(b book.Category) *BookCreate

SetCategory sets the "category" field.

func (*BookCreate) SetCoverURL

func (bc *BookCreate) SetCoverURL(s string) *BookCreate

SetCoverURL sets the "cover_url" field.

func (*BookCreate) SetCreateAt

func (bc *BookCreate) SetCreateAt(t time.Time) *BookCreate

SetCreateAt sets the "create_at" field.

func (*BookCreate) SetID

func (bc *BookCreate) SetID(u uuid.UUID) *BookCreate

SetID sets the "id" field.

func (*BookCreate) SetNillableAbstract

func (bc *BookCreate) SetNillableAbstract(s *string) *BookCreate

SetNillableAbstract sets the "abstract" field if the given value is not nil.

func (*BookCreate) SetNillableCreateAt

func (bc *BookCreate) SetNillableCreateAt(t *time.Time) *BookCreate

SetNillableCreateAt sets the "create_at" field if the given value is not nil.

func (*BookCreate) SetNillableID

func (bc *BookCreate) SetNillableID(u *uuid.UUID) *BookCreate

SetNillableID sets the "id" field if the given value is not nil.

func (*BookCreate) SetNillableUpdatedAt

func (bc *BookCreate) SetNillableUpdatedAt(t *time.Time) *BookCreate

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (*BookCreate) SetPages

func (bc *BookCreate) SetPages(u uint16) *BookCreate

SetPages sets the "pages" field.

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 "updated_at" 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.

func (*BookCreateBulk) Save

func (bcb *BookCreateBulk) Save(ctx context.Context) ([]*Book, error)

Save creates the Book entities in the database.

func (*BookCreateBulk) SaveX

func (bcb *BookCreateBulk) SaveX(ctx context.Context) []*Book

SaveX is like Save, 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.

type BookEdges

type BookEdges struct {
	// OnLoans holds the value of the on_loans edge.
	OnLoans []*BookLoan `json:"on_loans,omitempty"`
	// Author holds the value of the author edge.
	Author *User `json:"author,omitempty"`
	// contains filtered or unexported fields
}

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

func (BookEdges) AuthorOrErr

func (e BookEdges) AuthorOrErr() (*User, error)

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

func (BookEdges) OnLoansOrErr

func (e BookEdges) OnLoansOrErr() ([]*BookLoan, error)

OnLoansOrErr returns the OnLoans 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.

func (*BookGroupBy) Strings

func (bgb *BookGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*BookGroupBy) StringsX

func (bgb *BookGroupBy) StringsX(ctx context.Context) []string

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

type BookLoan

type BookLoan struct {

	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// CreateAt holds the value of the "create_at" field.
	CreateAt time.Time `json:"create_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// LoanDate holds the value of the "loan_date" field.
	LoanDate time.Time `json:"loan_date,omitempty"`
	// DeliveryDate holds the value of the "delivery_date" field.
	DeliveryDate time.Time `json:"delivery_date,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the BookLoanQuery when eager-loading is set.
	Edges BookLoanEdges `json:"edges"`
	// contains filtered or unexported fields
}

BookLoan is the model entity for the BookLoan schema.

func (*BookLoan) QueryBook

func (bl *BookLoan) QueryBook() *BookQuery

QueryBook queries the "book" edge of the BookLoan entity.

func (*BookLoan) QueryUser

func (bl *BookLoan) QueryUser() *UserQuery

QueryUser queries the "user" edge of the BookLoan entity.

func (*BookLoan) String

func (bl *BookLoan) String() string

String implements the fmt.Stringer.

func (*BookLoan) Unwrap

func (bl *BookLoan) Unwrap() *BookLoan

Unwrap unwraps the BookLoan 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 (*BookLoan) Update

func (bl *BookLoan) Update() *BookLoanUpdateOne

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

type BookLoanClient

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

BookLoanClient is a client for the BookLoan schema.

func NewBookLoanClient

func NewBookLoanClient(c config) *BookLoanClient

NewBookLoanClient returns a client for the BookLoan from the given config.

func (*BookLoanClient) Create

func (c *BookLoanClient) Create() *BookLoanCreate

Create returns a create builder for BookLoan.

func (*BookLoanClient) CreateBulk

func (c *BookLoanClient) CreateBulk(builders ...*BookLoanCreate) *BookLoanCreateBulk

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

func (*BookLoanClient) Delete

func (c *BookLoanClient) Delete() *BookLoanDelete

Delete returns a delete builder for BookLoan.

func (*BookLoanClient) DeleteOne

func (c *BookLoanClient) DeleteOne(bl *BookLoan) *BookLoanDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*BookLoanClient) DeleteOneID

func (c *BookLoanClient) DeleteOneID(id uuid.UUID) *BookLoanDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*BookLoanClient) Get

func (c *BookLoanClient) Get(ctx context.Context, id uuid.UUID) (*BookLoan, error)

Get returns a BookLoan entity by its id.

func (*BookLoanClient) GetX

func (c *BookLoanClient) GetX(ctx context.Context, id uuid.UUID) *BookLoan

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

func (*BookLoanClient) Hooks

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

Hooks returns the client hooks.

func (*BookLoanClient) Query

func (c *BookLoanClient) Query() *BookLoanQuery

Query returns a query builder for BookLoan.

func (*BookLoanClient) QueryBook

func (c *BookLoanClient) QueryBook(bl *BookLoan) *BookQuery

QueryBook queries the book edge of a BookLoan.

func (*BookLoanClient) QueryUser

func (c *BookLoanClient) QueryUser(bl *BookLoan) *UserQuery

QueryUser queries the user edge of a BookLoan.

func (*BookLoanClient) Update

func (c *BookLoanClient) Update() *BookLoanUpdate

Update returns an update builder for BookLoan.

func (*BookLoanClient) UpdateOne

func (c *BookLoanClient) UpdateOne(bl *BookLoan) *BookLoanUpdateOne

UpdateOne returns an update builder for the given entity.

func (*BookLoanClient) UpdateOneID

func (c *BookLoanClient) UpdateOneID(id uuid.UUID) *BookLoanUpdateOne

UpdateOneID returns an update builder for the given id.

func (*BookLoanClient) Use

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

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

type BookLoanCreate

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

BookLoanCreate is the builder for creating a BookLoan entity.

func (*BookLoanCreate) Exec

func (blc *BookLoanCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*BookLoanCreate) ExecX

func (blc *BookLoanCreate) ExecX(ctx context.Context)

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

func (*BookLoanCreate) Mutation

func (blc *BookLoanCreate) Mutation() *BookLoanMutation

Mutation returns the BookLoanMutation object of the builder.

func (*BookLoanCreate) Save

func (blc *BookLoanCreate) Save(ctx context.Context) (*BookLoan, error)

Save creates the BookLoan in the database.

func (*BookLoanCreate) SaveX

func (blc *BookLoanCreate) SaveX(ctx context.Context) *BookLoan

SaveX calls Save and panics if Save returns an error.

func (*BookLoanCreate) SetBook

func (blc *BookLoanCreate) SetBook(b *Book) *BookLoanCreate

SetBook sets the "book" edge to the Book entity.

func (*BookLoanCreate) SetBookID

func (blc *BookLoanCreate) SetBookID(id uuid.UUID) *BookLoanCreate

SetBookID sets the "book" edge to the Book entity by ID.

func (*BookLoanCreate) SetCreateAt

func (blc *BookLoanCreate) SetCreateAt(t time.Time) *BookLoanCreate

SetCreateAt sets the "create_at" field.

func (*BookLoanCreate) SetDeliveryDate

func (blc *BookLoanCreate) SetDeliveryDate(t time.Time) *BookLoanCreate

SetDeliveryDate sets the "delivery_date" field.

func (*BookLoanCreate) SetID

func (blc *BookLoanCreate) SetID(u uuid.UUID) *BookLoanCreate

SetID sets the "id" field.

func (*BookLoanCreate) SetLoanDate

func (blc *BookLoanCreate) SetLoanDate(t time.Time) *BookLoanCreate

SetLoanDate sets the "loan_date" field.

func (*BookLoanCreate) SetNillableCreateAt

func (blc *BookLoanCreate) SetNillableCreateAt(t *time.Time) *BookLoanCreate

SetNillableCreateAt sets the "create_at" field if the given value is not nil.

func (*BookLoanCreate) SetNillableDeliveryDate

func (blc *BookLoanCreate) SetNillableDeliveryDate(t *time.Time) *BookLoanCreate

SetNillableDeliveryDate sets the "delivery_date" field if the given value is not nil.

func (*BookLoanCreate) SetNillableID

func (blc *BookLoanCreate) SetNillableID(u *uuid.UUID) *BookLoanCreate

SetNillableID sets the "id" field if the given value is not nil.

func (*BookLoanCreate) SetNillableLoanDate

func (blc *BookLoanCreate) SetNillableLoanDate(t *time.Time) *BookLoanCreate

SetNillableLoanDate sets the "loan_date" field if the given value is not nil.

func (*BookLoanCreate) SetNillableUpdatedAt

func (blc *BookLoanCreate) SetNillableUpdatedAt(t *time.Time) *BookLoanCreate

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (*BookLoanCreate) SetUpdatedAt

func (blc *BookLoanCreate) SetUpdatedAt(t time.Time) *BookLoanCreate

SetUpdatedAt sets the "updated_at" field.

func (*BookLoanCreate) SetUser

func (blc *BookLoanCreate) SetUser(u *User) *BookLoanCreate

SetUser sets the "user" edge to the User entity.

func (*BookLoanCreate) SetUserID

func (blc *BookLoanCreate) SetUserID(id uuid.UUID) *BookLoanCreate

SetUserID sets the "user" edge to the User entity by ID.

type BookLoanCreateBulk

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

BookLoanCreateBulk is the builder for creating many BookLoan entities in bulk.

func (*BookLoanCreateBulk) Exec

func (blcb *BookLoanCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*BookLoanCreateBulk) ExecX

func (blcb *BookLoanCreateBulk) ExecX(ctx context.Context)

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

func (*BookLoanCreateBulk) Save

func (blcb *BookLoanCreateBulk) Save(ctx context.Context) ([]*BookLoan, error)

Save creates the BookLoan entities in the database.

func (*BookLoanCreateBulk) SaveX

func (blcb *BookLoanCreateBulk) SaveX(ctx context.Context) []*BookLoan

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

type BookLoanDelete

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

BookLoanDelete is the builder for deleting a BookLoan entity.

func (*BookLoanDelete) Exec

func (bld *BookLoanDelete) Exec(ctx context.Context) (int, error)

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

func (*BookLoanDelete) ExecX

func (bld *BookLoanDelete) ExecX(ctx context.Context) int

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

func (*BookLoanDelete) Where

func (bld *BookLoanDelete) Where(ps ...predicate.BookLoan) *BookLoanDelete

Where appends a list predicates to the BookLoanDelete builder.

type BookLoanDeleteOne

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

BookLoanDeleteOne is the builder for deleting a single BookLoan entity.

func (*BookLoanDeleteOne) Exec

func (bldo *BookLoanDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*BookLoanDeleteOne) ExecX

func (bldo *BookLoanDeleteOne) ExecX(ctx context.Context)

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

type BookLoanEdges

type BookLoanEdges struct {
	// User holds the value of the user edge.
	User *User `json:"user,omitempty"`
	// Book holds the value of the book edge.
	Book *Book `json:"book,omitempty"`
	// contains filtered or unexported fields
}

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

func (BookLoanEdges) BookOrErr

func (e BookLoanEdges) BookOrErr() (*Book, error)

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

func (BookLoanEdges) UserOrErr

func (e BookLoanEdges) UserOrErr() (*User, error)

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

type BookLoanGroupBy

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

BookLoanGroupBy is the group-by builder for BookLoan entities.

func (*BookLoanGroupBy) Aggregate

func (blgb *BookLoanGroupBy) Aggregate(fns ...AggregateFunc) *BookLoanGroupBy

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

func (*BookLoanGroupBy) Bool

func (blgb *BookLoanGroupBy) 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 (*BookLoanGroupBy) BoolX

func (blgb *BookLoanGroupBy) BoolX(ctx context.Context) bool

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

func (*BookLoanGroupBy) Bools

func (blgb *BookLoanGroupBy) 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 (*BookLoanGroupBy) BoolsX

func (blgb *BookLoanGroupBy) BoolsX(ctx context.Context) []bool

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

func (*BookLoanGroupBy) Float64

func (blgb *BookLoanGroupBy) 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 (*BookLoanGroupBy) Float64X

func (blgb *BookLoanGroupBy) Float64X(ctx context.Context) float64

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

func (*BookLoanGroupBy) Float64s

func (blgb *BookLoanGroupBy) 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 (*BookLoanGroupBy) Float64sX

func (blgb *BookLoanGroupBy) Float64sX(ctx context.Context) []float64

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

func (*BookLoanGroupBy) Int

func (blgb *BookLoanGroupBy) 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 (*BookLoanGroupBy) IntX

func (blgb *BookLoanGroupBy) IntX(ctx context.Context) int

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

func (*BookLoanGroupBy) Ints

func (blgb *BookLoanGroupBy) 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 (*BookLoanGroupBy) IntsX

func (blgb *BookLoanGroupBy) IntsX(ctx context.Context) []int

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

func (*BookLoanGroupBy) Scan

func (blgb *BookLoanGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*BookLoanGroupBy) ScanX

func (blgb *BookLoanGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*BookLoanGroupBy) String

func (blgb *BookLoanGroupBy) 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 (*BookLoanGroupBy) StringX

func (blgb *BookLoanGroupBy) StringX(ctx context.Context) string

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

func (*BookLoanGroupBy) Strings

func (blgb *BookLoanGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*BookLoanGroupBy) StringsX

func (blgb *BookLoanGroupBy) StringsX(ctx context.Context) []string

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

type BookLoanMutation

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

BookLoanMutation represents an operation that mutates the BookLoan nodes in the graph.

func (*BookLoanMutation) AddField

func (m *BookLoanMutation) 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 (*BookLoanMutation) AddedEdges

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

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

func (*BookLoanMutation) AddedField

func (m *BookLoanMutation) 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 (*BookLoanMutation) AddedFields

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

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

func (*BookLoanMutation) AddedIDs

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

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

func (*BookLoanMutation) BookCleared

func (m *BookLoanMutation) BookCleared() bool

BookCleared reports if the "book" edge to the Book entity was cleared.

func (*BookLoanMutation) BookID

func (m *BookLoanMutation) BookID() (id uuid.UUID, exists bool)

BookID returns the "book" edge ID in the mutation.

func (*BookLoanMutation) BookIDs

func (m *BookLoanMutation) BookIDs() (ids []uuid.UUID)

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

func (*BookLoanMutation) ClearBook

func (m *BookLoanMutation) ClearBook()

ClearBook clears the "book" edge to the Book entity.

func (*BookLoanMutation) ClearEdge

func (m *BookLoanMutation) 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 (*BookLoanMutation) ClearField

func (m *BookLoanMutation) 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 (*BookLoanMutation) ClearUser

func (m *BookLoanMutation) ClearUser()

ClearUser clears the "user" edge to the User entity.

func (*BookLoanMutation) ClearedEdges

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

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

func (*BookLoanMutation) ClearedFields

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

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

func (BookLoanMutation) Client

func (m BookLoanMutation) 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 (*BookLoanMutation) CreateAt

func (m *BookLoanMutation) CreateAt() (r time.Time, exists bool)

CreateAt returns the value of the "create_at" field in the mutation.

func (*BookLoanMutation) DeliveryDate

func (m *BookLoanMutation) DeliveryDate() (r time.Time, exists bool)

DeliveryDate returns the value of the "delivery_date" field in the mutation.

func (*BookLoanMutation) EdgeCleared

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

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

func (*BookLoanMutation) Field

func (m *BookLoanMutation) 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 (*BookLoanMutation) FieldCleared

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

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

func (*BookLoanMutation) Fields

func (m *BookLoanMutation) 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 (*BookLoanMutation) ID

func (m *BookLoanMutation) ID() (id uuid.UUID, 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 (*BookLoanMutation) IDs

func (m *BookLoanMutation) IDs(ctx context.Context) ([]uuid.UUID, 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 (*BookLoanMutation) LoanDate

func (m *BookLoanMutation) LoanDate() (r time.Time, exists bool)

LoanDate returns the value of the "loan_date" field in the mutation.

func (*BookLoanMutation) OldCreateAt

func (m *BookLoanMutation) OldCreateAt(ctx context.Context) (v time.Time, err error)

OldCreateAt returns the old "create_at" field's value of the BookLoan entity. If the BookLoan 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 (*BookLoanMutation) OldDeliveryDate

func (m *BookLoanMutation) OldDeliveryDate(ctx context.Context) (v time.Time, err error)

OldDeliveryDate returns the old "delivery_date" field's value of the BookLoan entity. If the BookLoan 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 (*BookLoanMutation) OldField

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

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

func (*BookLoanMutation) OldLoanDate

func (m *BookLoanMutation) OldLoanDate(ctx context.Context) (v time.Time, err error)

OldLoanDate returns the old "loan_date" field's value of the BookLoan entity. If the BookLoan 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 (*BookLoanMutation) OldUpdatedAt

func (m *BookLoanMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error)

OldUpdatedAt returns the old "updated_at" field's value of the BookLoan entity. If the BookLoan 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 (*BookLoanMutation) Op

func (m *BookLoanMutation) Op() Op

Op returns the operation name.

func (*BookLoanMutation) RemovedEdges

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

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

func (*BookLoanMutation) RemovedIDs

func (m *BookLoanMutation) 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 (*BookLoanMutation) ResetBook

func (m *BookLoanMutation) ResetBook()

ResetBook resets all changes to the "book" edge.

func (*BookLoanMutation) ResetCreateAt

func (m *BookLoanMutation) ResetCreateAt()

ResetCreateAt resets all changes to the "create_at" field.

func (*BookLoanMutation) ResetDeliveryDate

func (m *BookLoanMutation) ResetDeliveryDate()

ResetDeliveryDate resets all changes to the "delivery_date" field.

func (*BookLoanMutation) ResetEdge

func (m *BookLoanMutation) 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 (*BookLoanMutation) ResetField

func (m *BookLoanMutation) 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 (*BookLoanMutation) ResetLoanDate

func (m *BookLoanMutation) ResetLoanDate()

ResetLoanDate resets all changes to the "loan_date" field.

func (*BookLoanMutation) ResetUpdatedAt

func (m *BookLoanMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*BookLoanMutation) ResetUser

func (m *BookLoanMutation) ResetUser()

ResetUser resets all changes to the "user" edge.

func (*BookLoanMutation) SetBookID

func (m *BookLoanMutation) SetBookID(id uuid.UUID)

SetBookID sets the "book" edge to the Book entity by id.

func (*BookLoanMutation) SetCreateAt

func (m *BookLoanMutation) SetCreateAt(t time.Time)

SetCreateAt sets the "create_at" field.

func (*BookLoanMutation) SetDeliveryDate

func (m *BookLoanMutation) SetDeliveryDate(t time.Time)

SetDeliveryDate sets the "delivery_date" field.

func (*BookLoanMutation) SetField

func (m *BookLoanMutation) 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 (*BookLoanMutation) SetID

func (m *BookLoanMutation) SetID(id uuid.UUID)

SetID sets the value of the id field. Note that this operation is only accepted on creation of BookLoan entities.

func (*BookLoanMutation) SetLoanDate

func (m *BookLoanMutation) SetLoanDate(t time.Time)

SetLoanDate sets the "loan_date" field.

func (*BookLoanMutation) SetUpdatedAt

func (m *BookLoanMutation) SetUpdatedAt(t time.Time)

SetUpdatedAt sets the "updated_at" field.

func (*BookLoanMutation) SetUserID

func (m *BookLoanMutation) SetUserID(id uuid.UUID)

SetUserID sets the "user" edge to the User entity by id.

func (BookLoanMutation) Tx

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

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

func (*BookLoanMutation) Type

func (m *BookLoanMutation) Type() string

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

func (*BookLoanMutation) UpdatedAt

func (m *BookLoanMutation) UpdatedAt() (r time.Time, exists bool)

UpdatedAt returns the value of the "updated_at" field in the mutation.

func (*BookLoanMutation) UserCleared

func (m *BookLoanMutation) UserCleared() bool

UserCleared reports if the "user" edge to the User entity was cleared.

func (*BookLoanMutation) UserID

func (m *BookLoanMutation) UserID() (id uuid.UUID, exists bool)

UserID returns the "user" edge ID in the mutation.

func (*BookLoanMutation) UserIDs

func (m *BookLoanMutation) UserIDs() (ids []uuid.UUID)

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

func (*BookLoanMutation) Where

func (m *BookLoanMutation) Where(ps ...predicate.BookLoan)

Where appends a list predicates to the BookLoanMutation builder.

type BookLoanQuery

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

BookLoanQuery is the builder for querying BookLoan entities.

func (*BookLoanQuery) All

func (blq *BookLoanQuery) All(ctx context.Context) ([]*BookLoan, error)

All executes the query and returns a list of BookLoans.

func (*BookLoanQuery) AllX

func (blq *BookLoanQuery) AllX(ctx context.Context) []*BookLoan

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

func (*BookLoanQuery) Clone

func (blq *BookLoanQuery) Clone() *BookLoanQuery

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

func (*BookLoanQuery) Count

func (blq *BookLoanQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*BookLoanQuery) CountX

func (blq *BookLoanQuery) CountX(ctx context.Context) int

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

func (*BookLoanQuery) Exist

func (blq *BookLoanQuery) Exist(ctx context.Context) (bool, error)

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

func (*BookLoanQuery) ExistX

func (blq *BookLoanQuery) ExistX(ctx context.Context) bool

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

func (*BookLoanQuery) First

func (blq *BookLoanQuery) First(ctx context.Context) (*BookLoan, error)

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

func (*BookLoanQuery) FirstID

func (blq *BookLoanQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)

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

func (*BookLoanQuery) FirstIDX

func (blq *BookLoanQuery) FirstIDX(ctx context.Context) uuid.UUID

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

func (*BookLoanQuery) FirstX

func (blq *BookLoanQuery) FirstX(ctx context.Context) *BookLoan

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

func (*BookLoanQuery) GroupBy

func (blq *BookLoanQuery) GroupBy(field string, fields ...string) *BookLoanGroupBy

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 {
	CreateAt time.Time `json:"create_at,omitempty"`
	Count int `json:"count,omitempty"`
}

client.BookLoan.Query().
	GroupBy(bookloan.FieldCreateAt).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*BookLoanQuery) IDs

func (blq *BookLoanQuery) IDs(ctx context.Context) ([]uuid.UUID, error)

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

func (*BookLoanQuery) IDsX

func (blq *BookLoanQuery) IDsX(ctx context.Context) []uuid.UUID

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

func (*BookLoanQuery) Limit

func (blq *BookLoanQuery) Limit(limit int) *BookLoanQuery

Limit adds a limit step to the query.

func (*BookLoanQuery) Offset

func (blq *BookLoanQuery) Offset(offset int) *BookLoanQuery

Offset adds an offset step to the query.

func (*BookLoanQuery) Only

func (blq *BookLoanQuery) Only(ctx context.Context) (*BookLoan, error)

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

func (*BookLoanQuery) OnlyID

func (blq *BookLoanQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)

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

func (*BookLoanQuery) OnlyIDX

func (blq *BookLoanQuery) OnlyIDX(ctx context.Context) uuid.UUID

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

func (*BookLoanQuery) OnlyX

func (blq *BookLoanQuery) OnlyX(ctx context.Context) *BookLoan

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

func (*BookLoanQuery) Order

func (blq *BookLoanQuery) Order(o ...OrderFunc) *BookLoanQuery

Order adds an order step to the query.

func (*BookLoanQuery) QueryBook

func (blq *BookLoanQuery) QueryBook() *BookQuery

QueryBook chains the current query on the "book" edge.

func (*BookLoanQuery) QueryUser

func (blq *BookLoanQuery) QueryUser() *UserQuery

QueryUser chains the current query on the "user" edge.

func (*BookLoanQuery) Select

func (blq *BookLoanQuery) Select(fields ...string) *BookLoanSelect

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 {
	CreateAt time.Time `json:"create_at,omitempty"`
}

client.BookLoan.Query().
	Select(bookloan.FieldCreateAt).
	Scan(ctx, &v)

func (*BookLoanQuery) Unique

func (blq *BookLoanQuery) Unique(unique bool) *BookLoanQuery

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

func (*BookLoanQuery) Where

func (blq *BookLoanQuery) Where(ps ...predicate.BookLoan) *BookLoanQuery

Where adds a new predicate for the BookLoanQuery builder.

func (*BookLoanQuery) WithBook

func (blq *BookLoanQuery) WithBook(opts ...func(*BookQuery)) *BookLoanQuery

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

func (*BookLoanQuery) WithUser

func (blq *BookLoanQuery) WithUser(opts ...func(*UserQuery)) *BookLoanQuery

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

type BookLoanSelect

type BookLoanSelect struct {
	*BookLoanQuery
	// contains filtered or unexported fields
}

BookLoanSelect is the builder for selecting fields of BookLoan entities.

func (*BookLoanSelect) Bool

func (bls *BookLoanSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*BookLoanSelect) BoolX

func (bls *BookLoanSelect) BoolX(ctx context.Context) bool

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

func (*BookLoanSelect) Bools

func (bls *BookLoanSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*BookLoanSelect) BoolsX

func (bls *BookLoanSelect) BoolsX(ctx context.Context) []bool

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

func (*BookLoanSelect) Float64

func (bls *BookLoanSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*BookLoanSelect) Float64X

func (bls *BookLoanSelect) Float64X(ctx context.Context) float64

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

func (*BookLoanSelect) Float64s

func (bls *BookLoanSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*BookLoanSelect) Float64sX

func (bls *BookLoanSelect) Float64sX(ctx context.Context) []float64

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

func (*BookLoanSelect) Int

func (bls *BookLoanSelect) Int(ctx context.Context) (_ int, err error)

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

func (*BookLoanSelect) IntX

func (bls *BookLoanSelect) IntX(ctx context.Context) int

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

func (*BookLoanSelect) Ints

func (bls *BookLoanSelect) Ints(ctx context.Context) ([]int, error)

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

func (*BookLoanSelect) IntsX

func (bls *BookLoanSelect) IntsX(ctx context.Context) []int

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

func (*BookLoanSelect) Scan

func (bls *BookLoanSelect) Scan(ctx context.Context, v interface{}) error

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

func (*BookLoanSelect) ScanX

func (bls *BookLoanSelect) ScanX(ctx context.Context, v interface{})

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

func (*BookLoanSelect) String

func (bls *BookLoanSelect) String(ctx context.Context) (_ string, err error)

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

func (*BookLoanSelect) StringX

func (bls *BookLoanSelect) StringX(ctx context.Context) string

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

func (*BookLoanSelect) Strings

func (bls *BookLoanSelect) Strings(ctx context.Context) ([]string, error)

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

func (*BookLoanSelect) StringsX

func (bls *BookLoanSelect) StringsX(ctx context.Context) []string

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

type BookLoanUpdate

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

BookLoanUpdate is the builder for updating BookLoan entities.

func (*BookLoanUpdate) ClearBook

func (blu *BookLoanUpdate) ClearBook() *BookLoanUpdate

ClearBook clears the "book" edge to the Book entity.

func (*BookLoanUpdate) ClearUser

func (blu *BookLoanUpdate) ClearUser() *BookLoanUpdate

ClearUser clears the "user" edge to the User entity.

func (*BookLoanUpdate) Exec

func (blu *BookLoanUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*BookLoanUpdate) ExecX

func (blu *BookLoanUpdate) ExecX(ctx context.Context)

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

func (*BookLoanUpdate) Mutation

func (blu *BookLoanUpdate) Mutation() *BookLoanMutation

Mutation returns the BookLoanMutation object of the builder.

func (*BookLoanUpdate) Save

func (blu *BookLoanUpdate) Save(ctx context.Context) (int, error)

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

func (*BookLoanUpdate) SaveX

func (blu *BookLoanUpdate) SaveX(ctx context.Context) int

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

func (*BookLoanUpdate) SetBook

func (blu *BookLoanUpdate) SetBook(b *Book) *BookLoanUpdate

SetBook sets the "book" edge to the Book entity.

func (*BookLoanUpdate) SetBookID

func (blu *BookLoanUpdate) SetBookID(id uuid.UUID) *BookLoanUpdate

SetBookID sets the "book" edge to the Book entity by ID.

func (*BookLoanUpdate) SetDeliveryDate

func (blu *BookLoanUpdate) SetDeliveryDate(t time.Time) *BookLoanUpdate

SetDeliveryDate sets the "delivery_date" field.

func (*BookLoanUpdate) SetUpdatedAt

func (blu *BookLoanUpdate) SetUpdatedAt(t time.Time) *BookLoanUpdate

SetUpdatedAt sets the "updated_at" field.

func (*BookLoanUpdate) SetUser

func (blu *BookLoanUpdate) SetUser(u *User) *BookLoanUpdate

SetUser sets the "user" edge to the User entity.

func (*BookLoanUpdate) SetUserID

func (blu *BookLoanUpdate) SetUserID(id uuid.UUID) *BookLoanUpdate

SetUserID sets the "user" edge to the User entity by ID.

func (*BookLoanUpdate) Where

func (blu *BookLoanUpdate) Where(ps ...predicate.BookLoan) *BookLoanUpdate

Where appends a list predicates to the BookLoanUpdate builder.

type BookLoanUpdateOne

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

BookLoanUpdateOne is the builder for updating a single BookLoan entity.

func (*BookLoanUpdateOne) ClearBook

func (bluo *BookLoanUpdateOne) ClearBook() *BookLoanUpdateOne

ClearBook clears the "book" edge to the Book entity.

func (*BookLoanUpdateOne) ClearUser

func (bluo *BookLoanUpdateOne) ClearUser() *BookLoanUpdateOne

ClearUser clears the "user" edge to the User entity.

func (*BookLoanUpdateOne) Exec

func (bluo *BookLoanUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*BookLoanUpdateOne) ExecX

func (bluo *BookLoanUpdateOne) ExecX(ctx context.Context)

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

func (*BookLoanUpdateOne) Mutation

func (bluo *BookLoanUpdateOne) Mutation() *BookLoanMutation

Mutation returns the BookLoanMutation object of the builder.

func (*BookLoanUpdateOne) Save

func (bluo *BookLoanUpdateOne) Save(ctx context.Context) (*BookLoan, error)

Save executes the query and returns the updated BookLoan entity.

func (*BookLoanUpdateOne) SaveX

func (bluo *BookLoanUpdateOne) SaveX(ctx context.Context) *BookLoan

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

func (*BookLoanUpdateOne) Select

func (bluo *BookLoanUpdateOne) Select(field string, fields ...string) *BookLoanUpdateOne

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

func (*BookLoanUpdateOne) SetBook

func (bluo *BookLoanUpdateOne) SetBook(b *Book) *BookLoanUpdateOne

SetBook sets the "book" edge to the Book entity.

func (*BookLoanUpdateOne) SetBookID

func (bluo *BookLoanUpdateOne) SetBookID(id uuid.UUID) *BookLoanUpdateOne

SetBookID sets the "book" edge to the Book entity by ID.

func (*BookLoanUpdateOne) SetDeliveryDate

func (bluo *BookLoanUpdateOne) SetDeliveryDate(t time.Time) *BookLoanUpdateOne

SetDeliveryDate sets the "delivery_date" field.

func (*BookLoanUpdateOne) SetUpdatedAt

func (bluo *BookLoanUpdateOne) SetUpdatedAt(t time.Time) *BookLoanUpdateOne

SetUpdatedAt sets the "updated_at" field.

func (*BookLoanUpdateOne) SetUser

func (bluo *BookLoanUpdateOne) SetUser(u *User) *BookLoanUpdateOne

SetUser sets the "user" edge to the User entity.

func (*BookLoanUpdateOne) SetUserID

func (bluo *BookLoanUpdateOne) SetUserID(id uuid.UUID) *BookLoanUpdateOne

SetUserID sets the "user" edge to the User entity by ID.

type BookLoans

type BookLoans []*BookLoan

BookLoans is a parsable slice of BookLoan.

type BookMutation

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

BookMutation represents an operation that mutates the Book nodes in the graph.

func (*BookMutation) Abstract

func (m *BookMutation) Abstract() (r string, exists bool)

Abstract returns the value of the "abstract" field in the mutation.

func (*BookMutation) AbstractCleared

func (m *BookMutation) AbstractCleared() bool

AbstractCleared returns if the "abstract" field was cleared in this mutation.

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) AddOnLoanIDs

func (m *BookMutation) AddOnLoanIDs(ids ...uuid.UUID)

AddOnLoanIDs adds the "on_loans" edge to the BookLoan entity by ids.

func (*BookMutation) AddPages

func (m *BookMutation) AddPages(u int16)

AddPages adds u to the "pages" field.

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) AddedPages

func (m *BookMutation) AddedPages() (r int16, exists bool)

AddedPages returns the value that was added to the "pages" field in this mutation.

func (*BookMutation) AuthorCleared

func (m *BookMutation) AuthorCleared() bool

AuthorCleared reports if the "author" edge to the User entity was cleared.

func (*BookMutation) AuthorID

func (m *BookMutation) AuthorID() (id uuid.UUID, exists bool)

AuthorID returns the "author" edge ID in the mutation.

func (*BookMutation) AuthorIDs

func (m *BookMutation) AuthorIDs() (ids []uuid.UUID)

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

func (*BookMutation) Category

func (m *BookMutation) Category() (r book.Category, exists bool)

Category returns the value of the "category" field in the mutation.

func (*BookMutation) ClearAbstract

func (m *BookMutation) ClearAbstract()

ClearAbstract clears the value of the "abstract" field.

func (*BookMutation) ClearAuthor

func (m *BookMutation) ClearAuthor()

ClearAuthor clears the "author" edge to the User 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) ClearOnLoans

func (m *BookMutation) ClearOnLoans()

ClearOnLoans clears the "on_loans" edge to the BookLoan entity.

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) CoverURL

func (m *BookMutation) CoverURL() (r string, exists bool)

CoverURL returns the value of the "cover_url" field in the mutation.

func (*BookMutation) CreateAt

func (m *BookMutation) CreateAt() (r time.Time, exists bool)

CreateAt returns the value of the "create_at" 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 uuid.UUID, 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) ([]uuid.UUID, 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) OldAbstract

func (m *BookMutation) OldAbstract(ctx context.Context) (v string, err error)

OldAbstract returns the old "abstract" 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 book.Category, 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) OldCoverURL

func (m *BookMutation) OldCoverURL(ctx context.Context) (v string, err error)

OldCoverURL returns the old "cover_url" 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) OldCreateAt

func (m *BookMutation) OldCreateAt(ctx context.Context) (v time.Time, err error)

OldCreateAt returns the old "create_at" 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

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

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

func (*BookMutation) OldPages

func (m *BookMutation) OldPages(ctx context.Context) (v uint16, err error)

OldPages returns the old "pages" 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) OldUpdatedAt

func (m *BookMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error)

OldUpdatedAt returns the old "updated_at" 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) OnLoansCleared

func (m *BookMutation) OnLoansCleared() bool

OnLoansCleared reports if the "on_loans" edge to the BookLoan entity was cleared.

func (*BookMutation) OnLoansIDs

func (m *BookMutation) OnLoansIDs() (ids []uuid.UUID)

OnLoansIDs returns the "on_loans" edge IDs in the mutation.

func (*BookMutation) Op

func (m *BookMutation) Op() Op

Op returns the operation name.

func (*BookMutation) Pages

func (m *BookMutation) Pages() (r uint16, exists bool)

Pages returns the value of the "pages" field in the mutation.

func (*BookMutation) RemoveOnLoanIDs

func (m *BookMutation) RemoveOnLoanIDs(ids ...uuid.UUID)

RemoveOnLoanIDs removes the "on_loans" edge to the BookLoan entity by IDs.

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) RemovedOnLoansIDs

func (m *BookMutation) RemovedOnLoansIDs() (ids []uuid.UUID)

RemovedOnLoans returns the removed IDs of the "on_loans" edge to the BookLoan entity.

func (*BookMutation) ResetAbstract

func (m *BookMutation) ResetAbstract()

ResetAbstract resets all changes to the "abstract" field.

func (*BookMutation) ResetAuthor

func (m *BookMutation) ResetAuthor()

ResetAuthor resets all changes to the "author" edge.

func (*BookMutation) ResetCategory

func (m *BookMutation) ResetCategory()

ResetCategory resets all changes to the "category" field.

func (*BookMutation) ResetCoverURL

func (m *BookMutation) ResetCoverURL()

ResetCoverURL resets all changes to the "cover_url" field.

func (*BookMutation) ResetCreateAt

func (m *BookMutation) ResetCreateAt()

ResetCreateAt resets all changes to the "create_at" 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) ResetOnLoans

func (m *BookMutation) ResetOnLoans()

ResetOnLoans resets all changes to the "on_loans" edge.

func (*BookMutation) ResetPages

func (m *BookMutation) ResetPages()

ResetPages resets all changes to the "pages" field.

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 "updated_at" field.

func (*BookMutation) SetAbstract

func (m *BookMutation) SetAbstract(s string)

SetAbstract sets the "abstract" field.

func (*BookMutation) SetAuthorID

func (m *BookMutation) SetAuthorID(id uuid.UUID)

SetAuthorID sets the "author" edge to the User entity by id.

func (*BookMutation) SetCategory

func (m *BookMutation) SetCategory(b book.Category)

SetCategory sets the "category" field.

func (*BookMutation) SetCoverURL

func (m *BookMutation) SetCoverURL(s string)

SetCoverURL sets the "cover_url" field.

func (*BookMutation) SetCreateAt

func (m *BookMutation) SetCreateAt(t time.Time)

SetCreateAt sets the "create_at" 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 uuid.UUID)

SetID sets the value of the id field. Note that this operation is only accepted on creation of Book entities.

func (*BookMutation) SetPages

func (m *BookMutation) SetPages(u uint16)

SetPages sets the "pages" field.

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 "updated_at" 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).

func (*BookMutation) UpdatedAt

func (m *BookMutation) UpdatedAt() (r time.Time, exists bool)

UpdatedAt returns the value of the "updated_at" field in the mutation.

func (*BookMutation) Where

func (m *BookMutation) Where(ps ...predicate.Book)

Where appends a list predicates to the BookMutation builder.

type BookQuery

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

BookQuery is the builder for querying Book entities.

func (*BookQuery) All

func (bq *BookQuery) All(ctx context.Context) ([]*Book, error)

All executes the query and returns a list of Books.

func (*BookQuery) AllX

func (bq *BookQuery) AllX(ctx context.Context) []*Book

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

func (*BookQuery) Clone

func (bq *BookQuery) Clone() *BookQuery

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) Count

func (bq *BookQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*BookQuery) CountX

func (bq *BookQuery) CountX(ctx context.Context) int

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

func (*BookQuery) Exist

func (bq *BookQuery) Exist(ctx context.Context) (bool, error)

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

func (*BookQuery) ExistX

func (bq *BookQuery) ExistX(ctx context.Context) bool

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

func (*BookQuery) First

func (bq *BookQuery) First(ctx context.Context) (*Book, error)

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

func (*BookQuery) FirstID

func (bq *BookQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)

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

func (*BookQuery) FirstIDX

func (bq *BookQuery) FirstIDX(ctx context.Context) uuid.UUID

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

func (*BookQuery) FirstX

func (bq *BookQuery) FirstX(ctx context.Context) *Book

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

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 {
	CreateAt time.Time `json:"create_at,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Book.Query().
	GroupBy(book.FieldCreateAt).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*BookQuery) IDs

func (bq *BookQuery) IDs(ctx context.Context) ([]uuid.UUID, error)

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

func (*BookQuery) IDsX

func (bq *BookQuery) IDsX(ctx context.Context) []uuid.UUID

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

func (*BookQuery) Limit

func (bq *BookQuery) Limit(limit int) *BookQuery

Limit adds a limit step to the query.

func (*BookQuery) Offset

func (bq *BookQuery) Offset(offset int) *BookQuery

Offset adds an offset step to the query.

func (*BookQuery) Only

func (bq *BookQuery) Only(ctx context.Context) (*Book, error)

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

func (bq *BookQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)

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) OnlyIDX

func (bq *BookQuery) OnlyIDX(ctx context.Context) uuid.UUID

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

func (*BookQuery) OnlyX

func (bq *BookQuery) OnlyX(ctx context.Context) *Book

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

func (*BookQuery) Order

func (bq *BookQuery) Order(o ...OrderFunc) *BookQuery

Order adds an order step to the query.

func (*BookQuery) QueryAuthor

func (bq *BookQuery) QueryAuthor() *UserQuery

QueryAuthor chains the current query on the "author" edge.

func (*BookQuery) QueryOnLoans

func (bq *BookQuery) QueryOnLoans() *BookLoanQuery

QueryOnLoans chains the current query on the "on_loans" edge.

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 {
	CreateAt time.Time `json:"create_at,omitempty"`
}

client.Book.Query().
	Select(book.FieldCreateAt).
	Scan(ctx, &v)

func (*BookQuery) Unique

func (bq *BookQuery) Unique(unique bool) *BookQuery

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

func (*BookQuery) Where

func (bq *BookQuery) Where(ps ...predicate.Book) *BookQuery

Where adds a new predicate for the BookQuery builder.

func (*BookQuery) WithAuthor

func (bq *BookQuery) WithAuthor(opts ...func(*UserQuery)) *BookQuery

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

func (*BookQuery) WithOnLoans

func (bq *BookQuery) WithOnLoans(opts ...func(*BookLoanQuery)) *BookQuery

WithOnLoans tells the query-builder to eager-load the nodes that are connected to the "on_loans" 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.

func (*BookSelect) Strings

func (bs *BookSelect) Strings(ctx context.Context) ([]string, error)

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

func (*BookSelect) StringsX

func (bs *BookSelect) StringsX(ctx context.Context) []string

StringsX is like Strings, 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) AddOnLoanIDs

func (bu *BookUpdate) AddOnLoanIDs(ids ...uuid.UUID) *BookUpdate

AddOnLoanIDs adds the "on_loans" edge to the BookLoan entity by IDs.

func (*BookUpdate) AddOnLoans

func (bu *BookUpdate) AddOnLoans(b ...*BookLoan) *BookUpdate

AddOnLoans adds the "on_loans" edges to the BookLoan entity.

func (*BookUpdate) AddPages

func (bu *BookUpdate) AddPages(u int16) *BookUpdate

AddPages adds u to the "pages" field.

func (*BookUpdate) ClearAbstract

func (bu *BookUpdate) ClearAbstract() *BookUpdate

ClearAbstract clears the value of the "abstract" field.

func (*BookUpdate) ClearAuthor

func (bu *BookUpdate) ClearAuthor() *BookUpdate

ClearAuthor clears the "author" edge to the User entity.

func (*BookUpdate) ClearOnLoans

func (bu *BookUpdate) ClearOnLoans() *BookUpdate

ClearOnLoans clears all "on_loans" edges to the BookLoan 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) RemoveOnLoanIDs

func (bu *BookUpdate) RemoveOnLoanIDs(ids ...uuid.UUID) *BookUpdate

RemoveOnLoanIDs removes the "on_loans" edge to BookLoan entities by IDs.

func (*BookUpdate) RemoveOnLoans

func (bu *BookUpdate) RemoveOnLoans(b ...*BookLoan) *BookUpdate

RemoveOnLoans removes "on_loans" edges to BookLoan entities.

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) SetAbstract

func (bu *BookUpdate) SetAbstract(s string) *BookUpdate

SetAbstract sets the "abstract" field.

func (*BookUpdate) SetAuthor

func (bu *BookUpdate) SetAuthor(u *User) *BookUpdate

SetAuthor sets the "author" edge to the User entity.

func (*BookUpdate) SetAuthorID

func (bu *BookUpdate) SetAuthorID(id uuid.UUID) *BookUpdate

SetAuthorID sets the "author" edge to the User entity by ID.

func (*BookUpdate) SetCategory

func (bu *BookUpdate) SetCategory(b book.Category) *BookUpdate

SetCategory sets the "category" field.

func (*BookUpdate) SetCoverURL

func (bu *BookUpdate) SetCoverURL(s string) *BookUpdate

SetCoverURL sets the "cover_url" field.

func (*BookUpdate) SetNillableAbstract

func (bu *BookUpdate) SetNillableAbstract(s *string) *BookUpdate

SetNillableAbstract sets the "abstract" field if the given value is not nil.

func (*BookUpdate) SetPages

func (bu *BookUpdate) SetPages(u uint16) *BookUpdate

SetPages sets the "pages" 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 "updated_at" 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) AddOnLoanIDs

func (buo *BookUpdateOne) AddOnLoanIDs(ids ...uuid.UUID) *BookUpdateOne

AddOnLoanIDs adds the "on_loans" edge to the BookLoan entity by IDs.

func (*BookUpdateOne) AddOnLoans

func (buo *BookUpdateOne) AddOnLoans(b ...*BookLoan) *BookUpdateOne

AddOnLoans adds the "on_loans" edges to the BookLoan entity.

func (*BookUpdateOne) AddPages

func (buo *BookUpdateOne) AddPages(u int16) *BookUpdateOne

AddPages adds u to the "pages" field.

func (*BookUpdateOne) ClearAbstract

func (buo *BookUpdateOne) ClearAbstract() *BookUpdateOne

ClearAbstract clears the value of the "abstract" field.

func (*BookUpdateOne) ClearAuthor

func (buo *BookUpdateOne) ClearAuthor() *BookUpdateOne

ClearAuthor clears the "author" edge to the User entity.

func (*BookUpdateOne) ClearOnLoans

func (buo *BookUpdateOne) ClearOnLoans() *BookUpdateOne

ClearOnLoans clears all "on_loans" edges to the BookLoan 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) RemoveOnLoanIDs

func (buo *BookUpdateOne) RemoveOnLoanIDs(ids ...uuid.UUID) *BookUpdateOne

RemoveOnLoanIDs removes the "on_loans" edge to BookLoan entities by IDs.

func (*BookUpdateOne) RemoveOnLoans

func (buo *BookUpdateOne) RemoveOnLoans(b ...*BookLoan) *BookUpdateOne

RemoveOnLoans removes "on_loans" edges to BookLoan entities.

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) SetAbstract

func (buo *BookUpdateOne) SetAbstract(s string) *BookUpdateOne

SetAbstract sets the "abstract" field.

func (*BookUpdateOne) SetAuthor

func (buo *BookUpdateOne) SetAuthor(u *User) *BookUpdateOne

SetAuthor sets the "author" edge to the User entity.

func (*BookUpdateOne) SetAuthorID

func (buo *BookUpdateOne) SetAuthorID(id uuid.UUID) *BookUpdateOne

SetAuthorID sets the "author" edge to the User entity by ID.

func (*BookUpdateOne) SetCategory

func (buo *BookUpdateOne) SetCategory(b book.Category) *BookUpdateOne

SetCategory sets the "category" field.

func (*BookUpdateOne) SetCoverURL

func (buo *BookUpdateOne) SetCoverURL(s string) *BookUpdateOne

SetCoverURL sets the "cover_url" field.

func (*BookUpdateOne) SetNillableAbstract

func (buo *BookUpdateOne) SetNillableAbstract(s *string) *BookUpdateOne

SetNillableAbstract sets the "abstract" field if the given value is not nil.

func (*BookUpdateOne) SetPages

func (buo *BookUpdateOne) SetPages(u uint16) *BookUpdateOne

SetPages sets the "pages" 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 "updated_at" field.

type Books

type Books []*Book

Books is a parsable slice of Book.

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
	// BookLoan is the client for interacting with the BookLoan builders.
	BookLoan *BookLoanClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// contains filtered or unexported fields
}

Client is the client that holds all ent builders.

func FromContext

func FromContext(ctx context.Context) *Client

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

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new client configured with the given options.

func Open

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

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

func (*Client) BeginTx

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

BeginTx returns a transactional client with specified options.

func (*Client) Close

func (c *Client) Close() error

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

func (*Client) Debug

func (c *Client) Debug() *Client

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

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

func (*Client) Tx

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

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

func (*Client) Use

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

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

type CommitFunc

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

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

func (CommitFunc) Commit

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

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

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

hook := func(next ent.Committer) ent.Committer {
	return ent.CommitFunc(func(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 Committer

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

Committer is the interface that wraps the Commit method.

type ConstraintError

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

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

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

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

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

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

type NotFoundError

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

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

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

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

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

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

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

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

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

OrderFunc applies an ordering on the sql selector.

func Asc

func Asc(fields ...string) OrderFunc

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) OrderFunc

Desc applies the given fields in DESC order.

type Policy

type Policy = ent.Policy

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

type Query

type Query = ent.Query

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

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

hook := func(next ent.Rollbacker) ent.Rollbacker {
	return ent.RollbackFunc(func(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

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

Rollbacker is the interface that wraps the Rollback method.

type Tx

type Tx struct {

	// Book is the client for interacting with the Book builders.
	Book *BookClient
	// BookLoan is the client for interacting with the BookLoan builders.
	BookLoan *BookLoanClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// contains filtered or unexported fields
}

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

func TxFromContext

func TxFromContext(ctx context.Context) *Tx

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

func (*Tx) Client

func (tx *Tx) Client() *Client

Client returns a Client that binds to current transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) OnCommit

func (tx *Tx) OnCommit(f CommitHook)

OnCommit adds a hook to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f RollbackHook)

OnRollback adds a hook to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

type User

type User struct {

	// ID of the ent.
	ID uuid.UUID `json:"id,omitempty"`
	// CreateAt holds the value of the "create_at" field.
	CreateAt time.Time `json:"create_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// FirstName holds the value of the "first_name" field.
	FirstName string `json:"first_name,omitempty"`
	// LastName holds the value of the "last_name" field.
	LastName string `json:"last_name,omitempty"`
	// Email holds the value of the "email" field.
	Email string `json:"email,omitempty"`
	// Password holds the value of the "password" field.
	Password string `json:"-"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the UserQuery when eager-loading is set.
	Edges UserEdges `json:"edges"`
	// contains filtered or unexported fields
}

User is the model entity for the User schema.

func (*User) QueryBooks

func (u *User) QueryBooks() *BookQuery

QueryBooks queries the "books" edge of the User entity.

func (*User) QueryLoans

func (u *User) QueryLoans() *BookLoanQuery

QueryLoans queries the "loans" edge of the User entity.

func (*User) String

func (u *User) String() string

String implements the fmt.Stringer.

func (*User) Unwrap

func (u *User) Unwrap() *User

Unwrap unwraps the User 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 (*User) Update

func (u *User) Update() *UserUpdateOne

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

type UserClient

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

UserClient is a client for the User schema.

func NewUserClient

func NewUserClient(c config) *UserClient

NewUserClient returns a client for the User from the given config.

func (*UserClient) Create

func (c *UserClient) Create() *UserCreate

Create returns a create builder for User.

func (*UserClient) CreateBulk

func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk

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

func (*UserClient) Delete

func (c *UserClient) Delete() *UserDelete

Delete returns a delete builder for User.

func (*UserClient) DeleteOne

func (c *UserClient) DeleteOne(u *User) *UserDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*UserClient) DeleteOneID

func (c *UserClient) DeleteOneID(id uuid.UUID) *UserDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*UserClient) Get

func (c *UserClient) Get(ctx context.Context, id uuid.UUID) (*User, error)

Get returns a User entity by its id.

func (*UserClient) GetX

func (c *UserClient) GetX(ctx context.Context, id uuid.UUID) *User

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

func (*UserClient) Hooks

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

Hooks returns the client hooks.

func (*UserClient) Query

func (c *UserClient) Query() *UserQuery

Query returns a query builder for User.

func (*UserClient) QueryBooks

func (c *UserClient) QueryBooks(u *User) *BookQuery

QueryBooks queries the books edge of a User.

func (*UserClient) QueryLoans

func (c *UserClient) QueryLoans(u *User) *BookLoanQuery

QueryLoans queries the loans edge of a User.

func (*UserClient) Update

func (c *UserClient) Update() *UserUpdate

Update returns an update builder for User.

func (*UserClient) UpdateOne

func (c *UserClient) UpdateOne(u *User) *UserUpdateOne

UpdateOne returns an update builder for the given entity.

func (*UserClient) UpdateOneID

func (c *UserClient) UpdateOneID(id uuid.UUID) *UserUpdateOne

UpdateOneID returns an update builder for the given id.

func (*UserClient) Use

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

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

type UserCreate

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

UserCreate is the builder for creating a User entity.

func (*UserCreate) AddBookIDs

func (uc *UserCreate) AddBookIDs(ids ...uuid.UUID) *UserCreate

AddBookIDs adds the "books" edge to the Book entity by IDs.

func (*UserCreate) AddBooks

func (uc *UserCreate) AddBooks(b ...*Book) *UserCreate

AddBooks adds the "books" edges to the Book entity.

func (*UserCreate) AddLoanIDs

func (uc *UserCreate) AddLoanIDs(ids ...uuid.UUID) *UserCreate

AddLoanIDs adds the "loans" edge to the BookLoan entity by IDs.

func (*UserCreate) AddLoans

func (uc *UserCreate) AddLoans(b ...*BookLoan) *UserCreate

AddLoans adds the "loans" edges to the BookLoan entity.

func (*UserCreate) Exec

func (uc *UserCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserCreate) ExecX

func (uc *UserCreate) ExecX(ctx context.Context)

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

func (*UserCreate) Mutation

func (uc *UserCreate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserCreate) Save

func (uc *UserCreate) Save(ctx context.Context) (*User, error)

Save creates the User in the database.

func (*UserCreate) SaveX

func (uc *UserCreate) SaveX(ctx context.Context) *User

SaveX calls Save and panics if Save returns an error.

func (*UserCreate) SetCreateAt

func (uc *UserCreate) SetCreateAt(t time.Time) *UserCreate

SetCreateAt sets the "create_at" field.

func (*UserCreate) SetEmail

func (uc *UserCreate) SetEmail(s string) *UserCreate

SetEmail sets the "email" field.

func (*UserCreate) SetFirstName

func (uc *UserCreate) SetFirstName(s string) *UserCreate

SetFirstName sets the "first_name" field.

func (*UserCreate) SetID

func (uc *UserCreate) SetID(u uuid.UUID) *UserCreate

SetID sets the "id" field.

func (*UserCreate) SetLastName

func (uc *UserCreate) SetLastName(s string) *UserCreate

SetLastName sets the "last_name" field.

func (*UserCreate) SetNillableCreateAt

func (uc *UserCreate) SetNillableCreateAt(t *time.Time) *UserCreate

SetNillableCreateAt sets the "create_at" field if the given value is not nil.

func (*UserCreate) SetNillableID

func (uc *UserCreate) SetNillableID(u *uuid.UUID) *UserCreate

SetNillableID sets the "id" field if the given value is not nil.

func (*UserCreate) SetNillableUpdatedAt

func (uc *UserCreate) SetNillableUpdatedAt(t *time.Time) *UserCreate

SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.

func (*UserCreate) SetPassword

func (uc *UserCreate) SetPassword(s string) *UserCreate

SetPassword sets the "password" field.

func (*UserCreate) SetUpdatedAt

func (uc *UserCreate) SetUpdatedAt(t time.Time) *UserCreate

SetUpdatedAt sets the "updated_at" field.

type UserCreateBulk

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

UserCreateBulk is the builder for creating many User entities in bulk.

func (*UserCreateBulk) Exec

func (ucb *UserCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*UserCreateBulk) ExecX

func (ucb *UserCreateBulk) ExecX(ctx context.Context)

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

func (*UserCreateBulk) Save

func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error)

Save creates the User entities in the database.

func (*UserCreateBulk) SaveX

func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User

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

type UserDelete

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

UserDelete is the builder for deleting a User entity.

func (*UserDelete) Exec

func (ud *UserDelete) Exec(ctx context.Context) (int, error)

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

func (*UserDelete) ExecX

func (ud *UserDelete) ExecX(ctx context.Context) int

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

func (*UserDelete) Where

func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete

Where appends a list predicates to the UserDelete builder.

type UserDeleteOne

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

UserDeleteOne is the builder for deleting a single User entity.

func (*UserDeleteOne) Exec

func (udo *UserDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*UserDeleteOne) ExecX

func (udo *UserDeleteOne) ExecX(ctx context.Context)

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

type UserEdges

type UserEdges struct {
	// Books holds the value of the books edge.
	Books []*Book `json:"books,omitempty"`
	// Loans holds the value of the loans edge.
	Loans []*BookLoan `json:"loans,omitempty"`
	// contains filtered or unexported fields
}

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

func (UserEdges) BooksOrErr

func (e UserEdges) BooksOrErr() ([]*Book, error)

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

func (UserEdges) LoansOrErr

func (e UserEdges) LoansOrErr() ([]*BookLoan, error)

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

type UserGroupBy

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

UserGroupBy is the group-by builder for User entities.

func (*UserGroupBy) Aggregate

func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy

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

func (*UserGroupBy) Bool

func (ugb *UserGroupBy) 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 (*UserGroupBy) BoolX

func (ugb *UserGroupBy) BoolX(ctx context.Context) bool

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

func (*UserGroupBy) Bools

func (ugb *UserGroupBy) 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 (*UserGroupBy) BoolsX

func (ugb *UserGroupBy) BoolsX(ctx context.Context) []bool

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

func (*UserGroupBy) Float64

func (ugb *UserGroupBy) 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 (*UserGroupBy) Float64X

func (ugb *UserGroupBy) Float64X(ctx context.Context) float64

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

func (*UserGroupBy) Float64s

func (ugb *UserGroupBy) 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 (*UserGroupBy) Float64sX

func (ugb *UserGroupBy) Float64sX(ctx context.Context) []float64

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

func (*UserGroupBy) Int

func (ugb *UserGroupBy) 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 (*UserGroupBy) IntX

func (ugb *UserGroupBy) IntX(ctx context.Context) int

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

func (*UserGroupBy) Ints

func (ugb *UserGroupBy) 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 (*UserGroupBy) IntsX

func (ugb *UserGroupBy) IntsX(ctx context.Context) []int

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

func (*UserGroupBy) Scan

func (ugb *UserGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*UserGroupBy) ScanX

func (ugb *UserGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*UserGroupBy) String

func (ugb *UserGroupBy) 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 (*UserGroupBy) StringX

func (ugb *UserGroupBy) StringX(ctx context.Context) string

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

func (*UserGroupBy) Strings

func (ugb *UserGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*UserGroupBy) StringsX

func (ugb *UserGroupBy) StringsX(ctx context.Context) []string

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

type UserMutation

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

UserMutation represents an operation that mutates the User nodes in the graph.

func (*UserMutation) AddBookIDs

func (m *UserMutation) AddBookIDs(ids ...uuid.UUID)

AddBookIDs adds the "books" edge to the Book entity by ids.

func (*UserMutation) AddField

func (m *UserMutation) 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 (*UserMutation) AddLoanIDs

func (m *UserMutation) AddLoanIDs(ids ...uuid.UUID)

AddLoanIDs adds the "loans" edge to the BookLoan entity by ids.

func (*UserMutation) AddedEdges

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

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

func (*UserMutation) AddedField

func (m *UserMutation) 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 (*UserMutation) AddedFields

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

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

func (*UserMutation) AddedIDs

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

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

func (*UserMutation) BooksCleared

func (m *UserMutation) BooksCleared() bool

BooksCleared reports if the "books" edge to the Book entity was cleared.

func (*UserMutation) BooksIDs

func (m *UserMutation) BooksIDs() (ids []uuid.UUID)

BooksIDs returns the "books" edge IDs in the mutation.

func (*UserMutation) ClearBooks

func (m *UserMutation) ClearBooks()

ClearBooks clears the "books" edge to the Book entity.

func (*UserMutation) ClearEdge

func (m *UserMutation) 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 (*UserMutation) ClearField

func (m *UserMutation) 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 (*UserMutation) ClearLoans

func (m *UserMutation) ClearLoans()

ClearLoans clears the "loans" edge to the BookLoan entity.

func (*UserMutation) ClearedEdges

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

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

func (*UserMutation) ClearedFields

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

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

func (UserMutation) Client

func (m UserMutation) 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 (*UserMutation) CreateAt

func (m *UserMutation) CreateAt() (r time.Time, exists bool)

CreateAt returns the value of the "create_at" field in the mutation.

func (*UserMutation) EdgeCleared

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

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

func (*UserMutation) Email

func (m *UserMutation) Email() (r string, exists bool)

Email returns the value of the "email" field in the mutation.

func (*UserMutation) Field

func (m *UserMutation) 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 (*UserMutation) FieldCleared

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

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

func (*UserMutation) Fields

func (m *UserMutation) 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 (*UserMutation) FirstName

func (m *UserMutation) FirstName() (r string, exists bool)

FirstName returns the value of the "first_name" field in the mutation.

func (*UserMutation) ID

func (m *UserMutation) ID() (id uuid.UUID, 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 (*UserMutation) IDs

func (m *UserMutation) IDs(ctx context.Context) ([]uuid.UUID, 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 (*UserMutation) LastName

func (m *UserMutation) LastName() (r string, exists bool)

LastName returns the value of the "last_name" field in the mutation.

func (*UserMutation) LoansCleared

func (m *UserMutation) LoansCleared() bool

LoansCleared reports if the "loans" edge to the BookLoan entity was cleared.

func (*UserMutation) LoansIDs

func (m *UserMutation) LoansIDs() (ids []uuid.UUID)

LoansIDs returns the "loans" edge IDs in the mutation.

func (*UserMutation) OldCreateAt

func (m *UserMutation) OldCreateAt(ctx context.Context) (v time.Time, err error)

OldCreateAt returns the old "create_at" field's value of the User entity. If the User 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 (*UserMutation) OldEmail

func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error)

OldEmail returns the old "email" field's value of the User entity. If the User 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 (*UserMutation) OldField

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

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

func (*UserMutation) OldFirstName

func (m *UserMutation) OldFirstName(ctx context.Context) (v string, err error)

OldFirstName returns the old "first_name" field's value of the User entity. If the User 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 (*UserMutation) OldLastName

func (m *UserMutation) OldLastName(ctx context.Context) (v string, err error)

OldLastName returns the old "last_name" field's value of the User entity. If the User 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 (*UserMutation) OldPassword

func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error)

OldPassword returns the old "password" field's value of the User entity. If the User 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 (*UserMutation) OldUpdatedAt

func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error)

OldUpdatedAt returns the old "updated_at" field's value of the User entity. If the User 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 (*UserMutation) Op

func (m *UserMutation) Op() Op

Op returns the operation name.

func (*UserMutation) Password

func (m *UserMutation) Password() (r string, exists bool)

Password returns the value of the "password" field in the mutation.

func (*UserMutation) RemoveBookIDs

func (m *UserMutation) RemoveBookIDs(ids ...uuid.UUID)

RemoveBookIDs removes the "books" edge to the Book entity by IDs.

func (*UserMutation) RemoveLoanIDs

func (m *UserMutation) RemoveLoanIDs(ids ...uuid.UUID)

RemoveLoanIDs removes the "loans" edge to the BookLoan entity by IDs.

func (*UserMutation) RemovedBooksIDs

func (m *UserMutation) RemovedBooksIDs() (ids []uuid.UUID)

RemovedBooks returns the removed IDs of the "books" edge to the Book entity.

func (*UserMutation) RemovedEdges

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

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

func (*UserMutation) RemovedIDs

func (m *UserMutation) 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 (*UserMutation) RemovedLoansIDs

func (m *UserMutation) RemovedLoansIDs() (ids []uuid.UUID)

RemovedLoans returns the removed IDs of the "loans" edge to the BookLoan entity.

func (*UserMutation) ResetBooks

func (m *UserMutation) ResetBooks()

ResetBooks resets all changes to the "books" edge.

func (*UserMutation) ResetCreateAt

func (m *UserMutation) ResetCreateAt()

ResetCreateAt resets all changes to the "create_at" field.

func (*UserMutation) ResetEdge

func (m *UserMutation) 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 (*UserMutation) ResetEmail

func (m *UserMutation) ResetEmail()

ResetEmail resets all changes to the "email" field.

func (*UserMutation) ResetField

func (m *UserMutation) 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 (*UserMutation) ResetFirstName

func (m *UserMutation) ResetFirstName()

ResetFirstName resets all changes to the "first_name" field.

func (*UserMutation) ResetLastName

func (m *UserMutation) ResetLastName()

ResetLastName resets all changes to the "last_name" field.

func (*UserMutation) ResetLoans

func (m *UserMutation) ResetLoans()

ResetLoans resets all changes to the "loans" edge.

func (*UserMutation) ResetPassword

func (m *UserMutation) ResetPassword()

ResetPassword resets all changes to the "password" field.

func (*UserMutation) ResetUpdatedAt

func (m *UserMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*UserMutation) SetCreateAt

func (m *UserMutation) SetCreateAt(t time.Time)

SetCreateAt sets the "create_at" field.

func (*UserMutation) SetEmail

func (m *UserMutation) SetEmail(s string)

SetEmail sets the "email" field.

func (*UserMutation) SetField

func (m *UserMutation) 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 (*UserMutation) SetFirstName

func (m *UserMutation) SetFirstName(s string)

SetFirstName sets the "first_name" field.

func (*UserMutation) SetID

func (m *UserMutation) SetID(id uuid.UUID)

SetID sets the value of the id field. Note that this operation is only accepted on creation of User entities.

func (*UserMutation) SetLastName

func (m *UserMutation) SetLastName(s string)

SetLastName sets the "last_name" field.

func (*UserMutation) SetPassword

func (m *UserMutation) SetPassword(s string)

SetPassword sets the "password" field.

func (*UserMutation) SetUpdatedAt

func (m *UserMutation) SetUpdatedAt(t time.Time)

SetUpdatedAt sets the "updated_at" field.

func (UserMutation) Tx

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

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

func (*UserMutation) Type

func (m *UserMutation) Type() string

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

func (*UserMutation) UpdatedAt

func (m *UserMutation) UpdatedAt() (r time.Time, exists bool)

UpdatedAt returns the value of the "updated_at" field in the mutation.

func (*UserMutation) Where

func (m *UserMutation) Where(ps ...predicate.User)

Where appends a list predicates to the UserMutation builder.

type UserQuery

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

UserQuery is the builder for querying User entities.

func (*UserQuery) All

func (uq *UserQuery) All(ctx context.Context) ([]*User, error)

All executes the query and returns a list of Users.

func (*UserQuery) AllX

func (uq *UserQuery) AllX(ctx context.Context) []*User

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

func (*UserQuery) Clone

func (uq *UserQuery) Clone() *UserQuery

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

func (*UserQuery) Count

func (uq *UserQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*UserQuery) CountX

func (uq *UserQuery) CountX(ctx context.Context) int

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

func (*UserQuery) Exist

func (uq *UserQuery) Exist(ctx context.Context) (bool, error)

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

func (*UserQuery) ExistX

func (uq *UserQuery) ExistX(ctx context.Context) bool

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

func (*UserQuery) First

func (uq *UserQuery) First(ctx context.Context) (*User, error)

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

func (*UserQuery) FirstID

func (uq *UserQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)

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

func (*UserQuery) FirstIDX

func (uq *UserQuery) FirstIDX(ctx context.Context) uuid.UUID

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

func (*UserQuery) FirstX

func (uq *UserQuery) FirstX(ctx context.Context) *User

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

func (*UserQuery) GroupBy

func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy

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 {
	CreateAt time.Time `json:"create_at,omitempty"`
	Count int `json:"count,omitempty"`
}

client.User.Query().
	GroupBy(user.FieldCreateAt).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*UserQuery) IDs

func (uq *UserQuery) IDs(ctx context.Context) ([]uuid.UUID, error)

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

func (*UserQuery) IDsX

func (uq *UserQuery) IDsX(ctx context.Context) []uuid.UUID

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

func (*UserQuery) Limit

func (uq *UserQuery) Limit(limit int) *UserQuery

Limit adds a limit step to the query.

func (*UserQuery) Offset

func (uq *UserQuery) Offset(offset int) *UserQuery

Offset adds an offset step to the query.

func (*UserQuery) Only

func (uq *UserQuery) Only(ctx context.Context) (*User, error)

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

func (*UserQuery) OnlyID

func (uq *UserQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error)

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

func (*UserQuery) OnlyIDX

func (uq *UserQuery) OnlyIDX(ctx context.Context) uuid.UUID

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

func (*UserQuery) OnlyX

func (uq *UserQuery) OnlyX(ctx context.Context) *User

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

func (*UserQuery) Order

func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery

Order adds an order step to the query.

func (*UserQuery) QueryBooks

func (uq *UserQuery) QueryBooks() *BookQuery

QueryBooks chains the current query on the "books" edge.

func (*UserQuery) QueryLoans

func (uq *UserQuery) QueryLoans() *BookLoanQuery

QueryLoans chains the current query on the "loans" edge.

func (*UserQuery) Select

func (uq *UserQuery) Select(fields ...string) *UserSelect

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 {
	CreateAt time.Time `json:"create_at,omitempty"`
}

client.User.Query().
	Select(user.FieldCreateAt).
	Scan(ctx, &v)

func (*UserQuery) Unique

func (uq *UserQuery) Unique(unique bool) *UserQuery

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

func (*UserQuery) Where

func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery

Where adds a new predicate for the UserQuery builder.

func (*UserQuery) WithBooks

func (uq *UserQuery) WithBooks(opts ...func(*BookQuery)) *UserQuery

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.

func (*UserQuery) WithLoans

func (uq *UserQuery) WithLoans(opts ...func(*BookLoanQuery)) *UserQuery

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

type UserSelect

type UserSelect struct {
	*UserQuery
	// contains filtered or unexported fields
}

UserSelect is the builder for selecting fields of User entities.

func (*UserSelect) Bool

func (us *UserSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*UserSelect) BoolX

func (us *UserSelect) BoolX(ctx context.Context) bool

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

func (*UserSelect) Bools

func (us *UserSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*UserSelect) BoolsX

func (us *UserSelect) BoolsX(ctx context.Context) []bool

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

func (*UserSelect) Float64

func (us *UserSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*UserSelect) Float64X

func (us *UserSelect) Float64X(ctx context.Context) float64

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

func (*UserSelect) Float64s

func (us *UserSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*UserSelect) Float64sX

func (us *UserSelect) Float64sX(ctx context.Context) []float64

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

func (*UserSelect) Int

func (us *UserSelect) Int(ctx context.Context) (_ int, err error)

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

func (*UserSelect) IntX

func (us *UserSelect) IntX(ctx context.Context) int

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

func (*UserSelect) Ints

func (us *UserSelect) Ints(ctx context.Context) ([]int, error)

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

func (*UserSelect) IntsX

func (us *UserSelect) IntsX(ctx context.Context) []int

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

func (*UserSelect) Scan

func (us *UserSelect) Scan(ctx context.Context, v interface{}) error

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

func (*UserSelect) ScanX

func (us *UserSelect) ScanX(ctx context.Context, v interface{})

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

func (*UserSelect) String

func (us *UserSelect) String(ctx context.Context) (_ string, err error)

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

func (*UserSelect) StringX

func (us *UserSelect) StringX(ctx context.Context) string

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

func (*UserSelect) Strings

func (us *UserSelect) Strings(ctx context.Context) ([]string, error)

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

func (*UserSelect) StringsX

func (us *UserSelect) StringsX(ctx context.Context) []string

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

type UserUpdate

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

UserUpdate is the builder for updating User entities.

func (*UserUpdate) AddBookIDs

func (uu *UserUpdate) AddBookIDs(ids ...uuid.UUID) *UserUpdate

AddBookIDs adds the "books" edge to the Book entity by IDs.

func (*UserUpdate) AddBooks

func (uu *UserUpdate) AddBooks(b ...*Book) *UserUpdate

AddBooks adds the "books" edges to the Book entity.

func (*UserUpdate) AddLoanIDs

func (uu *UserUpdate) AddLoanIDs(ids ...uuid.UUID) *UserUpdate

AddLoanIDs adds the "loans" edge to the BookLoan entity by IDs.

func (*UserUpdate) AddLoans

func (uu *UserUpdate) AddLoans(b ...*BookLoan) *UserUpdate

AddLoans adds the "loans" edges to the BookLoan entity.

func (*UserUpdate) ClearBooks

func (uu *UserUpdate) ClearBooks() *UserUpdate

ClearBooks clears all "books" edges to the Book entity.

func (*UserUpdate) ClearLoans

func (uu *UserUpdate) ClearLoans() *UserUpdate

ClearLoans clears all "loans" edges to the BookLoan entity.

func (*UserUpdate) Exec

func (uu *UserUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserUpdate) ExecX

func (uu *UserUpdate) ExecX(ctx context.Context)

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

func (*UserUpdate) Mutation

func (uu *UserUpdate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdate) RemoveBookIDs

func (uu *UserUpdate) RemoveBookIDs(ids ...uuid.UUID) *UserUpdate

RemoveBookIDs removes the "books" edge to Book entities by IDs.

func (*UserUpdate) RemoveBooks

func (uu *UserUpdate) RemoveBooks(b ...*Book) *UserUpdate

RemoveBooks removes "books" edges to Book entities.

func (*UserUpdate) RemoveLoanIDs

func (uu *UserUpdate) RemoveLoanIDs(ids ...uuid.UUID) *UserUpdate

RemoveLoanIDs removes the "loans" edge to BookLoan entities by IDs.

func (*UserUpdate) RemoveLoans

func (uu *UserUpdate) RemoveLoans(b ...*BookLoan) *UserUpdate

RemoveLoans removes "loans" edges to BookLoan entities.

func (*UserUpdate) Save

func (uu *UserUpdate) Save(ctx context.Context) (int, error)

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

func (*UserUpdate) SaveX

func (uu *UserUpdate) SaveX(ctx context.Context) int

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

func (*UserUpdate) SetEmail

func (uu *UserUpdate) SetEmail(s string) *UserUpdate

SetEmail sets the "email" field.

func (*UserUpdate) SetFirstName

func (uu *UserUpdate) SetFirstName(s string) *UserUpdate

SetFirstName sets the "first_name" field.

func (*UserUpdate) SetLastName

func (uu *UserUpdate) SetLastName(s string) *UserUpdate

SetLastName sets the "last_name" field.

func (*UserUpdate) SetPassword

func (uu *UserUpdate) SetPassword(s string) *UserUpdate

SetPassword sets the "password" field.

func (*UserUpdate) SetUpdatedAt

func (uu *UserUpdate) SetUpdatedAt(t time.Time) *UserUpdate

SetUpdatedAt sets the "updated_at" field.

func (*UserUpdate) Where

func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate

Where appends a list predicates to the UserUpdate builder.

type UserUpdateOne

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

UserUpdateOne is the builder for updating a single User entity.

func (*UserUpdateOne) AddBookIDs

func (uuo *UserUpdateOne) AddBookIDs(ids ...uuid.UUID) *UserUpdateOne

AddBookIDs adds the "books" edge to the Book entity by IDs.

func (*UserUpdateOne) AddBooks

func (uuo *UserUpdateOne) AddBooks(b ...*Book) *UserUpdateOne

AddBooks adds the "books" edges to the Book entity.

func (*UserUpdateOne) AddLoanIDs

func (uuo *UserUpdateOne) AddLoanIDs(ids ...uuid.UUID) *UserUpdateOne

AddLoanIDs adds the "loans" edge to the BookLoan entity by IDs.

func (*UserUpdateOne) AddLoans

func (uuo *UserUpdateOne) AddLoans(b ...*BookLoan) *UserUpdateOne

AddLoans adds the "loans" edges to the BookLoan entity.

func (*UserUpdateOne) ClearBooks

func (uuo *UserUpdateOne) ClearBooks() *UserUpdateOne

ClearBooks clears all "books" edges to the Book entity.

func (*UserUpdateOne) ClearLoans

func (uuo *UserUpdateOne) ClearLoans() *UserUpdateOne

ClearLoans clears all "loans" edges to the BookLoan entity.

func (*UserUpdateOne) Exec

func (uuo *UserUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*UserUpdateOne) ExecX

func (uuo *UserUpdateOne) ExecX(ctx context.Context)

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

func (*UserUpdateOne) Mutation

func (uuo *UserUpdateOne) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdateOne) RemoveBookIDs

func (uuo *UserUpdateOne) RemoveBookIDs(ids ...uuid.UUID) *UserUpdateOne

RemoveBookIDs removes the "books" edge to Book entities by IDs.

func (*UserUpdateOne) RemoveBooks

func (uuo *UserUpdateOne) RemoveBooks(b ...*Book) *UserUpdateOne

RemoveBooks removes "books" edges to Book entities.

func (*UserUpdateOne) RemoveLoanIDs

func (uuo *UserUpdateOne) RemoveLoanIDs(ids ...uuid.UUID) *UserUpdateOne

RemoveLoanIDs removes the "loans" edge to BookLoan entities by IDs.

func (*UserUpdateOne) RemoveLoans

func (uuo *UserUpdateOne) RemoveLoans(b ...*BookLoan) *UserUpdateOne

RemoveLoans removes "loans" edges to BookLoan entities.

func (*UserUpdateOne) Save

func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error)

Save executes the query and returns the updated User entity.

func (*UserUpdateOne) SaveX

func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User

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

func (*UserUpdateOne) Select

func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne

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

func (*UserUpdateOne) SetEmail

func (uuo *UserUpdateOne) SetEmail(s string) *UserUpdateOne

SetEmail sets the "email" field.

func (*UserUpdateOne) SetFirstName

func (uuo *UserUpdateOne) SetFirstName(s string) *UserUpdateOne

SetFirstName sets the "first_name" field.

func (*UserUpdateOne) SetLastName

func (uuo *UserUpdateOne) SetLastName(s string) *UserUpdateOne

SetLastName sets the "last_name" field.

func (*UserUpdateOne) SetPassword

func (uuo *UserUpdateOne) SetPassword(s string) *UserUpdateOne

SetPassword sets the "password" field.

func (*UserUpdateOne) SetUpdatedAt

func (uuo *UserUpdateOne) SetUpdatedAt(t time.Time) *UserUpdateOne

SetUpdatedAt sets the "updated_at" field.

type Users

type Users []*User

Users is a parsable slice of User.

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.

type Value

type Value = ent.Value

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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