ent

package
v0.0.0-...-4cca6e0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 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.
	TypeArticle        = "Article"
	TypeArticleHistory = "ArticleHistory"
)

Variables

View Source
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")

ErrTxStarted is returned when trying to start a new transaction from a transactional client.

Functions

func Asc

func Asc(fields ...string) func(*sql.Selector)

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) func(*sql.Selector)

Desc applies the given fields in DESC order.

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 Article

type Article struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Title holds the value of the "title" field.
	Title string `json:"title,omitempty"`
	// URL holds the value of the "url" field.
	URL string `json:"url,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the ArticleQuery when eager-loading is set.
	Edges ArticleEdges `json:"edges"`
	// contains filtered or unexported fields
}

Article is the model entity for the Article schema.

func (*Article) QueryOwner

func (a *Article) QueryOwner() *ArticleHistoryQuery

QueryOwner queries the "owner" edge of the Article entity.

func (*Article) String

func (a *Article) String() string

String implements the fmt.Stringer.

func (*Article) Unwrap

func (a *Article) Unwrap() *Article

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

func (a *Article) Update() *ArticleUpdateOne

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

func (*Article) Value

func (a *Article) Value(name string) (ent.Value, error)

Value returns the ent.Value that was dynamically selected and assigned to the Article. This includes values selected through modifiers, order, etc.

type ArticleClient

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

ArticleClient is a client for the Article schema.

func NewArticleClient

func NewArticleClient(c config) *ArticleClient

NewArticleClient returns a client for the Article from the given config.

func (*ArticleClient) Create

func (c *ArticleClient) Create() *ArticleCreate

Create returns a builder for creating a Article entity.

func (*ArticleClient) CreateBulk

func (c *ArticleClient) CreateBulk(builders ...*ArticleCreate) *ArticleCreateBulk

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

func (*ArticleClient) Delete

func (c *ArticleClient) Delete() *ArticleDelete

Delete returns a delete builder for Article.

func (*ArticleClient) DeleteOne

func (c *ArticleClient) DeleteOne(a *Article) *ArticleDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*ArticleClient) DeleteOneID

func (c *ArticleClient) DeleteOneID(id int) *ArticleDeleteOne

DeleteOneID returns a builder for deleting the given entity by its id.

func (*ArticleClient) Get

func (c *ArticleClient) Get(ctx context.Context, id int) (*Article, error)

Get returns a Article entity by its id.

func (*ArticleClient) GetX

func (c *ArticleClient) GetX(ctx context.Context, id int) *Article

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

func (*ArticleClient) Hooks

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

Hooks returns the client hooks.

func (*ArticleClient) Intercept

func (c *ArticleClient) Intercept(interceptors ...Interceptor)

Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `article.Intercept(f(g(h())))`.

func (*ArticleClient) Interceptors

func (c *ArticleClient) Interceptors() []Interceptor

Interceptors returns the client interceptors.

func (*ArticleClient) MapCreateBulk

func (c *ArticleClient) MapCreateBulk(slice any, setFunc func(*ArticleCreate, int)) *ArticleCreateBulk

MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.

func (*ArticleClient) Query

func (c *ArticleClient) Query() *ArticleQuery

Query returns a query builder for Article.

func (*ArticleClient) QueryOwner

func (c *ArticleClient) QueryOwner(a *Article) *ArticleHistoryQuery

QueryOwner queries the owner edge of a Article.

func (*ArticleClient) Update

func (c *ArticleClient) Update() *ArticleUpdate

Update returns an update builder for Article.

func (*ArticleClient) UpdateOne

func (c *ArticleClient) UpdateOne(a *Article) *ArticleUpdateOne

UpdateOne returns an update builder for the given entity.

func (*ArticleClient) UpdateOneID

func (c *ArticleClient) UpdateOneID(id int) *ArticleUpdateOne

UpdateOneID returns an update builder for the given id.

func (*ArticleClient) Use

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

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

type ArticleCreate

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

ArticleCreate is the builder for creating a Article entity.

func (*ArticleCreate) Exec

func (ac *ArticleCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*ArticleCreate) ExecX

func (ac *ArticleCreate) ExecX(ctx context.Context)

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

func (*ArticleCreate) Mutation

func (ac *ArticleCreate) Mutation() *ArticleMutation

Mutation returns the ArticleMutation object of the builder.

func (*ArticleCreate) Save

func (ac *ArticleCreate) Save(ctx context.Context) (*Article, error)

Save creates the Article in the database.

func (*ArticleCreate) SaveX

func (ac *ArticleCreate) SaveX(ctx context.Context) *Article

SaveX calls Save and panics if Save returns an error.

func (*ArticleCreate) SetNillableOwnerID

func (ac *ArticleCreate) SetNillableOwnerID(id *int) *ArticleCreate

SetNillableOwnerID sets the "owner" edge to the ArticleHistory entity by ID if the given value is not nil.

func (*ArticleCreate) SetOwner

func (ac *ArticleCreate) SetOwner(a *ArticleHistory) *ArticleCreate

SetOwner sets the "owner" edge to the ArticleHistory entity.

func (*ArticleCreate) SetOwnerID

func (ac *ArticleCreate) SetOwnerID(id int) *ArticleCreate

SetOwnerID sets the "owner" edge to the ArticleHistory entity by ID.

func (*ArticleCreate) SetTitle

func (ac *ArticleCreate) SetTitle(s string) *ArticleCreate

SetTitle sets the "title" field.

func (*ArticleCreate) SetURL

func (ac *ArticleCreate) SetURL(s string) *ArticleCreate

SetURL sets the "url" field.

type ArticleCreateBulk

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

ArticleCreateBulk is the builder for creating many Article entities in bulk.

func (*ArticleCreateBulk) Exec

func (acb *ArticleCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*ArticleCreateBulk) ExecX

func (acb *ArticleCreateBulk) ExecX(ctx context.Context)

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

func (*ArticleCreateBulk) Save

func (acb *ArticleCreateBulk) Save(ctx context.Context) ([]*Article, error)

Save creates the Article entities in the database.

func (*ArticleCreateBulk) SaveX

func (acb *ArticleCreateBulk) SaveX(ctx context.Context) []*Article

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

type ArticleDelete

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

ArticleDelete is the builder for deleting a Article entity.

func (*ArticleDelete) Exec

func (ad *ArticleDelete) Exec(ctx context.Context) (int, error)

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

func (*ArticleDelete) ExecX

func (ad *ArticleDelete) ExecX(ctx context.Context) int

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

func (*ArticleDelete) Where

func (ad *ArticleDelete) Where(ps ...predicate.Article) *ArticleDelete

Where appends a list predicates to the ArticleDelete builder.

type ArticleDeleteOne

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

ArticleDeleteOne is the builder for deleting a single Article entity.

func (*ArticleDeleteOne) Exec

func (ado *ArticleDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*ArticleDeleteOne) ExecX

func (ado *ArticleDeleteOne) ExecX(ctx context.Context)

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

func (*ArticleDeleteOne) Where

Where appends a list predicates to the ArticleDelete builder.

type ArticleEdges

type ArticleEdges struct {
	// Owner holds the value of the owner edge.
	Owner *ArticleHistory `json:"owner,omitempty"`
	// contains filtered or unexported fields
}

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

func (ArticleEdges) OwnerOrErr

func (e ArticleEdges) OwnerOrErr() (*ArticleHistory, error)

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

type ArticleGroupBy

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

ArticleGroupBy is the group-by builder for Article entities.

func (*ArticleGroupBy) Aggregate

func (agb *ArticleGroupBy) Aggregate(fns ...AggregateFunc) *ArticleGroupBy

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

func (*ArticleGroupBy) Bool

func (s *ArticleGroupBy) Bool(ctx context.Context) (_ bool, err error)

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

func (*ArticleGroupBy) BoolX

func (s *ArticleGroupBy) BoolX(ctx context.Context) bool

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

func (*ArticleGroupBy) Bools

func (s *ArticleGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*ArticleGroupBy) BoolsX

func (s *ArticleGroupBy) BoolsX(ctx context.Context) []bool

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

func (*ArticleGroupBy) Float64

func (s *ArticleGroupBy) Float64(ctx context.Context) (_ float64, err error)

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

func (*ArticleGroupBy) Float64X

func (s *ArticleGroupBy) Float64X(ctx context.Context) float64

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

func (*ArticleGroupBy) Float64s

func (s *ArticleGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*ArticleGroupBy) Float64sX

func (s *ArticleGroupBy) Float64sX(ctx context.Context) []float64

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

func (*ArticleGroupBy) Int

func (s *ArticleGroupBy) Int(ctx context.Context) (_ int, err error)

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

func (*ArticleGroupBy) IntX

func (s *ArticleGroupBy) IntX(ctx context.Context) int

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

func (*ArticleGroupBy) Ints

func (s *ArticleGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*ArticleGroupBy) IntsX

func (s *ArticleGroupBy) IntsX(ctx context.Context) []int

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

func (*ArticleGroupBy) Scan

func (agb *ArticleGroupBy) Scan(ctx context.Context, v any) error

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

func (*ArticleGroupBy) ScanX

func (s *ArticleGroupBy) ScanX(ctx context.Context, v any)

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

func (*ArticleGroupBy) String

func (s *ArticleGroupBy) String(ctx context.Context) (_ string, err error)

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

func (*ArticleGroupBy) StringX

func (s *ArticleGroupBy) StringX(ctx context.Context) string

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

func (*ArticleGroupBy) Strings

func (s *ArticleGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*ArticleGroupBy) StringsX

func (s *ArticleGroupBy) StringsX(ctx context.Context) []string

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

type ArticleHistories

type ArticleHistories []*ArticleHistory

ArticleHistories is a parsable slice of ArticleHistory.

type ArticleHistory

type ArticleHistory struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the ArticleHistoryQuery when eager-loading is set.
	Edges ArticleHistoryEdges `json:"edges"`
	// contains filtered or unexported fields
}

ArticleHistory is the model entity for the ArticleHistory schema.

func (*ArticleHistory) QueryArticle

func (ah *ArticleHistory) QueryArticle() *ArticleQuery

QueryArticle queries the "article" edge of the ArticleHistory entity.

func (*ArticleHistory) String

func (ah *ArticleHistory) String() string

String implements the fmt.Stringer.

func (*ArticleHistory) Unwrap

func (ah *ArticleHistory) Unwrap() *ArticleHistory

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

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

func (*ArticleHistory) Value

func (ah *ArticleHistory) Value(name string) (ent.Value, error)

Value returns the ent.Value that was dynamically selected and assigned to the ArticleHistory. This includes values selected through modifiers, order, etc.

type ArticleHistoryClient

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

ArticleHistoryClient is a client for the ArticleHistory schema.

func NewArticleHistoryClient

func NewArticleHistoryClient(c config) *ArticleHistoryClient

NewArticleHistoryClient returns a client for the ArticleHistory from the given config.

func (*ArticleHistoryClient) Create

Create returns a builder for creating a ArticleHistory entity.

func (*ArticleHistoryClient) CreateBulk

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

func (*ArticleHistoryClient) Delete

Delete returns a delete builder for ArticleHistory.

func (*ArticleHistoryClient) DeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*ArticleHistoryClient) DeleteOneID

func (c *ArticleHistoryClient) DeleteOneID(id int) *ArticleHistoryDeleteOne

DeleteOneID returns a builder for deleting the given entity by its id.

func (*ArticleHistoryClient) Get

Get returns a ArticleHistory entity by its id.

func (*ArticleHistoryClient) GetX

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

func (*ArticleHistoryClient) Hooks

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

Hooks returns the client hooks.

func (*ArticleHistoryClient) Intercept

func (c *ArticleHistoryClient) Intercept(interceptors ...Interceptor)

Intercept adds a list of query interceptors to the interceptors stack. A call to `Intercept(f, g, h)` equals to `articlehistory.Intercept(f(g(h())))`.

func (*ArticleHistoryClient) Interceptors

func (c *ArticleHistoryClient) Interceptors() []Interceptor

Interceptors returns the client interceptors.

func (*ArticleHistoryClient) MapCreateBulk

func (c *ArticleHistoryClient) MapCreateBulk(slice any, setFunc func(*ArticleHistoryCreate, int)) *ArticleHistoryCreateBulk

MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.

func (*ArticleHistoryClient) Query

Query returns a query builder for ArticleHistory.

func (*ArticleHistoryClient) QueryArticle

func (c *ArticleHistoryClient) QueryArticle(ah *ArticleHistory) *ArticleQuery

QueryArticle queries the article edge of a ArticleHistory.

func (*ArticleHistoryClient) Update

Update returns an update builder for ArticleHistory.

func (*ArticleHistoryClient) UpdateOne

UpdateOne returns an update builder for the given entity.

func (*ArticleHistoryClient) UpdateOneID

func (c *ArticleHistoryClient) UpdateOneID(id int) *ArticleHistoryUpdateOne

UpdateOneID returns an update builder for the given id.

func (*ArticleHistoryClient) Use

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

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

type ArticleHistoryCreate

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

ArticleHistoryCreate is the builder for creating a ArticleHistory entity.

func (*ArticleHistoryCreate) AddArticle

func (ahc *ArticleHistoryCreate) AddArticle(a ...*Article) *ArticleHistoryCreate

AddArticle adds the "article" edges to the Article entity.

func (*ArticleHistoryCreate) AddArticleIDs

func (ahc *ArticleHistoryCreate) AddArticleIDs(ids ...int) *ArticleHistoryCreate

AddArticleIDs adds the "article" edge to the Article entity by IDs.

func (*ArticleHistoryCreate) Exec

func (ahc *ArticleHistoryCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*ArticleHistoryCreate) ExecX

func (ahc *ArticleHistoryCreate) ExecX(ctx context.Context)

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

func (*ArticleHistoryCreate) Mutation

Mutation returns the ArticleHistoryMutation object of the builder.

func (*ArticleHistoryCreate) Save

Save creates the ArticleHistory in the database.

func (*ArticleHistoryCreate) SaveX

SaveX calls Save and panics if Save returns an error.

func (*ArticleHistoryCreate) SetCreatedAt

func (ahc *ArticleHistoryCreate) SetCreatedAt(t time.Time) *ArticleHistoryCreate

SetCreatedAt sets the "created_at" field.

type ArticleHistoryCreateBulk

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

ArticleHistoryCreateBulk is the builder for creating many ArticleHistory entities in bulk.

func (*ArticleHistoryCreateBulk) Exec

Exec executes the query.

func (*ArticleHistoryCreateBulk) ExecX

func (ahcb *ArticleHistoryCreateBulk) ExecX(ctx context.Context)

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

func (*ArticleHistoryCreateBulk) Save

Save creates the ArticleHistory entities in the database.

func (*ArticleHistoryCreateBulk) SaveX

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

type ArticleHistoryDelete

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

ArticleHistoryDelete is the builder for deleting a ArticleHistory entity.

func (*ArticleHistoryDelete) Exec

func (ahd *ArticleHistoryDelete) Exec(ctx context.Context) (int, error)

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

func (*ArticleHistoryDelete) ExecX

func (ahd *ArticleHistoryDelete) ExecX(ctx context.Context) int

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

func (*ArticleHistoryDelete) Where

Where appends a list predicates to the ArticleHistoryDelete builder.

type ArticleHistoryDeleteOne

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

ArticleHistoryDeleteOne is the builder for deleting a single ArticleHistory entity.

func (*ArticleHistoryDeleteOne) Exec

func (ahdo *ArticleHistoryDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*ArticleHistoryDeleteOne) ExecX

func (ahdo *ArticleHistoryDeleteOne) ExecX(ctx context.Context)

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

func (*ArticleHistoryDeleteOne) Where

Where appends a list predicates to the ArticleHistoryDelete builder.

type ArticleHistoryEdges

type ArticleHistoryEdges struct {
	// Article holds the value of the article edge.
	Article []*Article `json:"article,omitempty"`
	// contains filtered or unexported fields
}

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

func (ArticleHistoryEdges) ArticleOrErr

func (e ArticleHistoryEdges) ArticleOrErr() ([]*Article, error)

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

type ArticleHistoryGroupBy

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

ArticleHistoryGroupBy is the group-by builder for ArticleHistory entities.

func (*ArticleHistoryGroupBy) Aggregate

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

func (*ArticleHistoryGroupBy) Bool

func (s *ArticleHistoryGroupBy) Bool(ctx context.Context) (_ bool, err error)

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

func (*ArticleHistoryGroupBy) BoolX

func (s *ArticleHistoryGroupBy) BoolX(ctx context.Context) bool

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

func (*ArticleHistoryGroupBy) Bools

func (s *ArticleHistoryGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*ArticleHistoryGroupBy) BoolsX

func (s *ArticleHistoryGroupBy) BoolsX(ctx context.Context) []bool

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

func (*ArticleHistoryGroupBy) Float64

func (s *ArticleHistoryGroupBy) Float64(ctx context.Context) (_ float64, err error)

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

func (*ArticleHistoryGroupBy) Float64X

func (s *ArticleHistoryGroupBy) Float64X(ctx context.Context) float64

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

func (*ArticleHistoryGroupBy) Float64s

func (s *ArticleHistoryGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*ArticleHistoryGroupBy) Float64sX

func (s *ArticleHistoryGroupBy) Float64sX(ctx context.Context) []float64

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

func (*ArticleHistoryGroupBy) Int

func (s *ArticleHistoryGroupBy) Int(ctx context.Context) (_ int, err error)

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

func (*ArticleHistoryGroupBy) IntX

func (s *ArticleHistoryGroupBy) IntX(ctx context.Context) int

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

func (*ArticleHistoryGroupBy) Ints

func (s *ArticleHistoryGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*ArticleHistoryGroupBy) IntsX

func (s *ArticleHistoryGroupBy) IntsX(ctx context.Context) []int

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

func (*ArticleHistoryGroupBy) Scan

func (ahgb *ArticleHistoryGroupBy) Scan(ctx context.Context, v any) error

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

func (*ArticleHistoryGroupBy) ScanX

func (s *ArticleHistoryGroupBy) ScanX(ctx context.Context, v any)

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

func (*ArticleHistoryGroupBy) String

func (s *ArticleHistoryGroupBy) String(ctx context.Context) (_ string, err error)

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

func (*ArticleHistoryGroupBy) StringX

func (s *ArticleHistoryGroupBy) StringX(ctx context.Context) string

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

func (*ArticleHistoryGroupBy) Strings

func (s *ArticleHistoryGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*ArticleHistoryGroupBy) StringsX

func (s *ArticleHistoryGroupBy) StringsX(ctx context.Context) []string

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

type ArticleHistoryMutation

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

ArticleHistoryMutation represents an operation that mutates the ArticleHistory nodes in the graph.

func (*ArticleHistoryMutation) AddArticleIDs

func (m *ArticleHistoryMutation) AddArticleIDs(ids ...int)

AddArticleIDs adds the "article" edge to the Article entity by ids.

func (*ArticleHistoryMutation) AddField

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

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

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

func (*ArticleHistoryMutation) AddedField

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

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

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

func (*ArticleHistoryMutation) AddedIDs

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

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

func (*ArticleHistoryMutation) ArticleCleared

func (m *ArticleHistoryMutation) ArticleCleared() bool

ArticleCleared reports if the "article" edge to the Article entity was cleared.

func (*ArticleHistoryMutation) ArticleIDs

func (m *ArticleHistoryMutation) ArticleIDs() (ids []int)

ArticleIDs returns the "article" edge IDs in the mutation.

func (*ArticleHistoryMutation) ClearArticle

func (m *ArticleHistoryMutation) ClearArticle()

ClearArticle clears the "article" edge to the Article entity.

func (*ArticleHistoryMutation) ClearEdge

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

func (m *ArticleHistoryMutation) 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 (*ArticleHistoryMutation) ClearedEdges

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

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

func (*ArticleHistoryMutation) ClearedFields

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

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

func (ArticleHistoryMutation) Client

func (m ArticleHistoryMutation) 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 (*ArticleHistoryMutation) CreatedAt

func (m *ArticleHistoryMutation) CreatedAt() (r time.Time, exists bool)

CreatedAt returns the value of the "created_at" field in the mutation.

func (*ArticleHistoryMutation) EdgeCleared

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

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

func (*ArticleHistoryMutation) Field

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

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

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

func (*ArticleHistoryMutation) Fields

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

func (m *ArticleHistoryMutation) ID() (id int, exists bool)

ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder or after it was returned from the database.

func (*ArticleHistoryMutation) IDs

func (m *ArticleHistoryMutation) IDs(ctx context.Context) ([]int, error)

IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.

func (*ArticleHistoryMutation) OldCreatedAt

func (m *ArticleHistoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error)

OldCreatedAt returns the old "created_at" field's value of the ArticleHistory entity. If the ArticleHistory 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 (*ArticleHistoryMutation) OldField

func (m *ArticleHistoryMutation) 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 (*ArticleHistoryMutation) Op

func (m *ArticleHistoryMutation) Op() Op

Op returns the operation name.

func (*ArticleHistoryMutation) RemoveArticleIDs

func (m *ArticleHistoryMutation) RemoveArticleIDs(ids ...int)

RemoveArticleIDs removes the "article" edge to the Article entity by IDs.

func (*ArticleHistoryMutation) RemovedArticleIDs

func (m *ArticleHistoryMutation) RemovedArticleIDs() (ids []int)

RemovedArticle returns the removed IDs of the "article" edge to the Article entity.

func (*ArticleHistoryMutation) RemovedEdges

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

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

func (*ArticleHistoryMutation) RemovedIDs

func (m *ArticleHistoryMutation) 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 (*ArticleHistoryMutation) ResetArticle

func (m *ArticleHistoryMutation) ResetArticle()

ResetArticle resets all changes to the "article" edge.

func (*ArticleHistoryMutation) ResetCreatedAt

func (m *ArticleHistoryMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*ArticleHistoryMutation) ResetEdge

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

func (m *ArticleHistoryMutation) 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 (*ArticleHistoryMutation) SetCreatedAt

func (m *ArticleHistoryMutation) SetCreatedAt(t time.Time)

SetCreatedAt sets the "created_at" field.

func (*ArticleHistoryMutation) SetField

func (m *ArticleHistoryMutation) 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 (*ArticleHistoryMutation) SetOp

func (m *ArticleHistoryMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (ArticleHistoryMutation) Tx

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

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

func (*ArticleHistoryMutation) Type

func (m *ArticleHistoryMutation) Type() string

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

func (*ArticleHistoryMutation) Where

Where appends a list predicates to the ArticleHistoryMutation builder.

func (*ArticleHistoryMutation) WhereP

func (m *ArticleHistoryMutation) WhereP(ps ...func(*sql.Selector))

WhereP appends storage-level predicates to the ArticleHistoryMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.

type ArticleHistoryQuery

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

ArticleHistoryQuery is the builder for querying ArticleHistory entities.

func (*ArticleHistoryQuery) Aggregate

func (ahq *ArticleHistoryQuery) Aggregate(fns ...AggregateFunc) *ArticleHistorySelect

Aggregate returns a ArticleHistorySelect configured with the given aggregations.

func (*ArticleHistoryQuery) All

All executes the query and returns a list of ArticleHistories.

func (*ArticleHistoryQuery) AllX

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

func (*ArticleHistoryQuery) Clone

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

func (*ArticleHistoryQuery) Count

func (ahq *ArticleHistoryQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*ArticleHistoryQuery) CountX

func (ahq *ArticleHistoryQuery) CountX(ctx context.Context) int

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

func (*ArticleHistoryQuery) Exist

func (ahq *ArticleHistoryQuery) Exist(ctx context.Context) (bool, error)

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

func (*ArticleHistoryQuery) ExistX

func (ahq *ArticleHistoryQuery) ExistX(ctx context.Context) bool

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

func (*ArticleHistoryQuery) First

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

func (*ArticleHistoryQuery) FirstID

func (ahq *ArticleHistoryQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*ArticleHistoryQuery) FirstIDX

func (ahq *ArticleHistoryQuery) FirstIDX(ctx context.Context) int

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

func (*ArticleHistoryQuery) FirstX

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

func (*ArticleHistoryQuery) GroupBy

func (ahq *ArticleHistoryQuery) GroupBy(field string, fields ...string) *ArticleHistoryGroupBy

GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.

Example:

var v []struct {
	CreatedAt time.Time `json:"created_at,omitempty"`
	Count int `json:"count,omitempty"`
}

client.ArticleHistory.Query().
	GroupBy(articlehistory.FieldCreatedAt).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*ArticleHistoryQuery) IDs

func (ahq *ArticleHistoryQuery) IDs(ctx context.Context) (ids []int, err error)

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

func (*ArticleHistoryQuery) IDsX

func (ahq *ArticleHistoryQuery) IDsX(ctx context.Context) []int

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

func (*ArticleHistoryQuery) Limit

func (ahq *ArticleHistoryQuery) Limit(limit int) *ArticleHistoryQuery

Limit the number of records to be returned by this query.

func (*ArticleHistoryQuery) Offset

func (ahq *ArticleHistoryQuery) Offset(offset int) *ArticleHistoryQuery

Offset to start from.

func (*ArticleHistoryQuery) Only

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

func (*ArticleHistoryQuery) OnlyID

func (ahq *ArticleHistoryQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*ArticleHistoryQuery) OnlyIDX

func (ahq *ArticleHistoryQuery) OnlyIDX(ctx context.Context) int

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

func (*ArticleHistoryQuery) OnlyX

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

func (*ArticleHistoryQuery) Order

Order specifies how the records should be ordered.

func (*ArticleHistoryQuery) QueryArticle

func (ahq *ArticleHistoryQuery) QueryArticle() *ArticleQuery

QueryArticle chains the current query on the "article" edge.

func (*ArticleHistoryQuery) Select

func (ahq *ArticleHistoryQuery) Select(fields ...string) *ArticleHistorySelect

Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.

Example:

var v []struct {
	CreatedAt time.Time `json:"created_at,omitempty"`
}

client.ArticleHistory.Query().
	Select(articlehistory.FieldCreatedAt).
	Scan(ctx, &v)

func (*ArticleHistoryQuery) Unique

func (ahq *ArticleHistoryQuery) Unique(unique bool) *ArticleHistoryQuery

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 (*ArticleHistoryQuery) Where

Where adds a new predicate for the ArticleHistoryQuery builder.

func (*ArticleHistoryQuery) WithArticle

func (ahq *ArticleHistoryQuery) WithArticle(opts ...func(*ArticleQuery)) *ArticleHistoryQuery

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

type ArticleHistorySelect

type ArticleHistorySelect struct {
	*ArticleHistoryQuery
	// contains filtered or unexported fields
}

ArticleHistorySelect is the builder for selecting fields of ArticleHistory entities.

func (*ArticleHistorySelect) Aggregate

Aggregate adds the given aggregation functions to the selector query.

func (*ArticleHistorySelect) Bool

func (s *ArticleHistorySelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*ArticleHistorySelect) BoolX

func (s *ArticleHistorySelect) BoolX(ctx context.Context) bool

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

func (*ArticleHistorySelect) Bools

func (s *ArticleHistorySelect) Bools(ctx context.Context) ([]bool, error)

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

func (*ArticleHistorySelect) BoolsX

func (s *ArticleHistorySelect) BoolsX(ctx context.Context) []bool

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

func (*ArticleHistorySelect) Float64

func (s *ArticleHistorySelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*ArticleHistorySelect) Float64X

func (s *ArticleHistorySelect) Float64X(ctx context.Context) float64

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

func (*ArticleHistorySelect) Float64s

func (s *ArticleHistorySelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*ArticleHistorySelect) Float64sX

func (s *ArticleHistorySelect) Float64sX(ctx context.Context) []float64

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

func (*ArticleHistorySelect) Int

func (s *ArticleHistorySelect) Int(ctx context.Context) (_ int, err error)

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

func (*ArticleHistorySelect) IntX

func (s *ArticleHistorySelect) IntX(ctx context.Context) int

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

func (*ArticleHistorySelect) Ints

func (s *ArticleHistorySelect) Ints(ctx context.Context) ([]int, error)

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

func (*ArticleHistorySelect) IntsX

func (s *ArticleHistorySelect) IntsX(ctx context.Context) []int

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

func (*ArticleHistorySelect) Scan

func (ahs *ArticleHistorySelect) Scan(ctx context.Context, v any) error

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

func (*ArticleHistorySelect) ScanX

func (s *ArticleHistorySelect) ScanX(ctx context.Context, v any)

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

func (*ArticleHistorySelect) String

func (s *ArticleHistorySelect) String(ctx context.Context) (_ string, err error)

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

func (*ArticleHistorySelect) StringX

func (s *ArticleHistorySelect) StringX(ctx context.Context) string

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

func (*ArticleHistorySelect) Strings

func (s *ArticleHistorySelect) Strings(ctx context.Context) ([]string, error)

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

func (*ArticleHistorySelect) StringsX

func (s *ArticleHistorySelect) StringsX(ctx context.Context) []string

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

type ArticleHistoryUpdate

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

ArticleHistoryUpdate is the builder for updating ArticleHistory entities.

func (*ArticleHistoryUpdate) AddArticle

func (ahu *ArticleHistoryUpdate) AddArticle(a ...*Article) *ArticleHistoryUpdate

AddArticle adds the "article" edges to the Article entity.

func (*ArticleHistoryUpdate) AddArticleIDs

func (ahu *ArticleHistoryUpdate) AddArticleIDs(ids ...int) *ArticleHistoryUpdate

AddArticleIDs adds the "article" edge to the Article entity by IDs.

func (*ArticleHistoryUpdate) ClearArticle

func (ahu *ArticleHistoryUpdate) ClearArticle() *ArticleHistoryUpdate

ClearArticle clears all "article" edges to the Article entity.

func (*ArticleHistoryUpdate) Exec

func (ahu *ArticleHistoryUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*ArticleHistoryUpdate) ExecX

func (ahu *ArticleHistoryUpdate) ExecX(ctx context.Context)

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

func (*ArticleHistoryUpdate) Mutation

Mutation returns the ArticleHistoryMutation object of the builder.

func (*ArticleHistoryUpdate) RemoveArticle

func (ahu *ArticleHistoryUpdate) RemoveArticle(a ...*Article) *ArticleHistoryUpdate

RemoveArticle removes "article" edges to Article entities.

func (*ArticleHistoryUpdate) RemoveArticleIDs

func (ahu *ArticleHistoryUpdate) RemoveArticleIDs(ids ...int) *ArticleHistoryUpdate

RemoveArticleIDs removes the "article" edge to Article entities by IDs.

func (*ArticleHistoryUpdate) Save

func (ahu *ArticleHistoryUpdate) Save(ctx context.Context) (int, error)

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

func (*ArticleHistoryUpdate) SaveX

func (ahu *ArticleHistoryUpdate) SaveX(ctx context.Context) int

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

func (*ArticleHistoryUpdate) SetCreatedAt

func (ahu *ArticleHistoryUpdate) SetCreatedAt(t time.Time) *ArticleHistoryUpdate

SetCreatedAt sets the "created_at" field.

func (*ArticleHistoryUpdate) SetNillableCreatedAt

func (ahu *ArticleHistoryUpdate) SetNillableCreatedAt(t *time.Time) *ArticleHistoryUpdate

SetNillableCreatedAt sets the "created_at" field if the given value is not nil.

func (*ArticleHistoryUpdate) Where

Where appends a list predicates to the ArticleHistoryUpdate builder.

type ArticleHistoryUpdateOne

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

ArticleHistoryUpdateOne is the builder for updating a single ArticleHistory entity.

func (*ArticleHistoryUpdateOne) AddArticle

func (ahuo *ArticleHistoryUpdateOne) AddArticle(a ...*Article) *ArticleHistoryUpdateOne

AddArticle adds the "article" edges to the Article entity.

func (*ArticleHistoryUpdateOne) AddArticleIDs

func (ahuo *ArticleHistoryUpdateOne) AddArticleIDs(ids ...int) *ArticleHistoryUpdateOne

AddArticleIDs adds the "article" edge to the Article entity by IDs.

func (*ArticleHistoryUpdateOne) ClearArticle

func (ahuo *ArticleHistoryUpdateOne) ClearArticle() *ArticleHistoryUpdateOne

ClearArticle clears all "article" edges to the Article entity.

func (*ArticleHistoryUpdateOne) Exec

func (ahuo *ArticleHistoryUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*ArticleHistoryUpdateOne) ExecX

func (ahuo *ArticleHistoryUpdateOne) ExecX(ctx context.Context)

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

func (*ArticleHistoryUpdateOne) Mutation

Mutation returns the ArticleHistoryMutation object of the builder.

func (*ArticleHistoryUpdateOne) RemoveArticle

func (ahuo *ArticleHistoryUpdateOne) RemoveArticle(a ...*Article) *ArticleHistoryUpdateOne

RemoveArticle removes "article" edges to Article entities.

func (*ArticleHistoryUpdateOne) RemoveArticleIDs

func (ahuo *ArticleHistoryUpdateOne) RemoveArticleIDs(ids ...int) *ArticleHistoryUpdateOne

RemoveArticleIDs removes the "article" edge to Article entities by IDs.

func (*ArticleHistoryUpdateOne) Save

Save executes the query and returns the updated ArticleHistory entity.

func (*ArticleHistoryUpdateOne) SaveX

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

func (*ArticleHistoryUpdateOne) Select

func (ahuo *ArticleHistoryUpdateOne) Select(field string, fields ...string) *ArticleHistoryUpdateOne

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

func (*ArticleHistoryUpdateOne) SetCreatedAt

SetCreatedAt sets the "created_at" field.

func (*ArticleHistoryUpdateOne) SetNillableCreatedAt

func (ahuo *ArticleHistoryUpdateOne) SetNillableCreatedAt(t *time.Time) *ArticleHistoryUpdateOne

SetNillableCreatedAt sets the "created_at" field if the given value is not nil.

func (*ArticleHistoryUpdateOne) Where

Where appends a list predicates to the ArticleHistoryUpdate builder.

type ArticleMutation

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

ArticleMutation represents an operation that mutates the Article nodes in the graph.

func (*ArticleMutation) AddField

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

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

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

func (*ArticleMutation) AddedField

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

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

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

func (*ArticleMutation) AddedIDs

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

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

func (*ArticleMutation) ClearEdge

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

func (m *ArticleMutation) 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 (*ArticleMutation) ClearOwner

func (m *ArticleMutation) ClearOwner()

ClearOwner clears the "owner" edge to the ArticleHistory entity.

func (*ArticleMutation) ClearedEdges

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

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

func (*ArticleMutation) ClearedFields

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

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

func (ArticleMutation) Client

func (m ArticleMutation) 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 (*ArticleMutation) EdgeCleared

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

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

func (*ArticleMutation) Field

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

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

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

func (*ArticleMutation) Fields

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

func (m *ArticleMutation) ID() (id int, exists bool)

ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder or after it was returned from the database.

func (*ArticleMutation) IDs

func (m *ArticleMutation) IDs(ctx context.Context) ([]int, error)

IDs queries the database and returns the entity ids that match the mutation's predicate. That means, if the mutation is applied within a transaction with an isolation level such as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated or updated by the mutation.

func (*ArticleMutation) OldField

func (m *ArticleMutation) 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 (*ArticleMutation) OldTitle

func (m *ArticleMutation) OldTitle(ctx context.Context) (v string, err error)

OldTitle returns the old "title" field's value of the Article entity. If the Article 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 (*ArticleMutation) OldURL

func (m *ArticleMutation) OldURL(ctx context.Context) (v string, err error)

OldURL returns the old "url" field's value of the Article entity. If the Article 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 (*ArticleMutation) Op

func (m *ArticleMutation) Op() Op

Op returns the operation name.

func (*ArticleMutation) OwnerCleared

func (m *ArticleMutation) OwnerCleared() bool

OwnerCleared reports if the "owner" edge to the ArticleHistory entity was cleared.

func (*ArticleMutation) OwnerID

func (m *ArticleMutation) OwnerID() (id int, exists bool)

OwnerID returns the "owner" edge ID in the mutation.

func (*ArticleMutation) OwnerIDs

func (m *ArticleMutation) OwnerIDs() (ids []int)

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

func (*ArticleMutation) RemovedEdges

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

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

func (*ArticleMutation) RemovedIDs

func (m *ArticleMutation) 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 (*ArticleMutation) ResetEdge

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

func (m *ArticleMutation) 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 (*ArticleMutation) ResetOwner

func (m *ArticleMutation) ResetOwner()

ResetOwner resets all changes to the "owner" edge.

func (*ArticleMutation) ResetTitle

func (m *ArticleMutation) ResetTitle()

ResetTitle resets all changes to the "title" field.

func (*ArticleMutation) ResetURL

func (m *ArticleMutation) ResetURL()

ResetURL resets all changes to the "url" field.

func (*ArticleMutation) SetField

func (m *ArticleMutation) 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 (*ArticleMutation) SetOp

func (m *ArticleMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*ArticleMutation) SetOwnerID

func (m *ArticleMutation) SetOwnerID(id int)

SetOwnerID sets the "owner" edge to the ArticleHistory entity by id.

func (*ArticleMutation) SetTitle

func (m *ArticleMutation) SetTitle(s string)

SetTitle sets the "title" field.

func (*ArticleMutation) SetURL

func (m *ArticleMutation) SetURL(s string)

SetURL sets the "url" field.

func (*ArticleMutation) Title

func (m *ArticleMutation) Title() (r string, exists bool)

Title returns the value of the "title" field in the mutation.

func (ArticleMutation) Tx

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

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

func (*ArticleMutation) Type

func (m *ArticleMutation) Type() string

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

func (*ArticleMutation) URL

func (m *ArticleMutation) URL() (r string, exists bool)

URL returns the value of the "url" field in the mutation.

func (*ArticleMutation) Where

func (m *ArticleMutation) Where(ps ...predicate.Article)

Where appends a list predicates to the ArticleMutation builder.

func (*ArticleMutation) WhereP

func (m *ArticleMutation) WhereP(ps ...func(*sql.Selector))

WhereP appends storage-level predicates to the ArticleMutation builder. Using this method, users can use type-assertion to append predicates that do not depend on any generated package.

type ArticleQuery

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

ArticleQuery is the builder for querying Article entities.

func (*ArticleQuery) Aggregate

func (aq *ArticleQuery) Aggregate(fns ...AggregateFunc) *ArticleSelect

Aggregate returns a ArticleSelect configured with the given aggregations.

func (*ArticleQuery) All

func (aq *ArticleQuery) All(ctx context.Context) ([]*Article, error)

All executes the query and returns a list of Articles.

func (*ArticleQuery) AllX

func (aq *ArticleQuery) AllX(ctx context.Context) []*Article

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

func (*ArticleQuery) Clone

func (aq *ArticleQuery) Clone() *ArticleQuery

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

func (*ArticleQuery) Count

func (aq *ArticleQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*ArticleQuery) CountX

func (aq *ArticleQuery) CountX(ctx context.Context) int

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

func (*ArticleQuery) Exist

func (aq *ArticleQuery) Exist(ctx context.Context) (bool, error)

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

func (*ArticleQuery) ExistX

func (aq *ArticleQuery) ExistX(ctx context.Context) bool

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

func (*ArticleQuery) First

func (aq *ArticleQuery) First(ctx context.Context) (*Article, error)

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

func (*ArticleQuery) FirstID

func (aq *ArticleQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*ArticleQuery) FirstIDX

func (aq *ArticleQuery) FirstIDX(ctx context.Context) int

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

func (*ArticleQuery) FirstX

func (aq *ArticleQuery) FirstX(ctx context.Context) *Article

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

func (*ArticleQuery) GroupBy

func (aq *ArticleQuery) GroupBy(field string, fields ...string) *ArticleGroupBy

GroupBy is used to group vertices by one or more fields/columns. It is often used with aggregate functions, like: count, max, mean, min, sum.

Example:

var v []struct {
	Title string `json:"title,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Article.Query().
	GroupBy(article.FieldTitle).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*ArticleQuery) IDs

func (aq *ArticleQuery) IDs(ctx context.Context) (ids []int, err error)

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

func (*ArticleQuery) IDsX

func (aq *ArticleQuery) IDsX(ctx context.Context) []int

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

func (*ArticleQuery) Limit

func (aq *ArticleQuery) Limit(limit int) *ArticleQuery

Limit the number of records to be returned by this query.

func (*ArticleQuery) Offset

func (aq *ArticleQuery) Offset(offset int) *ArticleQuery

Offset to start from.

func (*ArticleQuery) Only

func (aq *ArticleQuery) Only(ctx context.Context) (*Article, error)

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

func (*ArticleQuery) OnlyID

func (aq *ArticleQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*ArticleQuery) OnlyIDX

func (aq *ArticleQuery) OnlyIDX(ctx context.Context) int

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

func (*ArticleQuery) OnlyX

func (aq *ArticleQuery) OnlyX(ctx context.Context) *Article

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

func (*ArticleQuery) Order

func (aq *ArticleQuery) Order(o ...article.OrderOption) *ArticleQuery

Order specifies how the records should be ordered.

func (*ArticleQuery) QueryOwner

func (aq *ArticleQuery) QueryOwner() *ArticleHistoryQuery

QueryOwner chains the current query on the "owner" edge.

func (*ArticleQuery) Select

func (aq *ArticleQuery) Select(fields ...string) *ArticleSelect

Select allows the selection one or more fields/columns for the given query, instead of selecting all fields in the entity.

Example:

var v []struct {
	Title string `json:"title,omitempty"`
}

client.Article.Query().
	Select(article.FieldTitle).
	Scan(ctx, &v)

func (*ArticleQuery) Unique

func (aq *ArticleQuery) Unique(unique bool) *ArticleQuery

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 (*ArticleQuery) Where

func (aq *ArticleQuery) Where(ps ...predicate.Article) *ArticleQuery

Where adds a new predicate for the ArticleQuery builder.

func (*ArticleQuery) WithOwner

func (aq *ArticleQuery) WithOwner(opts ...func(*ArticleHistoryQuery)) *ArticleQuery

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

type ArticleSelect

type ArticleSelect struct {
	*ArticleQuery
	// contains filtered or unexported fields
}

ArticleSelect is the builder for selecting fields of Article entities.

func (*ArticleSelect) Aggregate

func (as *ArticleSelect) Aggregate(fns ...AggregateFunc) *ArticleSelect

Aggregate adds the given aggregation functions to the selector query.

func (*ArticleSelect) Bool

func (s *ArticleSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*ArticleSelect) BoolX

func (s *ArticleSelect) BoolX(ctx context.Context) bool

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

func (*ArticleSelect) Bools

func (s *ArticleSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*ArticleSelect) BoolsX

func (s *ArticleSelect) BoolsX(ctx context.Context) []bool

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

func (*ArticleSelect) Float64

func (s *ArticleSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*ArticleSelect) Float64X

func (s *ArticleSelect) Float64X(ctx context.Context) float64

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

func (*ArticleSelect) Float64s

func (s *ArticleSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*ArticleSelect) Float64sX

func (s *ArticleSelect) Float64sX(ctx context.Context) []float64

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

func (*ArticleSelect) Int

func (s *ArticleSelect) Int(ctx context.Context) (_ int, err error)

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

func (*ArticleSelect) IntX

func (s *ArticleSelect) IntX(ctx context.Context) int

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

func (*ArticleSelect) Ints

func (s *ArticleSelect) Ints(ctx context.Context) ([]int, error)

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

func (*ArticleSelect) IntsX

func (s *ArticleSelect) IntsX(ctx context.Context) []int

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

func (*ArticleSelect) Scan

func (as *ArticleSelect) Scan(ctx context.Context, v any) error

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

func (*ArticleSelect) ScanX

func (s *ArticleSelect) ScanX(ctx context.Context, v any)

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

func (*ArticleSelect) String

func (s *ArticleSelect) String(ctx context.Context) (_ string, err error)

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

func (*ArticleSelect) StringX

func (s *ArticleSelect) StringX(ctx context.Context) string

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

func (*ArticleSelect) Strings

func (s *ArticleSelect) Strings(ctx context.Context) ([]string, error)

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

func (*ArticleSelect) StringsX

func (s *ArticleSelect) StringsX(ctx context.Context) []string

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

type ArticleUpdate

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

ArticleUpdate is the builder for updating Article entities.

func (*ArticleUpdate) ClearOwner

func (au *ArticleUpdate) ClearOwner() *ArticleUpdate

ClearOwner clears the "owner" edge to the ArticleHistory entity.

func (*ArticleUpdate) Exec

func (au *ArticleUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*ArticleUpdate) ExecX

func (au *ArticleUpdate) ExecX(ctx context.Context)

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

func (*ArticleUpdate) Mutation

func (au *ArticleUpdate) Mutation() *ArticleMutation

Mutation returns the ArticleMutation object of the builder.

func (*ArticleUpdate) Save

func (au *ArticleUpdate) Save(ctx context.Context) (int, error)

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

func (*ArticleUpdate) SaveX

func (au *ArticleUpdate) SaveX(ctx context.Context) int

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

func (*ArticleUpdate) SetNillableOwnerID

func (au *ArticleUpdate) SetNillableOwnerID(id *int) *ArticleUpdate

SetNillableOwnerID sets the "owner" edge to the ArticleHistory entity by ID if the given value is not nil.

func (*ArticleUpdate) SetNillableTitle

func (au *ArticleUpdate) SetNillableTitle(s *string) *ArticleUpdate

SetNillableTitle sets the "title" field if the given value is not nil.

func (*ArticleUpdate) SetNillableURL

func (au *ArticleUpdate) SetNillableURL(s *string) *ArticleUpdate

SetNillableURL sets the "url" field if the given value is not nil.

func (*ArticleUpdate) SetOwner

func (au *ArticleUpdate) SetOwner(a *ArticleHistory) *ArticleUpdate

SetOwner sets the "owner" edge to the ArticleHistory entity.

func (*ArticleUpdate) SetOwnerID

func (au *ArticleUpdate) SetOwnerID(id int) *ArticleUpdate

SetOwnerID sets the "owner" edge to the ArticleHistory entity by ID.

func (*ArticleUpdate) SetTitle

func (au *ArticleUpdate) SetTitle(s string) *ArticleUpdate

SetTitle sets the "title" field.

func (*ArticleUpdate) SetURL

func (au *ArticleUpdate) SetURL(s string) *ArticleUpdate

SetURL sets the "url" field.

func (*ArticleUpdate) Where

func (au *ArticleUpdate) Where(ps ...predicate.Article) *ArticleUpdate

Where appends a list predicates to the ArticleUpdate builder.

type ArticleUpdateOne

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

ArticleUpdateOne is the builder for updating a single Article entity.

func (*ArticleUpdateOne) ClearOwner

func (auo *ArticleUpdateOne) ClearOwner() *ArticleUpdateOne

ClearOwner clears the "owner" edge to the ArticleHistory entity.

func (*ArticleUpdateOne) Exec

func (auo *ArticleUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*ArticleUpdateOne) ExecX

func (auo *ArticleUpdateOne) ExecX(ctx context.Context)

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

func (*ArticleUpdateOne) Mutation

func (auo *ArticleUpdateOne) Mutation() *ArticleMutation

Mutation returns the ArticleMutation object of the builder.

func (*ArticleUpdateOne) Save

func (auo *ArticleUpdateOne) Save(ctx context.Context) (*Article, error)

Save executes the query and returns the updated Article entity.

func (*ArticleUpdateOne) SaveX

func (auo *ArticleUpdateOne) SaveX(ctx context.Context) *Article

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

func (*ArticleUpdateOne) Select

func (auo *ArticleUpdateOne) Select(field string, fields ...string) *ArticleUpdateOne

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

func (*ArticleUpdateOne) SetNillableOwnerID

func (auo *ArticleUpdateOne) SetNillableOwnerID(id *int) *ArticleUpdateOne

SetNillableOwnerID sets the "owner" edge to the ArticleHistory entity by ID if the given value is not nil.

func (*ArticleUpdateOne) SetNillableTitle

func (auo *ArticleUpdateOne) SetNillableTitle(s *string) *ArticleUpdateOne

SetNillableTitle sets the "title" field if the given value is not nil.

func (*ArticleUpdateOne) SetNillableURL

func (auo *ArticleUpdateOne) SetNillableURL(s *string) *ArticleUpdateOne

SetNillableURL sets the "url" field if the given value is not nil.

func (*ArticleUpdateOne) SetOwner

SetOwner sets the "owner" edge to the ArticleHistory entity.

func (*ArticleUpdateOne) SetOwnerID

func (auo *ArticleUpdateOne) SetOwnerID(id int) *ArticleUpdateOne

SetOwnerID sets the "owner" edge to the ArticleHistory entity by ID.

func (*ArticleUpdateOne) SetTitle

func (auo *ArticleUpdateOne) SetTitle(s string) *ArticleUpdateOne

SetTitle sets the "title" field.

func (*ArticleUpdateOne) SetURL

func (auo *ArticleUpdateOne) SetURL(s string) *ArticleUpdateOne

SetURL sets the "url" field.

func (*ArticleUpdateOne) Where

Where appends a list predicates to the ArticleUpdate builder.

type Articles

type Articles []*Article

Articles is a parsable slice of Article.

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Article is the client for interacting with the Article builders.
	Article *ArticleClient
	// ArticleHistory is the client for interacting with the ArticleHistory builders.
	ArticleHistory *ArticleHistoryClient
	// 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 Migrate

func Migrate() *Client

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().
	Article.
	Query().
	Count(ctx)

func (*Client) Intercept

func (c *Client) Intercept(interceptors ...Interceptor)

Intercept adds the query interceptors to all the entity clients. In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.

func (*Client) Mutate

func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error)

Mutate implements the ent.Mutator interface.

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 InterceptFunc

type InterceptFunc = ent.InterceptFunc

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

type Interceptor

type Interceptor = ent.Interceptor

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

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type 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(...any)) Option

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

OrderFunc applies an ordering on the sql selector. Deprecated: Use Asc/Desc functions or the package builders instead.

type Policy

type Policy = ent.Policy

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

type Querier

type Querier = ent.Querier

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

type QuerierFunc

type QuerierFunc = ent.QuerierFunc

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 QueryContext

type QueryContext = ent.QueryContext

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 TraverseFunc

type TraverseFunc = ent.TraverseFunc

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

type Traverser

type Traverser = ent.Traverser

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

type Tx

type Tx struct {

	// Article is the client for interacting with the Article builders.
	Article *ArticleClient
	// ArticleHistory is the client for interacting with the ArticleHistory builders.
	ArticleHistory *ArticleHistoryClient
	// 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 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