ent

package
v0.0.0-...-ecf7a97 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT, MIT Imports: 20 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"
	TypeComment = "Comment"
	TypeTag     = "Tag"
)

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 validaton 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, func(string) bool) 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 int64 `json:"id,omitempty"`
	// Title holds the value of the "title" field.
	Title string `json:"title,omitempty"`
	// Content holds the value of the "content" field.
	Content string `json:"content,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,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) QueryComments

func (a *Article) QueryComments() *CommentQuery

QueryComments queries the "comments" edge of the Article entity.

func (*Article) QueryTags

func (a *Article) QueryTags() *TagQuery

QueryTags queries the "tags" 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.

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 create builder for Article.

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 delete builder for the given entity.

func (*ArticleClient) DeleteOneID

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

DeleteOneID returns a delete builder for the given id.

func (*ArticleClient) Get

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

Get returns a Article entity by its id.

func (*ArticleClient) GetX

func (c *ArticleClient) GetX(ctx context.Context, id int64) *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) Query

func (c *ArticleClient) Query() *ArticleQuery

Query returns a query builder for Article.

func (*ArticleClient) QueryComments

func (c *ArticleClient) QueryComments(a *Article) *CommentQuery

QueryComments queries the comments edge of a Article.

func (*ArticleClient) QueryTags

func (c *ArticleClient) QueryTags(a *Article) *TagQuery

QueryTags queries the tags 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 int64) *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) AddCommentIDs

func (ac *ArticleCreate) AddCommentIDs(ids ...int64) *ArticleCreate

AddCommentIDs adds the "comments" edge to the Comment entity by IDs.

func (*ArticleCreate) AddComments

func (ac *ArticleCreate) AddComments(c ...*Comment) *ArticleCreate

AddComments adds the "comments" edges to the Comment entity.

func (*ArticleCreate) AddTagIDs

func (ac *ArticleCreate) AddTagIDs(ids ...int64) *ArticleCreate

AddTagIDs adds the "tags" edge to the Tag entity by IDs.

func (*ArticleCreate) AddTags

func (ac *ArticleCreate) AddTags(t ...*Tag) *ArticleCreate

AddTags adds the "tags" edges to the Tag entity.

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

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

SetContent sets the "content" field.

func (*ArticleCreate) SetCreatedAt

func (ac *ArticleCreate) SetCreatedAt(t time.Time) *ArticleCreate

SetCreatedAt sets the "created_at" field.

func (*ArticleCreate) SetID

func (ac *ArticleCreate) SetID(i int64) *ArticleCreate

SetID sets the "id" field.

func (*ArticleCreate) SetNillableCreatedAt

func (ac *ArticleCreate) SetNillableCreatedAt(t *time.Time) *ArticleCreate

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

func (*ArticleCreate) SetNillableUpdatedAt

func (ac *ArticleCreate) SetNillableUpdatedAt(t *time.Time) *ArticleCreate

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

func (*ArticleCreate) SetTitle

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

SetTitle sets the "title" field.

func (*ArticleCreate) SetUpdatedAt

func (ac *ArticleCreate) SetUpdatedAt(t time.Time) *ArticleCreate

SetUpdatedAt sets the "updated_at" field.

type ArticleCreateBulk

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

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

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 adds a new predicate 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.

type ArticleEdges

type ArticleEdges struct {
	// Comments holds the value of the comments edge.
	Comments []*Comment `json:"comments,omitempty"`
	// Tags holds the value of the tags edge.
	Tags []*Tag `json:"tags,omitempty"`
	// contains filtered or unexported fields
}

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

func (ArticleEdges) CommentsOrErr

func (e ArticleEdges) CommentsOrErr() ([]*Comment, error)

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

func (ArticleEdges) TagsOrErr

func (e ArticleEdges) TagsOrErr() ([]*Tag, error)

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

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 (agb *ArticleGroupBy) 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 (*ArticleGroupBy) BoolX

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

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

func (*ArticleGroupBy) Bools

func (agb *ArticleGroupBy) 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 (*ArticleGroupBy) BoolsX

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

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

func (*ArticleGroupBy) Float64

func (agb *ArticleGroupBy) 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 (*ArticleGroupBy) Float64X

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

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

func (*ArticleGroupBy) Float64s

func (agb *ArticleGroupBy) 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 (*ArticleGroupBy) Float64sX

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

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

func (*ArticleGroupBy) Int

func (agb *ArticleGroupBy) 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 (*ArticleGroupBy) IntX

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

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

func (*ArticleGroupBy) Ints

func (agb *ArticleGroupBy) 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 (*ArticleGroupBy) IntsX

func (agb *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 interface{}) error

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

func (*ArticleGroupBy) ScanX

func (agb *ArticleGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*ArticleGroupBy) String

func (agb *ArticleGroupBy) 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 (*ArticleGroupBy) StringX

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

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

func (*ArticleGroupBy) Strings

func (agb *ArticleGroupBy) 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 (*ArticleGroupBy) StringsX

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

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

type ArticleMutation

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

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

func (*ArticleMutation) AddCommentIDs

func (m *ArticleMutation) AddCommentIDs(ids ...int64)

AddCommentIDs adds the "comments" edge to the Comment entity by ids.

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

func (m *ArticleMutation) AddTagIDs(ids ...int64)

AddTagIDs adds the "tags" edge to the Tag entity by ids.

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

func (m *ArticleMutation) ClearComments()

ClearComments clears the "comments" edge to the Comment entity.

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

func (m *ArticleMutation) ClearTags()

ClearTags clears the "tags" edge to the Tag 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) CommentsCleared

func (m *ArticleMutation) CommentsCleared() bool

CommentsCleared returns if the "comments" edge to the Comment entity was cleared.

func (*ArticleMutation) CommentsIDs

func (m *ArticleMutation) CommentsIDs() (ids []int64)

CommentsIDs returns the "comments" edge IDs in the mutation.

func (*ArticleMutation) Content

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

Content returns the value of the "content" field in the mutation.

func (*ArticleMutation) CreatedAt

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

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

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 int64, exists bool)

ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder.

func (*ArticleMutation) OldContent

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

OldContent returns the old "content" 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) OldCreatedAt

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

OldCreatedAt returns the old "created_at" 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) 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) OldUpdatedAt

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

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

func (m *ArticleMutation) RemoveCommentIDs(ids ...int64)

RemoveCommentIDs removes the "comments" edge to the Comment entity by IDs.

func (*ArticleMutation) RemoveTagIDs

func (m *ArticleMutation) RemoveTagIDs(ids ...int64)

RemoveTagIDs removes the "tags" edge to the Tag entity by IDs.

func (*ArticleMutation) RemovedCommentsIDs

func (m *ArticleMutation) RemovedCommentsIDs() (ids []int64)

RemovedComments returns the removed IDs of the "comments" edge to the Comment entity.

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

func (m *ArticleMutation) RemovedTagsIDs() (ids []int64)

RemovedTags returns the removed IDs of the "tags" edge to the Tag entity.

func (*ArticleMutation) ResetComments

func (m *ArticleMutation) ResetComments()

ResetComments resets all changes to the "comments" edge.

func (*ArticleMutation) ResetContent

func (m *ArticleMutation) ResetContent()

ResetContent resets all changes to the "content" field.

func (*ArticleMutation) ResetCreatedAt

func (m *ArticleMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

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

func (m *ArticleMutation) ResetTags()

ResetTags resets all changes to the "tags" edge.

func (*ArticleMutation) ResetTitle

func (m *ArticleMutation) ResetTitle()

ResetTitle resets all changes to the "title" field.

func (*ArticleMutation) ResetUpdatedAt

func (m *ArticleMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*ArticleMutation) SetContent

func (m *ArticleMutation) SetContent(s string)

SetContent sets the "content" field.

func (*ArticleMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" 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) SetID

func (m *ArticleMutation) SetID(id int64)

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

func (*ArticleMutation) SetTitle

func (m *ArticleMutation) SetTitle(s string)

SetTitle sets the "title" field.

func (*ArticleMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*ArticleMutation) TagsCleared

func (m *ArticleMutation) TagsCleared() bool

TagsCleared returns if the "tags" edge to the Tag entity was cleared.

func (*ArticleMutation) TagsIDs

func (m *ArticleMutation) TagsIDs() (ids []int64)

TagsIDs returns the "tags" edge IDs in the mutation.

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

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

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

type ArticleQuery

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

ArticleQuery is the builder for querying Article entities.

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 int64, 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) int64

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) ([]int64, error)

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

func (*ArticleQuery) IDsX

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

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

func (*ArticleQuery) Limit

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

Limit adds a limit step to the query.

func (*ArticleQuery) Offset

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

Offset adds an offset step to the query.

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 exactly one Article entity is not found. Returns a *NotFoundError when no Article entities are found.

func (*ArticleQuery) OnlyID

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

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

func (*ArticleQuery) OnlyIDX

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

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 ...OrderFunc) *ArticleQuery

Order adds an order step to the query.

func (*ArticleQuery) QueryComments

func (aq *ArticleQuery) QueryComments() *CommentQuery

QueryComments chains the current query on the "comments" edge.

func (*ArticleQuery) QueryTags

func (aq *ArticleQuery) QueryTags() *TagQuery

QueryTags chains the current query on the "tags" edge.

func (*ArticleQuery) Select

func (aq *ArticleQuery) Select(field string, 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) Where

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

Where adds a new predicate for the ArticleQuery builder.

func (*ArticleQuery) WithComments

func (aq *ArticleQuery) WithComments(opts ...func(*CommentQuery)) *ArticleQuery

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

func (*ArticleQuery) WithTags

func (aq *ArticleQuery) WithTags(opts ...func(*TagQuery)) *ArticleQuery

WithTags tells the query-builder to eager-load the nodes that are connected to the "tags" 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) Bool

func (as *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 (as *ArticleSelect) BoolX(ctx context.Context) bool

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

func (*ArticleSelect) Bools

func (as *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 (as *ArticleSelect) BoolsX(ctx context.Context) []bool

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

func (*ArticleSelect) Float64

func (as *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 (as *ArticleSelect) Float64X(ctx context.Context) float64

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

func (*ArticleSelect) Float64s

func (as *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 (as *ArticleSelect) Float64sX(ctx context.Context) []float64

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

func (*ArticleSelect) Int

func (as *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 (as *ArticleSelect) IntX(ctx context.Context) int

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

func (*ArticleSelect) Ints

func (as *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 (as *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 interface{}) error

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

func (*ArticleSelect) ScanX

func (as *ArticleSelect) ScanX(ctx context.Context, v interface{})

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

func (*ArticleSelect) String

func (as *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 (as *ArticleSelect) StringX(ctx context.Context) string

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

func (*ArticleSelect) Strings

func (as *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 (as *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) AddCommentIDs

func (au *ArticleUpdate) AddCommentIDs(ids ...int64) *ArticleUpdate

AddCommentIDs adds the "comments" edge to the Comment entity by IDs.

func (*ArticleUpdate) AddComments

func (au *ArticleUpdate) AddComments(c ...*Comment) *ArticleUpdate

AddComments adds the "comments" edges to the Comment entity.

func (*ArticleUpdate) AddTagIDs

func (au *ArticleUpdate) AddTagIDs(ids ...int64) *ArticleUpdate

AddTagIDs adds the "tags" edge to the Tag entity by IDs.

func (*ArticleUpdate) AddTags

func (au *ArticleUpdate) AddTags(t ...*Tag) *ArticleUpdate

AddTags adds the "tags" edges to the Tag entity.

func (*ArticleUpdate) ClearComments

func (au *ArticleUpdate) ClearComments() *ArticleUpdate

ClearComments clears all "comments" edges to the Comment entity.

func (*ArticleUpdate) ClearTags

func (au *ArticleUpdate) ClearTags() *ArticleUpdate

ClearTags clears all "tags" edges to the Tag 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) RemoveCommentIDs

func (au *ArticleUpdate) RemoveCommentIDs(ids ...int64) *ArticleUpdate

RemoveCommentIDs removes the "comments" edge to Comment entities by IDs.

func (*ArticleUpdate) RemoveComments

func (au *ArticleUpdate) RemoveComments(c ...*Comment) *ArticleUpdate

RemoveComments removes "comments" edges to Comment entities.

func (*ArticleUpdate) RemoveTagIDs

func (au *ArticleUpdate) RemoveTagIDs(ids ...int64) *ArticleUpdate

RemoveTagIDs removes the "tags" edge to Tag entities by IDs.

func (*ArticleUpdate) RemoveTags

func (au *ArticleUpdate) RemoveTags(t ...*Tag) *ArticleUpdate

RemoveTags removes "tags" edges to Tag entities.

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

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

SetContent sets the "content" field.

func (*ArticleUpdate) SetCreatedAt

func (au *ArticleUpdate) SetCreatedAt(t time.Time) *ArticleUpdate

SetCreatedAt sets the "created_at" field.

func (*ArticleUpdate) SetNillableCreatedAt

func (au *ArticleUpdate) SetNillableCreatedAt(t *time.Time) *ArticleUpdate

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

func (*ArticleUpdate) SetNillableUpdatedAt

func (au *ArticleUpdate) SetNillableUpdatedAt(t *time.Time) *ArticleUpdate

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

func (*ArticleUpdate) SetTitle

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

SetTitle sets the "title" field.

func (*ArticleUpdate) SetUpdatedAt

func (au *ArticleUpdate) SetUpdatedAt(t time.Time) *ArticleUpdate

SetUpdatedAt sets the "updated_at" field.

func (*ArticleUpdate) Where

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

Where adds a new predicate for 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) AddCommentIDs

func (auo *ArticleUpdateOne) AddCommentIDs(ids ...int64) *ArticleUpdateOne

AddCommentIDs adds the "comments" edge to the Comment entity by IDs.

func (*ArticleUpdateOne) AddComments

func (auo *ArticleUpdateOne) AddComments(c ...*Comment) *ArticleUpdateOne

AddComments adds the "comments" edges to the Comment entity.

func (*ArticleUpdateOne) AddTagIDs

func (auo *ArticleUpdateOne) AddTagIDs(ids ...int64) *ArticleUpdateOne

AddTagIDs adds the "tags" edge to the Tag entity by IDs.

func (*ArticleUpdateOne) AddTags

func (auo *ArticleUpdateOne) AddTags(t ...*Tag) *ArticleUpdateOne

AddTags adds the "tags" edges to the Tag entity.

func (*ArticleUpdateOne) ClearComments

func (auo *ArticleUpdateOne) ClearComments() *ArticleUpdateOne

ClearComments clears all "comments" edges to the Comment entity.

func (*ArticleUpdateOne) ClearTags

func (auo *ArticleUpdateOne) ClearTags() *ArticleUpdateOne

ClearTags clears all "tags" edges to the Tag 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) RemoveCommentIDs

func (auo *ArticleUpdateOne) RemoveCommentIDs(ids ...int64) *ArticleUpdateOne

RemoveCommentIDs removes the "comments" edge to Comment entities by IDs.

func (*ArticleUpdateOne) RemoveComments

func (auo *ArticleUpdateOne) RemoveComments(c ...*Comment) *ArticleUpdateOne

RemoveComments removes "comments" edges to Comment entities.

func (*ArticleUpdateOne) RemoveTagIDs

func (auo *ArticleUpdateOne) RemoveTagIDs(ids ...int64) *ArticleUpdateOne

RemoveTagIDs removes the "tags" edge to Tag entities by IDs.

func (*ArticleUpdateOne) RemoveTags

func (auo *ArticleUpdateOne) RemoveTags(t ...*Tag) *ArticleUpdateOne

RemoveTags removes "tags" edges to Tag entities.

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

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

SetContent sets the "content" field.

func (*ArticleUpdateOne) SetCreatedAt

func (auo *ArticleUpdateOne) SetCreatedAt(t time.Time) *ArticleUpdateOne

SetCreatedAt sets the "created_at" field.

func (*ArticleUpdateOne) SetNillableCreatedAt

func (auo *ArticleUpdateOne) SetNillableCreatedAt(t *time.Time) *ArticleUpdateOne

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

func (*ArticleUpdateOne) SetNillableUpdatedAt

func (auo *ArticleUpdateOne) SetNillableUpdatedAt(t *time.Time) *ArticleUpdateOne

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

func (*ArticleUpdateOne) SetTitle

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

SetTitle sets the "title" field.

func (*ArticleUpdateOne) SetUpdatedAt

func (auo *ArticleUpdateOne) SetUpdatedAt(t time.Time) *ArticleUpdateOne

SetUpdatedAt sets the "updated_at" field.

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
	// Comment is the client for interacting with the Comment builders.
	Comment *CommentClient
	// Tag is the client for interacting with the Tag builders.
	Tag *TagClient
	// 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().
	Article.
	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 Comment

type Comment struct {

	// ID of the ent.
	ID int64 `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Content holds the value of the "content" field.
	Content string `json:"content,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the CommentQuery when eager-loading is set.
	Edges CommentEdges `json:"edges"`
	// contains filtered or unexported fields
}

Comment is the model entity for the Comment schema.

func (*Comment) QueryPost

func (c *Comment) QueryPost() *ArticleQuery

QueryPost queries the "post" edge of the Comment entity.

func (*Comment) String

func (c *Comment) String() string

String implements the fmt.Stringer.

func (*Comment) Unwrap

func (c *Comment) Unwrap() *Comment

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

func (c *Comment) Update() *CommentUpdateOne

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

type CommentClient

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

CommentClient is a client for the Comment schema.

func NewCommentClient

func NewCommentClient(c config) *CommentClient

NewCommentClient returns a client for the Comment from the given config.

func (*CommentClient) Create

func (c *CommentClient) Create() *CommentCreate

Create returns a create builder for Comment.

func (*CommentClient) CreateBulk

func (c *CommentClient) CreateBulk(builders ...*CommentCreate) *CommentCreateBulk

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

func (*CommentClient) Delete

func (c *CommentClient) Delete() *CommentDelete

Delete returns a delete builder for Comment.

func (*CommentClient) DeleteOne

func (c *CommentClient) DeleteOne(co *Comment) *CommentDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*CommentClient) DeleteOneID

func (c *CommentClient) DeleteOneID(id int64) *CommentDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*CommentClient) Get

func (c *CommentClient) Get(ctx context.Context, id int64) (*Comment, error)

Get returns a Comment entity by its id.

func (*CommentClient) GetX

func (c *CommentClient) GetX(ctx context.Context, id int64) *Comment

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

func (*CommentClient) Hooks

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

Hooks returns the client hooks.

func (*CommentClient) Query

func (c *CommentClient) Query() *CommentQuery

Query returns a query builder for Comment.

func (*CommentClient) QueryPost

func (c *CommentClient) QueryPost(co *Comment) *ArticleQuery

QueryPost queries the post edge of a Comment.

func (*CommentClient) Update

func (c *CommentClient) Update() *CommentUpdate

Update returns an update builder for Comment.

func (*CommentClient) UpdateOne

func (c *CommentClient) UpdateOne(co *Comment) *CommentUpdateOne

UpdateOne returns an update builder for the given entity.

func (*CommentClient) UpdateOneID

func (c *CommentClient) UpdateOneID(id int64) *CommentUpdateOne

UpdateOneID returns an update builder for the given id.

func (*CommentClient) Use

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

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

type CommentCreate

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

CommentCreate is the builder for creating a Comment entity.

func (*CommentCreate) Mutation

func (cc *CommentCreate) Mutation() *CommentMutation

Mutation returns the CommentMutation object of the builder.

func (*CommentCreate) Save

func (cc *CommentCreate) Save(ctx context.Context) (*Comment, error)

Save creates the Comment in the database.

func (*CommentCreate) SaveX

func (cc *CommentCreate) SaveX(ctx context.Context) *Comment

SaveX calls Save and panics if Save returns an error.

func (*CommentCreate) SetContent

func (cc *CommentCreate) SetContent(s string) *CommentCreate

SetContent sets the "content" field.

func (*CommentCreate) SetCreatedAt

func (cc *CommentCreate) SetCreatedAt(t time.Time) *CommentCreate

SetCreatedAt sets the "created_at" field.

func (*CommentCreate) SetID

func (cc *CommentCreate) SetID(i int64) *CommentCreate

SetID sets the "id" field.

func (*CommentCreate) SetName

func (cc *CommentCreate) SetName(s string) *CommentCreate

SetName sets the "name" field.

func (*CommentCreate) SetNillableCreatedAt

func (cc *CommentCreate) SetNillableCreatedAt(t *time.Time) *CommentCreate

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

func (*CommentCreate) SetNillablePostID

func (cc *CommentCreate) SetNillablePostID(id *int64) *CommentCreate

SetNillablePostID sets the "post" edge to the Article entity by ID if the given value is not nil.

func (*CommentCreate) SetNillableUpdatedAt

func (cc *CommentCreate) SetNillableUpdatedAt(t *time.Time) *CommentCreate

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

func (*CommentCreate) SetPost

func (cc *CommentCreate) SetPost(a *Article) *CommentCreate

SetPost sets the "post" edge to the Article entity.

func (*CommentCreate) SetPostID

func (cc *CommentCreate) SetPostID(id int64) *CommentCreate

SetPostID sets the "post" edge to the Article entity by ID.

func (*CommentCreate) SetUpdatedAt

func (cc *CommentCreate) SetUpdatedAt(t time.Time) *CommentCreate

SetUpdatedAt sets the "updated_at" field.

type CommentCreateBulk

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

CommentCreateBulk is the builder for creating many Comment entities in bulk.

func (*CommentCreateBulk) Save

func (ccb *CommentCreateBulk) Save(ctx context.Context) ([]*Comment, error)

Save creates the Comment entities in the database.

func (*CommentCreateBulk) SaveX

func (ccb *CommentCreateBulk) SaveX(ctx context.Context) []*Comment

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

type CommentDelete

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

CommentDelete is the builder for deleting a Comment entity.

func (*CommentDelete) Exec

func (cd *CommentDelete) Exec(ctx context.Context) (int, error)

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

func (*CommentDelete) ExecX

func (cd *CommentDelete) ExecX(ctx context.Context) int

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

func (*CommentDelete) Where

func (cd *CommentDelete) Where(ps ...predicate.Comment) *CommentDelete

Where adds a new predicate to the CommentDelete builder.

type CommentDeleteOne

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

CommentDeleteOne is the builder for deleting a single Comment entity.

func (*CommentDeleteOne) Exec

func (cdo *CommentDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*CommentDeleteOne) ExecX

func (cdo *CommentDeleteOne) ExecX(ctx context.Context)

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

type CommentEdges

type CommentEdges struct {
	// Post holds the value of the post edge.
	Post *Article `json:"post,omitempty"`
	// contains filtered or unexported fields
}

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

func (CommentEdges) PostOrErr

func (e CommentEdges) PostOrErr() (*Article, error)

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

type CommentGroupBy

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

CommentGroupBy is the group-by builder for Comment entities.

func (*CommentGroupBy) Aggregate

func (cgb *CommentGroupBy) Aggregate(fns ...AggregateFunc) *CommentGroupBy

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

func (*CommentGroupBy) Bool

func (cgb *CommentGroupBy) 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 (*CommentGroupBy) BoolX

func (cgb *CommentGroupBy) BoolX(ctx context.Context) bool

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

func (*CommentGroupBy) Bools

func (cgb *CommentGroupBy) 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 (*CommentGroupBy) BoolsX

func (cgb *CommentGroupBy) BoolsX(ctx context.Context) []bool

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

func (*CommentGroupBy) Float64

func (cgb *CommentGroupBy) 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 (*CommentGroupBy) Float64X

func (cgb *CommentGroupBy) Float64X(ctx context.Context) float64

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

func (*CommentGroupBy) Float64s

func (cgb *CommentGroupBy) 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 (*CommentGroupBy) Float64sX

func (cgb *CommentGroupBy) Float64sX(ctx context.Context) []float64

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

func (*CommentGroupBy) Int

func (cgb *CommentGroupBy) 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 (*CommentGroupBy) IntX

func (cgb *CommentGroupBy) IntX(ctx context.Context) int

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

func (*CommentGroupBy) Ints

func (cgb *CommentGroupBy) 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 (*CommentGroupBy) IntsX

func (cgb *CommentGroupBy) IntsX(ctx context.Context) []int

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

func (*CommentGroupBy) Scan

func (cgb *CommentGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*CommentGroupBy) ScanX

func (cgb *CommentGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*CommentGroupBy) String

func (cgb *CommentGroupBy) 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 (*CommentGroupBy) StringX

func (cgb *CommentGroupBy) StringX(ctx context.Context) string

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

func (*CommentGroupBy) Strings

func (cgb *CommentGroupBy) 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 (*CommentGroupBy) StringsX

func (cgb *CommentGroupBy) StringsX(ctx context.Context) []string

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

type CommentMutation

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

CommentMutation represents an operation that mutates the Comment nodes in the graph.

func (*CommentMutation) AddField

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

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

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

func (*CommentMutation) AddedField

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

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

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

func (*CommentMutation) AddedIDs

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

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

func (*CommentMutation) ClearEdge

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

func (m *CommentMutation) 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 (*CommentMutation) ClearPost

func (m *CommentMutation) ClearPost()

ClearPost clears the "post" edge to the Article entity.

func (*CommentMutation) ClearedEdges

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

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

func (*CommentMutation) ClearedFields

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

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

func (CommentMutation) Client

func (m CommentMutation) 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 (*CommentMutation) Content

func (m *CommentMutation) Content() (r string, exists bool)

Content returns the value of the "content" field in the mutation.

func (*CommentMutation) CreatedAt

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

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

func (*CommentMutation) EdgeCleared

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

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

func (*CommentMutation) Field

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

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

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

func (*CommentMutation) Fields

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

func (m *CommentMutation) ID() (id int64, exists bool)

ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder.

func (*CommentMutation) Name

func (m *CommentMutation) Name() (r string, exists bool)

Name returns the value of the "name" field in the mutation.

func (*CommentMutation) OldContent

func (m *CommentMutation) OldContent(ctx context.Context) (v string, err error)

OldContent returns the old "content" field's value of the Comment entity. If the Comment 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 (*CommentMutation) OldCreatedAt

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

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

func (m *CommentMutation) 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 (*CommentMutation) OldName

func (m *CommentMutation) OldName(ctx context.Context) (v string, err error)

OldName returns the old "name" field's value of the Comment entity. If the Comment 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 (*CommentMutation) OldUpdatedAt

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

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

func (m *CommentMutation) Op() Op

Op returns the operation name.

func (*CommentMutation) PostCleared

func (m *CommentMutation) PostCleared() bool

PostCleared returns if the "post" edge to the Article entity was cleared.

func (*CommentMutation) PostID

func (m *CommentMutation) PostID() (id int64, exists bool)

PostID returns the "post" edge ID in the mutation.

func (*CommentMutation) PostIDs

func (m *CommentMutation) PostIDs() (ids []int64)

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

func (*CommentMutation) RemovedEdges

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

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

func (*CommentMutation) RemovedIDs

func (m *CommentMutation) 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 (*CommentMutation) ResetContent

func (m *CommentMutation) ResetContent()

ResetContent resets all changes to the "content" field.

func (*CommentMutation) ResetCreatedAt

func (m *CommentMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*CommentMutation) ResetEdge

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

func (m *CommentMutation) 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 (*CommentMutation) ResetName

func (m *CommentMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*CommentMutation) ResetPost

func (m *CommentMutation) ResetPost()

ResetPost resets all changes to the "post" edge.

func (*CommentMutation) ResetUpdatedAt

func (m *CommentMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*CommentMutation) SetContent

func (m *CommentMutation) SetContent(s string)

SetContent sets the "content" field.

func (*CommentMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*CommentMutation) SetField

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

func (m *CommentMutation) SetID(id int64)

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

func (*CommentMutation) SetName

func (m *CommentMutation) SetName(s string)

SetName sets the "name" field.

func (*CommentMutation) SetPostID

func (m *CommentMutation) SetPostID(id int64)

SetPostID sets the "post" edge to the Article entity by id.

func (*CommentMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (CommentMutation) Tx

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

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

func (*CommentMutation) Type

func (m *CommentMutation) Type() string

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

func (*CommentMutation) UpdatedAt

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

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

type CommentQuery

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

CommentQuery is the builder for querying Comment entities.

func (*CommentQuery) All

func (cq *CommentQuery) All(ctx context.Context) ([]*Comment, error)

All executes the query and returns a list of Comments.

func (*CommentQuery) AllX

func (cq *CommentQuery) AllX(ctx context.Context) []*Comment

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

func (*CommentQuery) Clone

func (cq *CommentQuery) Clone() *CommentQuery

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

func (*CommentQuery) Count

func (cq *CommentQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*CommentQuery) CountX

func (cq *CommentQuery) CountX(ctx context.Context) int

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

func (*CommentQuery) Exist

func (cq *CommentQuery) Exist(ctx context.Context) (bool, error)

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

func (*CommentQuery) ExistX

func (cq *CommentQuery) ExistX(ctx context.Context) bool

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

func (*CommentQuery) First

func (cq *CommentQuery) First(ctx context.Context) (*Comment, error)

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

func (*CommentQuery) FirstID

func (cq *CommentQuery) FirstID(ctx context.Context) (id int64, err error)

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

func (*CommentQuery) FirstIDX

func (cq *CommentQuery) FirstIDX(ctx context.Context) int64

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

func (*CommentQuery) FirstX

func (cq *CommentQuery) FirstX(ctx context.Context) *Comment

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

func (*CommentQuery) GroupBy

func (cq *CommentQuery) GroupBy(field string, fields ...string) *CommentGroupBy

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 {
	Name string `json:"name,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Comment.Query().
	GroupBy(comment.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*CommentQuery) IDs

func (cq *CommentQuery) IDs(ctx context.Context) ([]int64, error)

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

func (*CommentQuery) IDsX

func (cq *CommentQuery) IDsX(ctx context.Context) []int64

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

func (*CommentQuery) Limit

func (cq *CommentQuery) Limit(limit int) *CommentQuery

Limit adds a limit step to the query.

func (*CommentQuery) Offset

func (cq *CommentQuery) Offset(offset int) *CommentQuery

Offset adds an offset step to the query.

func (*CommentQuery) Only

func (cq *CommentQuery) Only(ctx context.Context) (*Comment, error)

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

func (*CommentQuery) OnlyID

func (cq *CommentQuery) OnlyID(ctx context.Context) (id int64, err error)

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

func (*CommentQuery) OnlyIDX

func (cq *CommentQuery) OnlyIDX(ctx context.Context) int64

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

func (*CommentQuery) OnlyX

func (cq *CommentQuery) OnlyX(ctx context.Context) *Comment

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

func (*CommentQuery) Order

func (cq *CommentQuery) Order(o ...OrderFunc) *CommentQuery

Order adds an order step to the query.

func (*CommentQuery) QueryPost

func (cq *CommentQuery) QueryPost() *ArticleQuery

QueryPost chains the current query on the "post" edge.

func (*CommentQuery) Select

func (cq *CommentQuery) Select(field string, fields ...string) *CommentSelect

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 {
	Name string `json:"name,omitempty"`
}

client.Comment.Query().
	Select(comment.FieldName).
	Scan(ctx, &v)

func (*CommentQuery) Where

func (cq *CommentQuery) Where(ps ...predicate.Comment) *CommentQuery

Where adds a new predicate for the CommentQuery builder.

func (*CommentQuery) WithPost

func (cq *CommentQuery) WithPost(opts ...func(*ArticleQuery)) *CommentQuery

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

type CommentSelect

type CommentSelect struct {
	*CommentQuery
	// contains filtered or unexported fields
}

CommentSelect is the builder for selecting fields of Comment entities.

func (*CommentSelect) Bool

func (cs *CommentSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*CommentSelect) BoolX

func (cs *CommentSelect) BoolX(ctx context.Context) bool

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

func (*CommentSelect) Bools

func (cs *CommentSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*CommentSelect) BoolsX

func (cs *CommentSelect) BoolsX(ctx context.Context) []bool

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

func (*CommentSelect) Float64

func (cs *CommentSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*CommentSelect) Float64X

func (cs *CommentSelect) Float64X(ctx context.Context) float64

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

func (*CommentSelect) Float64s

func (cs *CommentSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*CommentSelect) Float64sX

func (cs *CommentSelect) Float64sX(ctx context.Context) []float64

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

func (*CommentSelect) Int

func (cs *CommentSelect) Int(ctx context.Context) (_ int, err error)

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

func (*CommentSelect) IntX

func (cs *CommentSelect) IntX(ctx context.Context) int

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

func (*CommentSelect) Ints

func (cs *CommentSelect) Ints(ctx context.Context) ([]int, error)

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

func (*CommentSelect) IntsX

func (cs *CommentSelect) IntsX(ctx context.Context) []int

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

func (*CommentSelect) Scan

func (cs *CommentSelect) Scan(ctx context.Context, v interface{}) error

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

func (*CommentSelect) ScanX

func (cs *CommentSelect) ScanX(ctx context.Context, v interface{})

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

func (*CommentSelect) String

func (cs *CommentSelect) String(ctx context.Context) (_ string, err error)

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

func (*CommentSelect) StringX

func (cs *CommentSelect) StringX(ctx context.Context) string

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

func (*CommentSelect) Strings

func (cs *CommentSelect) Strings(ctx context.Context) ([]string, error)

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

func (*CommentSelect) StringsX

func (cs *CommentSelect) StringsX(ctx context.Context) []string

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

type CommentUpdate

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

CommentUpdate is the builder for updating Comment entities.

func (*CommentUpdate) ClearPost

func (cu *CommentUpdate) ClearPost() *CommentUpdate

ClearPost clears the "post" edge to the Article entity.

func (*CommentUpdate) Exec

func (cu *CommentUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*CommentUpdate) ExecX

func (cu *CommentUpdate) ExecX(ctx context.Context)

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

func (*CommentUpdate) Mutation

func (cu *CommentUpdate) Mutation() *CommentMutation

Mutation returns the CommentMutation object of the builder.

func (*CommentUpdate) Save

func (cu *CommentUpdate) Save(ctx context.Context) (int, error)

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

func (*CommentUpdate) SaveX

func (cu *CommentUpdate) SaveX(ctx context.Context) int

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

func (*CommentUpdate) SetContent

func (cu *CommentUpdate) SetContent(s string) *CommentUpdate

SetContent sets the "content" field.

func (*CommentUpdate) SetCreatedAt

func (cu *CommentUpdate) SetCreatedAt(t time.Time) *CommentUpdate

SetCreatedAt sets the "created_at" field.

func (*CommentUpdate) SetName

func (cu *CommentUpdate) SetName(s string) *CommentUpdate

SetName sets the "name" field.

func (*CommentUpdate) SetNillableCreatedAt

func (cu *CommentUpdate) SetNillableCreatedAt(t *time.Time) *CommentUpdate

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

func (*CommentUpdate) SetNillablePostID

func (cu *CommentUpdate) SetNillablePostID(id *int64) *CommentUpdate

SetNillablePostID sets the "post" edge to the Article entity by ID if the given value is not nil.

func (*CommentUpdate) SetNillableUpdatedAt

func (cu *CommentUpdate) SetNillableUpdatedAt(t *time.Time) *CommentUpdate

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

func (*CommentUpdate) SetPost

func (cu *CommentUpdate) SetPost(a *Article) *CommentUpdate

SetPost sets the "post" edge to the Article entity.

func (*CommentUpdate) SetPostID

func (cu *CommentUpdate) SetPostID(id int64) *CommentUpdate

SetPostID sets the "post" edge to the Article entity by ID.

func (*CommentUpdate) SetUpdatedAt

func (cu *CommentUpdate) SetUpdatedAt(t time.Time) *CommentUpdate

SetUpdatedAt sets the "updated_at" field.

func (*CommentUpdate) Where

func (cu *CommentUpdate) Where(ps ...predicate.Comment) *CommentUpdate

Where adds a new predicate for the CommentUpdate builder.

type CommentUpdateOne

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

CommentUpdateOne is the builder for updating a single Comment entity.

func (*CommentUpdateOne) ClearPost

func (cuo *CommentUpdateOne) ClearPost() *CommentUpdateOne

ClearPost clears the "post" edge to the Article entity.

func (*CommentUpdateOne) Exec

func (cuo *CommentUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*CommentUpdateOne) ExecX

func (cuo *CommentUpdateOne) ExecX(ctx context.Context)

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

func (*CommentUpdateOne) Mutation

func (cuo *CommentUpdateOne) Mutation() *CommentMutation

Mutation returns the CommentMutation object of the builder.

func (*CommentUpdateOne) Save

func (cuo *CommentUpdateOne) Save(ctx context.Context) (*Comment, error)

Save executes the query and returns the updated Comment entity.

func (*CommentUpdateOne) SaveX

func (cuo *CommentUpdateOne) SaveX(ctx context.Context) *Comment

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

func (*CommentUpdateOne) SetContent

func (cuo *CommentUpdateOne) SetContent(s string) *CommentUpdateOne

SetContent sets the "content" field.

func (*CommentUpdateOne) SetCreatedAt

func (cuo *CommentUpdateOne) SetCreatedAt(t time.Time) *CommentUpdateOne

SetCreatedAt sets the "created_at" field.

func (*CommentUpdateOne) SetName

func (cuo *CommentUpdateOne) SetName(s string) *CommentUpdateOne

SetName sets the "name" field.

func (*CommentUpdateOne) SetNillableCreatedAt

func (cuo *CommentUpdateOne) SetNillableCreatedAt(t *time.Time) *CommentUpdateOne

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

func (*CommentUpdateOne) SetNillablePostID

func (cuo *CommentUpdateOne) SetNillablePostID(id *int64) *CommentUpdateOne

SetNillablePostID sets the "post" edge to the Article entity by ID if the given value is not nil.

func (*CommentUpdateOne) SetNillableUpdatedAt

func (cuo *CommentUpdateOne) SetNillableUpdatedAt(t *time.Time) *CommentUpdateOne

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

func (*CommentUpdateOne) SetPost

func (cuo *CommentUpdateOne) SetPost(a *Article) *CommentUpdateOne

SetPost sets the "post" edge to the Article entity.

func (*CommentUpdateOne) SetPostID

func (cuo *CommentUpdateOne) SetPostID(id int64) *CommentUpdateOne

SetPostID sets the "post" edge to the Article entity by ID.

func (*CommentUpdateOne) SetUpdatedAt

func (cuo *CommentUpdateOne) SetUpdatedAt(t time.Time) *CommentUpdateOne

SetUpdatedAt sets the "updated_at" field.

type Comments

type Comments []*Comment

Comments is a parsable slice of Comment.

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(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 Committer 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, func(string) bool)

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(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 Rollbacker method.

type Tag

type Tag struct {

	// ID of the ent.
	ID int64 `json:"id,omitempty"`
	// Slug holds the value of the "slug" field.
	Slug string `json:"slug,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt holds the value of the "updated_at" field.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the TagQuery when eager-loading is set.
	Edges TagEdges `json:"edges"`
	// contains filtered or unexported fields
}

Tag is the model entity for the Tag schema.

func (*Tag) QueryPosts

func (t *Tag) QueryPosts() *ArticleQuery

QueryPosts queries the "posts" edge of the Tag entity.

func (*Tag) String

func (t *Tag) String() string

String implements the fmt.Stringer.

func (*Tag) Unwrap

func (t *Tag) Unwrap() *Tag

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

func (t *Tag) Update() *TagUpdateOne

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

type TagClient

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

TagClient is a client for the Tag schema.

func NewTagClient

func NewTagClient(c config) *TagClient

NewTagClient returns a client for the Tag from the given config.

func (*TagClient) Create

func (c *TagClient) Create() *TagCreate

Create returns a create builder for Tag.

func (*TagClient) CreateBulk

func (c *TagClient) CreateBulk(builders ...*TagCreate) *TagCreateBulk

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

func (*TagClient) Delete

func (c *TagClient) Delete() *TagDelete

Delete returns a delete builder for Tag.

func (*TagClient) DeleteOne

func (c *TagClient) DeleteOne(t *Tag) *TagDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*TagClient) DeleteOneID

func (c *TagClient) DeleteOneID(id int64) *TagDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*TagClient) Get

func (c *TagClient) Get(ctx context.Context, id int64) (*Tag, error)

Get returns a Tag entity by its id.

func (*TagClient) GetX

func (c *TagClient) GetX(ctx context.Context, id int64) *Tag

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

func (*TagClient) Hooks

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

Hooks returns the client hooks.

func (*TagClient) Query

func (c *TagClient) Query() *TagQuery

Query returns a query builder for Tag.

func (*TagClient) QueryPosts

func (c *TagClient) QueryPosts(t *Tag) *ArticleQuery

QueryPosts queries the posts edge of a Tag.

func (*TagClient) Update

func (c *TagClient) Update() *TagUpdate

Update returns an update builder for Tag.

func (*TagClient) UpdateOne

func (c *TagClient) UpdateOne(t *Tag) *TagUpdateOne

UpdateOne returns an update builder for the given entity.

func (*TagClient) UpdateOneID

func (c *TagClient) UpdateOneID(id int64) *TagUpdateOne

UpdateOneID returns an update builder for the given id.

func (*TagClient) Use

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

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

type TagCreate

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

TagCreate is the builder for creating a Tag entity.

func (*TagCreate) AddPostIDs

func (tc *TagCreate) AddPostIDs(ids ...int64) *TagCreate

AddPostIDs adds the "posts" edge to the Article entity by IDs.

func (*TagCreate) AddPosts

func (tc *TagCreate) AddPosts(a ...*Article) *TagCreate

AddPosts adds the "posts" edges to the Article entity.

func (*TagCreate) Mutation

func (tc *TagCreate) Mutation() *TagMutation

Mutation returns the TagMutation object of the builder.

func (*TagCreate) Save

func (tc *TagCreate) Save(ctx context.Context) (*Tag, error)

Save creates the Tag in the database.

func (*TagCreate) SaveX

func (tc *TagCreate) SaveX(ctx context.Context) *Tag

SaveX calls Save and panics if Save returns an error.

func (*TagCreate) SetCreatedAt

func (tc *TagCreate) SetCreatedAt(t time.Time) *TagCreate

SetCreatedAt sets the "created_at" field.

func (*TagCreate) SetID

func (tc *TagCreate) SetID(i int64) *TagCreate

SetID sets the "id" field.

func (*TagCreate) SetName

func (tc *TagCreate) SetName(s string) *TagCreate

SetName sets the "name" field.

func (*TagCreate) SetNillableCreatedAt

func (tc *TagCreate) SetNillableCreatedAt(t *time.Time) *TagCreate

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

func (*TagCreate) SetNillableUpdatedAt

func (tc *TagCreate) SetNillableUpdatedAt(t *time.Time) *TagCreate

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

func (*TagCreate) SetSlug

func (tc *TagCreate) SetSlug(s string) *TagCreate

SetSlug sets the "slug" field.

func (*TagCreate) SetUpdatedAt

func (tc *TagCreate) SetUpdatedAt(t time.Time) *TagCreate

SetUpdatedAt sets the "updated_at" field.

type TagCreateBulk

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

TagCreateBulk is the builder for creating many Tag entities in bulk.

func (*TagCreateBulk) Save

func (tcb *TagCreateBulk) Save(ctx context.Context) ([]*Tag, error)

Save creates the Tag entities in the database.

func (*TagCreateBulk) SaveX

func (tcb *TagCreateBulk) SaveX(ctx context.Context) []*Tag

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

type TagDelete

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

TagDelete is the builder for deleting a Tag entity.

func (*TagDelete) Exec

func (td *TagDelete) Exec(ctx context.Context) (int, error)

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

func (*TagDelete) ExecX

func (td *TagDelete) ExecX(ctx context.Context) int

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

func (*TagDelete) Where

func (td *TagDelete) Where(ps ...predicate.Tag) *TagDelete

Where adds a new predicate to the TagDelete builder.

type TagDeleteOne

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

TagDeleteOne is the builder for deleting a single Tag entity.

func (*TagDeleteOne) Exec

func (tdo *TagDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*TagDeleteOne) ExecX

func (tdo *TagDeleteOne) ExecX(ctx context.Context)

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

type TagEdges

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

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

func (TagEdges) PostsOrErr

func (e TagEdges) PostsOrErr() ([]*Article, error)

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

type TagGroupBy

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

TagGroupBy is the group-by builder for Tag entities.

func (*TagGroupBy) Aggregate

func (tgb *TagGroupBy) Aggregate(fns ...AggregateFunc) *TagGroupBy

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

func (*TagGroupBy) Bool

func (tgb *TagGroupBy) 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 (*TagGroupBy) BoolX

func (tgb *TagGroupBy) BoolX(ctx context.Context) bool

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

func (*TagGroupBy) Bools

func (tgb *TagGroupBy) 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 (*TagGroupBy) BoolsX

func (tgb *TagGroupBy) BoolsX(ctx context.Context) []bool

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

func (*TagGroupBy) Float64

func (tgb *TagGroupBy) 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 (*TagGroupBy) Float64X

func (tgb *TagGroupBy) Float64X(ctx context.Context) float64

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

func (*TagGroupBy) Float64s

func (tgb *TagGroupBy) 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 (*TagGroupBy) Float64sX

func (tgb *TagGroupBy) Float64sX(ctx context.Context) []float64

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

func (*TagGroupBy) Int

func (tgb *TagGroupBy) 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 (*TagGroupBy) IntX

func (tgb *TagGroupBy) IntX(ctx context.Context) int

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

func (*TagGroupBy) Ints

func (tgb *TagGroupBy) 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 (*TagGroupBy) IntsX

func (tgb *TagGroupBy) IntsX(ctx context.Context) []int

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

func (*TagGroupBy) Scan

func (tgb *TagGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*TagGroupBy) ScanX

func (tgb *TagGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*TagGroupBy) String

func (tgb *TagGroupBy) 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 (*TagGroupBy) StringX

func (tgb *TagGroupBy) StringX(ctx context.Context) string

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

func (*TagGroupBy) Strings

func (tgb *TagGroupBy) 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 (*TagGroupBy) StringsX

func (tgb *TagGroupBy) StringsX(ctx context.Context) []string

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

type TagMutation

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

TagMutation represents an operation that mutates the Tag nodes in the graph.

func (*TagMutation) AddField

func (m *TagMutation) 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 (*TagMutation) AddPostIDs

func (m *TagMutation) AddPostIDs(ids ...int64)

AddPostIDs adds the "posts" edge to the Article entity by ids.

func (*TagMutation) AddedEdges

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

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

func (*TagMutation) AddedField

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

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

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

func (*TagMutation) AddedIDs

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

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

func (*TagMutation) ClearEdge

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

func (m *TagMutation) 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 (*TagMutation) ClearPosts

func (m *TagMutation) ClearPosts()

ClearPosts clears the "posts" edge to the Article entity.

func (*TagMutation) ClearedEdges

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

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

func (*TagMutation) ClearedFields

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

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

func (TagMutation) Client

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

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

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

func (*TagMutation) EdgeCleared

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

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

func (*TagMutation) Field

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

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

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

func (*TagMutation) Fields

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

func (m *TagMutation) ID() (id int64, exists bool)

ID returns the ID value in the mutation. Note that the ID is only available if it was provided to the builder.

func (*TagMutation) Name

func (m *TagMutation) Name() (r string, exists bool)

Name returns the value of the "name" field in the mutation.

func (*TagMutation) OldCreatedAt

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

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

func (m *TagMutation) 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 (*TagMutation) OldName

func (m *TagMutation) OldName(ctx context.Context) (v string, err error)

OldName returns the old "name" field's value of the Tag entity. If the Tag 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 (*TagMutation) OldSlug

func (m *TagMutation) OldSlug(ctx context.Context) (v string, err error)

OldSlug returns the old "slug" field's value of the Tag entity. If the Tag 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 (*TagMutation) OldUpdatedAt

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

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

func (m *TagMutation) Op() Op

Op returns the operation name.

func (*TagMutation) PostsCleared

func (m *TagMutation) PostsCleared() bool

PostsCleared returns if the "posts" edge to the Article entity was cleared.

func (*TagMutation) PostsIDs

func (m *TagMutation) PostsIDs() (ids []int64)

PostsIDs returns the "posts" edge IDs in the mutation.

func (*TagMutation) RemovePostIDs

func (m *TagMutation) RemovePostIDs(ids ...int64)

RemovePostIDs removes the "posts" edge to the Article entity by IDs.

func (*TagMutation) RemovedEdges

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

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

func (*TagMutation) RemovedIDs

func (m *TagMutation) 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 (*TagMutation) RemovedPostsIDs

func (m *TagMutation) RemovedPostsIDs() (ids []int64)

RemovedPosts returns the removed IDs of the "posts" edge to the Article entity.

func (*TagMutation) ResetCreatedAt

func (m *TagMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*TagMutation) ResetEdge

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

func (m *TagMutation) 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 (*TagMutation) ResetName

func (m *TagMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*TagMutation) ResetPosts

func (m *TagMutation) ResetPosts()

ResetPosts resets all changes to the "posts" edge.

func (*TagMutation) ResetSlug

func (m *TagMutation) ResetSlug()

ResetSlug resets all changes to the "slug" field.

func (*TagMutation) ResetUpdatedAt

func (m *TagMutation) ResetUpdatedAt()

ResetUpdatedAt resets all changes to the "updated_at" field.

func (*TagMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*TagMutation) SetField

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

func (m *TagMutation) SetID(id int64)

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

func (*TagMutation) SetName

func (m *TagMutation) SetName(s string)

SetName sets the "name" field.

func (*TagMutation) SetSlug

func (m *TagMutation) SetSlug(s string)

SetSlug sets the "slug" field.

func (*TagMutation) SetUpdatedAt

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

SetUpdatedAt sets the "updated_at" field.

func (*TagMutation) Slug

func (m *TagMutation) Slug() (r string, exists bool)

Slug returns the value of the "slug" field in the mutation.

func (TagMutation) Tx

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

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

func (*TagMutation) Type

func (m *TagMutation) Type() string

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

func (*TagMutation) UpdatedAt

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

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

type TagQuery

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

TagQuery is the builder for querying Tag entities.

func (*TagQuery) All

func (tq *TagQuery) All(ctx context.Context) ([]*Tag, error)

All executes the query and returns a list of Tags.

func (*TagQuery) AllX

func (tq *TagQuery) AllX(ctx context.Context) []*Tag

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

func (*TagQuery) Clone

func (tq *TagQuery) Clone() *TagQuery

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

func (*TagQuery) Count

func (tq *TagQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*TagQuery) CountX

func (tq *TagQuery) CountX(ctx context.Context) int

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

func (*TagQuery) Exist

func (tq *TagQuery) Exist(ctx context.Context) (bool, error)

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

func (*TagQuery) ExistX

func (tq *TagQuery) ExistX(ctx context.Context) bool

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

func (*TagQuery) First

func (tq *TagQuery) First(ctx context.Context) (*Tag, error)

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

func (*TagQuery) FirstID

func (tq *TagQuery) FirstID(ctx context.Context) (id int64, err error)

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

func (*TagQuery) FirstIDX

func (tq *TagQuery) FirstIDX(ctx context.Context) int64

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

func (*TagQuery) FirstX

func (tq *TagQuery) FirstX(ctx context.Context) *Tag

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

func (*TagQuery) GroupBy

func (tq *TagQuery) GroupBy(field string, fields ...string) *TagGroupBy

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 {
	Slug string `json:"slug,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Tag.Query().
	GroupBy(tag.FieldSlug).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*TagQuery) IDs

func (tq *TagQuery) IDs(ctx context.Context) ([]int64, error)

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

func (*TagQuery) IDsX

func (tq *TagQuery) IDsX(ctx context.Context) []int64

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

func (*TagQuery) Limit

func (tq *TagQuery) Limit(limit int) *TagQuery

Limit adds a limit step to the query.

func (*TagQuery) Offset

func (tq *TagQuery) Offset(offset int) *TagQuery

Offset adds an offset step to the query.

func (*TagQuery) Only

func (tq *TagQuery) Only(ctx context.Context) (*Tag, error)

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

func (*TagQuery) OnlyID

func (tq *TagQuery) OnlyID(ctx context.Context) (id int64, err error)

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

func (*TagQuery) OnlyIDX

func (tq *TagQuery) OnlyIDX(ctx context.Context) int64

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

func (*TagQuery) OnlyX

func (tq *TagQuery) OnlyX(ctx context.Context) *Tag

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

func (*TagQuery) Order

func (tq *TagQuery) Order(o ...OrderFunc) *TagQuery

Order adds an order step to the query.

func (*TagQuery) QueryPosts

func (tq *TagQuery) QueryPosts() *ArticleQuery

QueryPosts chains the current query on the "posts" edge.

func (*TagQuery) Select

func (tq *TagQuery) Select(field string, fields ...string) *TagSelect

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 {
	Slug string `json:"slug,omitempty"`
}

client.Tag.Query().
	Select(tag.FieldSlug).
	Scan(ctx, &v)

func (*TagQuery) Where

func (tq *TagQuery) Where(ps ...predicate.Tag) *TagQuery

Where adds a new predicate for the TagQuery builder.

func (*TagQuery) WithPosts

func (tq *TagQuery) WithPosts(opts ...func(*ArticleQuery)) *TagQuery

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

type TagSelect

type TagSelect struct {
	*TagQuery
	// contains filtered or unexported fields
}

TagSelect is the builder for selecting fields of Tag entities.

func (*TagSelect) Bool

func (ts *TagSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*TagSelect) BoolX

func (ts *TagSelect) BoolX(ctx context.Context) bool

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

func (*TagSelect) Bools

func (ts *TagSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*TagSelect) BoolsX

func (ts *TagSelect) BoolsX(ctx context.Context) []bool

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

func (*TagSelect) Float64

func (ts *TagSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*TagSelect) Float64X

func (ts *TagSelect) Float64X(ctx context.Context) float64

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

func (*TagSelect) Float64s

func (ts *TagSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*TagSelect) Float64sX

func (ts *TagSelect) Float64sX(ctx context.Context) []float64

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

func (*TagSelect) Int

func (ts *TagSelect) Int(ctx context.Context) (_ int, err error)

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

func (*TagSelect) IntX

func (ts *TagSelect) IntX(ctx context.Context) int

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

func (*TagSelect) Ints

func (ts *TagSelect) Ints(ctx context.Context) ([]int, error)

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

func (*TagSelect) IntsX

func (ts *TagSelect) IntsX(ctx context.Context) []int

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

func (*TagSelect) Scan

func (ts *TagSelect) Scan(ctx context.Context, v interface{}) error

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

func (*TagSelect) ScanX

func (ts *TagSelect) ScanX(ctx context.Context, v interface{})

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

func (*TagSelect) String

func (ts *TagSelect) String(ctx context.Context) (_ string, err error)

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

func (*TagSelect) StringX

func (ts *TagSelect) StringX(ctx context.Context) string

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

func (*TagSelect) Strings

func (ts *TagSelect) Strings(ctx context.Context) ([]string, error)

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

func (*TagSelect) StringsX

func (ts *TagSelect) StringsX(ctx context.Context) []string

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

type TagUpdate

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

TagUpdate is the builder for updating Tag entities.

func (*TagUpdate) AddPostIDs

func (tu *TagUpdate) AddPostIDs(ids ...int64) *TagUpdate

AddPostIDs adds the "posts" edge to the Article entity by IDs.

func (*TagUpdate) AddPosts

func (tu *TagUpdate) AddPosts(a ...*Article) *TagUpdate

AddPosts adds the "posts" edges to the Article entity.

func (*TagUpdate) ClearPosts

func (tu *TagUpdate) ClearPosts() *TagUpdate

ClearPosts clears all "posts" edges to the Article entity.

func (*TagUpdate) Exec

func (tu *TagUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*TagUpdate) ExecX

func (tu *TagUpdate) ExecX(ctx context.Context)

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

func (*TagUpdate) Mutation

func (tu *TagUpdate) Mutation() *TagMutation

Mutation returns the TagMutation object of the builder.

func (*TagUpdate) RemovePostIDs

func (tu *TagUpdate) RemovePostIDs(ids ...int64) *TagUpdate

RemovePostIDs removes the "posts" edge to Article entities by IDs.

func (*TagUpdate) RemovePosts

func (tu *TagUpdate) RemovePosts(a ...*Article) *TagUpdate

RemovePosts removes "posts" edges to Article entities.

func (*TagUpdate) Save

func (tu *TagUpdate) Save(ctx context.Context) (int, error)

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

func (*TagUpdate) SaveX

func (tu *TagUpdate) SaveX(ctx context.Context) int

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

func (*TagUpdate) SetCreatedAt

func (tu *TagUpdate) SetCreatedAt(t time.Time) *TagUpdate

SetCreatedAt sets the "created_at" field.

func (*TagUpdate) SetName

func (tu *TagUpdate) SetName(s string) *TagUpdate

SetName sets the "name" field.

func (*TagUpdate) SetNillableCreatedAt

func (tu *TagUpdate) SetNillableCreatedAt(t *time.Time) *TagUpdate

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

func (*TagUpdate) SetNillableUpdatedAt

func (tu *TagUpdate) SetNillableUpdatedAt(t *time.Time) *TagUpdate

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

func (*TagUpdate) SetSlug

func (tu *TagUpdate) SetSlug(s string) *TagUpdate

SetSlug sets the "slug" field.

func (*TagUpdate) SetUpdatedAt

func (tu *TagUpdate) SetUpdatedAt(t time.Time) *TagUpdate

SetUpdatedAt sets the "updated_at" field.

func (*TagUpdate) Where

func (tu *TagUpdate) Where(ps ...predicate.Tag) *TagUpdate

Where adds a new predicate for the TagUpdate builder.

type TagUpdateOne

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

TagUpdateOne is the builder for updating a single Tag entity.

func (*TagUpdateOne) AddPostIDs

func (tuo *TagUpdateOne) AddPostIDs(ids ...int64) *TagUpdateOne

AddPostIDs adds the "posts" edge to the Article entity by IDs.

func (*TagUpdateOne) AddPosts

func (tuo *TagUpdateOne) AddPosts(a ...*Article) *TagUpdateOne

AddPosts adds the "posts" edges to the Article entity.

func (*TagUpdateOne) ClearPosts

func (tuo *TagUpdateOne) ClearPosts() *TagUpdateOne

ClearPosts clears all "posts" edges to the Article entity.

func (*TagUpdateOne) Exec

func (tuo *TagUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*TagUpdateOne) ExecX

func (tuo *TagUpdateOne) ExecX(ctx context.Context)

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

func (*TagUpdateOne) Mutation

func (tuo *TagUpdateOne) Mutation() *TagMutation

Mutation returns the TagMutation object of the builder.

func (*TagUpdateOne) RemovePostIDs

func (tuo *TagUpdateOne) RemovePostIDs(ids ...int64) *TagUpdateOne

RemovePostIDs removes the "posts" edge to Article entities by IDs.

func (*TagUpdateOne) RemovePosts

func (tuo *TagUpdateOne) RemovePosts(a ...*Article) *TagUpdateOne

RemovePosts removes "posts" edges to Article entities.

func (*TagUpdateOne) Save

func (tuo *TagUpdateOne) Save(ctx context.Context) (*Tag, error)

Save executes the query and returns the updated Tag entity.

func (*TagUpdateOne) SaveX

func (tuo *TagUpdateOne) SaveX(ctx context.Context) *Tag

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

func (*TagUpdateOne) SetCreatedAt

func (tuo *TagUpdateOne) SetCreatedAt(t time.Time) *TagUpdateOne

SetCreatedAt sets the "created_at" field.

func (*TagUpdateOne) SetName

func (tuo *TagUpdateOne) SetName(s string) *TagUpdateOne

SetName sets the "name" field.

func (*TagUpdateOne) SetNillableCreatedAt

func (tuo *TagUpdateOne) SetNillableCreatedAt(t *time.Time) *TagUpdateOne

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

func (*TagUpdateOne) SetNillableUpdatedAt

func (tuo *TagUpdateOne) SetNillableUpdatedAt(t *time.Time) *TagUpdateOne

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

func (*TagUpdateOne) SetSlug

func (tuo *TagUpdateOne) SetSlug(s string) *TagUpdateOne

SetSlug sets the "slug" field.

func (*TagUpdateOne) SetUpdatedAt

func (tuo *TagUpdateOne) SetUpdatedAt(t time.Time) *TagUpdateOne

SetUpdatedAt sets the "updated_at" field.

type Tags

type Tags []*Tag

Tags is a parsable slice of Tag.

type Tx

type Tx struct {

	// Article is the client for interacting with the Article builders.
	Article *ArticleClient
	// Comment is the client for interacting with the Comment builders.
	Comment *CommentClient
	// Tag is the client for interacting with the Tag builders.
	Tag *TagClient
	// 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 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