ent

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

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

Go to latest
Published: Dec 1, 2023 License: MIT Imports: 22 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.
	TypeAnswer   = "Answer"
	TypeQuestion = "Question"
	TypeTag      = "Tag"
	TypeUser     = "User"
)

Variables

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

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

Functions

func Asc

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

Asc applies the given fields in ASC order.

func Desc

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

Desc applies the given fields in DESC order.

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func IsValidationError

func IsValidationError(err error) bool

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

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

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

NewContext returns a new context with the given Client attached.

func NewTxContext

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

NewTxContext returns a new context with the given Tx attached.

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

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

func As

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

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

func Count

func Count() AggregateFunc

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

func Max

func Max(field string) AggregateFunc

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

func Mean

func Mean(field string) AggregateFunc

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

func Min

func Min(field string) AggregateFunc

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

func Sum

func Sum(field string) AggregateFunc

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

type Answer

type Answer struct {

	// ID of the ent.
	ID int `json:"id,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"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the AnswerQuery when eager-loading is set.
	Edges AnswerEdges `json:"edges"`
	// contains filtered or unexported fields
}

Answer is the model entity for the Answer schema.

func (*Answer) QueryAuthor

func (a *Answer) QueryAuthor() *UserQuery

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

func (*Answer) QueryQuestion

func (a *Answer) QueryQuestion() *QuestionQuery

QueryQuestion queries the "question" edge of the Answer entity.

func (*Answer) String

func (a *Answer) String() string

String implements the fmt.Stringer.

func (*Answer) Unwrap

func (a *Answer) Unwrap() *Answer

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

func (a *Answer) Update() *AnswerUpdateOne

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

func (*Answer) Value

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

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

type AnswerClient

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

AnswerClient is a client for the Answer schema.

func NewAnswerClient

func NewAnswerClient(c config) *AnswerClient

NewAnswerClient returns a client for the Answer from the given config.

func (*AnswerClient) Create

func (c *AnswerClient) Create() *AnswerCreate

Create returns a builder for creating a Answer entity.

func (*AnswerClient) CreateBulk

func (c *AnswerClient) CreateBulk(builders ...*AnswerCreate) *AnswerCreateBulk

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

func (*AnswerClient) Delete

func (c *AnswerClient) Delete() *AnswerDelete

Delete returns a delete builder for Answer.

func (*AnswerClient) DeleteOne

func (c *AnswerClient) DeleteOne(a *Answer) *AnswerDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*AnswerClient) DeleteOneID

func (c *AnswerClient) DeleteOneID(id int) *AnswerDeleteOne

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

func (*AnswerClient) Get

func (c *AnswerClient) Get(ctx context.Context, id int) (*Answer, error)

Get returns a Answer entity by its id.

func (*AnswerClient) GetX

func (c *AnswerClient) GetX(ctx context.Context, id int) *Answer

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

func (*AnswerClient) Hooks

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

Hooks returns the client hooks.

func (*AnswerClient) Intercept

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

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

func (*AnswerClient) Interceptors

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

Interceptors returns the client interceptors.

func (*AnswerClient) MapCreateBulk

func (c *AnswerClient) MapCreateBulk(slice any, setFunc func(*AnswerCreate, int)) *AnswerCreateBulk

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

func (*AnswerClient) Query

func (c *AnswerClient) Query() *AnswerQuery

Query returns a query builder for Answer.

func (*AnswerClient) QueryAuthor

func (c *AnswerClient) QueryAuthor(a *Answer) *UserQuery

QueryAuthor queries the author edge of a Answer.

func (*AnswerClient) QueryQuestion

func (c *AnswerClient) QueryQuestion(a *Answer) *QuestionQuery

QueryQuestion queries the question edge of a Answer.

func (*AnswerClient) Update

func (c *AnswerClient) Update() *AnswerUpdate

Update returns an update builder for Answer.

func (*AnswerClient) UpdateOne

func (c *AnswerClient) UpdateOne(a *Answer) *AnswerUpdateOne

UpdateOne returns an update builder for the given entity.

func (*AnswerClient) UpdateOneID

func (c *AnswerClient) UpdateOneID(id int) *AnswerUpdateOne

UpdateOneID returns an update builder for the given id.

func (*AnswerClient) Use

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

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

type AnswerCreate

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

AnswerCreate is the builder for creating a Answer entity.

func (*AnswerCreate) Exec

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

Exec executes the query.

func (*AnswerCreate) ExecX

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

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

func (*AnswerCreate) Mutation

func (ac *AnswerCreate) Mutation() *AnswerMutation

Mutation returns the AnswerMutation object of the builder.

func (*AnswerCreate) Save

func (ac *AnswerCreate) Save(ctx context.Context) (*Answer, error)

Save creates the Answer in the database.

func (*AnswerCreate) SaveX

func (ac *AnswerCreate) SaveX(ctx context.Context) *Answer

SaveX calls Save and panics if Save returns an error.

func (*AnswerCreate) SetAuthor

func (ac *AnswerCreate) SetAuthor(u *User) *AnswerCreate

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

func (*AnswerCreate) SetAuthorID

func (ac *AnswerCreate) SetAuthorID(id int) *AnswerCreate

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

func (*AnswerCreate) SetContent

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

SetContent sets the "content" field.

func (*AnswerCreate) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*AnswerCreate) SetNillableAuthorID

func (ac *AnswerCreate) SetNillableAuthorID(id *int) *AnswerCreate

SetNillableAuthorID sets the "author" edge to the User entity by ID if the given value is not nil.

func (*AnswerCreate) SetNillableCreatedAt

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

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

func (*AnswerCreate) SetNillableQuestionID

func (ac *AnswerCreate) SetNillableQuestionID(id *int) *AnswerCreate

SetNillableQuestionID sets the "question" edge to the Question entity by ID if the given value is not nil.

func (*AnswerCreate) SetQuestion

func (ac *AnswerCreate) SetQuestion(q *Question) *AnswerCreate

SetQuestion sets the "question" edge to the Question entity.

func (*AnswerCreate) SetQuestionID

func (ac *AnswerCreate) SetQuestionID(id int) *AnswerCreate

SetQuestionID sets the "question" edge to the Question entity by ID.

type AnswerCreateBulk

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

AnswerCreateBulk is the builder for creating many Answer entities in bulk.

func (*AnswerCreateBulk) Exec

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

Exec executes the query.

func (*AnswerCreateBulk) ExecX

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

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

func (*AnswerCreateBulk) Save

func (acb *AnswerCreateBulk) Save(ctx context.Context) ([]*Answer, error)

Save creates the Answer entities in the database.

func (*AnswerCreateBulk) SaveX

func (acb *AnswerCreateBulk) SaveX(ctx context.Context) []*Answer

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

type AnswerDelete

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

AnswerDelete is the builder for deleting a Answer entity.

func (*AnswerDelete) Exec

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

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

func (*AnswerDelete) ExecX

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

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

func (*AnswerDelete) Where

func (ad *AnswerDelete) Where(ps ...predicate.Answer) *AnswerDelete

Where appends a list predicates to the AnswerDelete builder.

type AnswerDeleteOne

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

AnswerDeleteOne is the builder for deleting a single Answer entity.

func (*AnswerDeleteOne) Exec

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

Exec executes the deletion query.

func (*AnswerDeleteOne) ExecX

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

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

func (*AnswerDeleteOne) Where

func (ado *AnswerDeleteOne) Where(ps ...predicate.Answer) *AnswerDeleteOne

Where appends a list predicates to the AnswerDelete builder.

type AnswerEdges

type AnswerEdges struct {
	// Question holds the value of the question edge.
	Question *Question `json:"question,omitempty"`
	// Author holds the value of the author edge.
	Author *User `json:"author,omitempty"`
	// contains filtered or unexported fields
}

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

func (AnswerEdges) AuthorOrErr

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

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

func (AnswerEdges) QuestionOrErr

func (e AnswerEdges) QuestionOrErr() (*Question, error)

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

type AnswerGroupBy

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

AnswerGroupBy is the group-by builder for Answer entities.

func (*AnswerGroupBy) Aggregate

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

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

func (*AnswerGroupBy) Bool

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

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

func (*AnswerGroupBy) BoolX

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

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

func (*AnswerGroupBy) Bools

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

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

func (*AnswerGroupBy) BoolsX

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

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

func (*AnswerGroupBy) Float64

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

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

func (*AnswerGroupBy) Float64X

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

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

func (*AnswerGroupBy) Float64s

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

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

func (*AnswerGroupBy) Float64sX

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

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

func (*AnswerGroupBy) Int

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

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

func (*AnswerGroupBy) IntX

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

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

func (*AnswerGroupBy) Ints

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

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

func (*AnswerGroupBy) IntsX

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

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

func (*AnswerGroupBy) Scan

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

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

func (*AnswerGroupBy) ScanX

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

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

func (*AnswerGroupBy) String

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

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

func (*AnswerGroupBy) StringX

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

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

func (*AnswerGroupBy) Strings

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

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

func (*AnswerGroupBy) StringsX

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

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

type AnswerMutation

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

AnswerMutation represents an operation that mutates the Answer nodes in the graph.

func (*AnswerMutation) AddField

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

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

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

func (*AnswerMutation) AddedField

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

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

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

func (*AnswerMutation) AddedIDs

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

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

func (*AnswerMutation) AuthorCleared

func (m *AnswerMutation) AuthorCleared() bool

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

func (*AnswerMutation) AuthorID

func (m *AnswerMutation) AuthorID() (id int, exists bool)

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

func (*AnswerMutation) AuthorIDs

func (m *AnswerMutation) AuthorIDs() (ids []int)

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

func (*AnswerMutation) ClearAuthor

func (m *AnswerMutation) ClearAuthor()

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

func (*AnswerMutation) ClearEdge

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

func (m *AnswerMutation) 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 (*AnswerMutation) ClearQuestion

func (m *AnswerMutation) ClearQuestion()

ClearQuestion clears the "question" edge to the Question entity.

func (*AnswerMutation) ClearedEdges

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

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

func (*AnswerMutation) ClearedFields

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

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

func (AnswerMutation) Client

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

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

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

func (*AnswerMutation) CreatedAt

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

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

func (*AnswerMutation) EdgeCleared

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

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

func (*AnswerMutation) Field

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

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

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

func (*AnswerMutation) Fields

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

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

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

func (*AnswerMutation) IDs

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

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

func (*AnswerMutation) OldContent

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

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

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

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

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

func (m *AnswerMutation) Op() Op

Op returns the operation name.

func (*AnswerMutation) QuestionCleared

func (m *AnswerMutation) QuestionCleared() bool

QuestionCleared reports if the "question" edge to the Question entity was cleared.

func (*AnswerMutation) QuestionID

func (m *AnswerMutation) QuestionID() (id int, exists bool)

QuestionID returns the "question" edge ID in the mutation.

func (*AnswerMutation) QuestionIDs

func (m *AnswerMutation) QuestionIDs() (ids []int)

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

func (*AnswerMutation) RemovedEdges

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

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

func (*AnswerMutation) RemovedIDs

func (m *AnswerMutation) 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 (*AnswerMutation) ResetAuthor

func (m *AnswerMutation) ResetAuthor()

ResetAuthor resets all changes to the "author" edge.

func (*AnswerMutation) ResetContent

func (m *AnswerMutation) ResetContent()

ResetContent resets all changes to the "content" field.

func (*AnswerMutation) ResetCreatedAt

func (m *AnswerMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*AnswerMutation) ResetEdge

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

func (m *AnswerMutation) 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 (*AnswerMutation) ResetQuestion

func (m *AnswerMutation) ResetQuestion()

ResetQuestion resets all changes to the "question" edge.

func (*AnswerMutation) SetAuthorID

func (m *AnswerMutation) SetAuthorID(id int)

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

func (*AnswerMutation) SetContent

func (m *AnswerMutation) SetContent(s string)

SetContent sets the "content" field.

func (*AnswerMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*AnswerMutation) SetField

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

func (m *AnswerMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*AnswerMutation) SetQuestionID

func (m *AnswerMutation) SetQuestionID(id int)

SetQuestionID sets the "question" edge to the Question entity by id.

func (AnswerMutation) Tx

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

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

func (*AnswerMutation) Type

func (m *AnswerMutation) Type() string

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

func (*AnswerMutation) Where

func (m *AnswerMutation) Where(ps ...predicate.Answer)

Where appends a list predicates to the AnswerMutation builder.

func (*AnswerMutation) WhereP

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

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

type AnswerQuery

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

AnswerQuery is the builder for querying Answer entities.

func (*AnswerQuery) Aggregate

func (aq *AnswerQuery) Aggregate(fns ...AggregateFunc) *AnswerSelect

Aggregate returns a AnswerSelect configured with the given aggregations.

func (*AnswerQuery) All

func (aq *AnswerQuery) All(ctx context.Context) ([]*Answer, error)

All executes the query and returns a list of Answers.

func (*AnswerQuery) AllX

func (aq *AnswerQuery) AllX(ctx context.Context) []*Answer

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

func (*AnswerQuery) Clone

func (aq *AnswerQuery) Clone() *AnswerQuery

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

func (*AnswerQuery) Count

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

Count returns the count of the given query.

func (*AnswerQuery) CountX

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

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

func (*AnswerQuery) Exist

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

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

func (*AnswerQuery) ExistX

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

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

func (*AnswerQuery) First

func (aq *AnswerQuery) First(ctx context.Context) (*Answer, error)

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

func (*AnswerQuery) FirstID

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

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

func (*AnswerQuery) FirstIDX

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

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

func (*AnswerQuery) FirstX

func (aq *AnswerQuery) FirstX(ctx context.Context) *Answer

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

func (*AnswerQuery) GroupBy

func (aq *AnswerQuery) GroupBy(field string, fields ...string) *AnswerGroupBy

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

client.Answer.Query().
	GroupBy(answer.FieldContent).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*AnswerQuery) IDs

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

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

func (*AnswerQuery) IDsX

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

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

func (*AnswerQuery) Limit

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

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

func (*AnswerQuery) Offset

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

Offset to start from.

func (*AnswerQuery) Only

func (aq *AnswerQuery) Only(ctx context.Context) (*Answer, error)

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

func (*AnswerQuery) OnlyID

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

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

func (*AnswerQuery) OnlyIDX

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

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

func (*AnswerQuery) OnlyX

func (aq *AnswerQuery) OnlyX(ctx context.Context) *Answer

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

func (*AnswerQuery) Order

func (aq *AnswerQuery) Order(o ...answer.OrderOption) *AnswerQuery

Order specifies how the records should be ordered.

func (*AnswerQuery) QueryAuthor

func (aq *AnswerQuery) QueryAuthor() *UserQuery

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

func (*AnswerQuery) QueryQuestion

func (aq *AnswerQuery) QueryQuestion() *QuestionQuery

QueryQuestion chains the current query on the "question" edge.

func (*AnswerQuery) Select

func (aq *AnswerQuery) Select(fields ...string) *AnswerSelect

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

client.Answer.Query().
	Select(answer.FieldContent).
	Scan(ctx, &v)

func (*AnswerQuery) Unique

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

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

func (*AnswerQuery) Where

func (aq *AnswerQuery) Where(ps ...predicate.Answer) *AnswerQuery

Where adds a new predicate for the AnswerQuery builder.

func (*AnswerQuery) WithAuthor

func (aq *AnswerQuery) WithAuthor(opts ...func(*UserQuery)) *AnswerQuery

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

func (*AnswerQuery) WithQuestion

func (aq *AnswerQuery) WithQuestion(opts ...func(*QuestionQuery)) *AnswerQuery

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

type AnswerSelect

type AnswerSelect struct {
	*AnswerQuery
	// contains filtered or unexported fields
}

AnswerSelect is the builder for selecting fields of Answer entities.

func (*AnswerSelect) Aggregate

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

Aggregate adds the given aggregation functions to the selector query.

func (*AnswerSelect) Bool

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

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

func (*AnswerSelect) BoolX

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

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

func (*AnswerSelect) Bools

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

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

func (*AnswerSelect) BoolsX

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

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

func (*AnswerSelect) Float64

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

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

func (*AnswerSelect) Float64X

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

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

func (*AnswerSelect) Float64s

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

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

func (*AnswerSelect) Float64sX

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

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

func (*AnswerSelect) Int

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

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

func (*AnswerSelect) IntX

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

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

func (*AnswerSelect) Ints

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

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

func (*AnswerSelect) IntsX

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

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

func (*AnswerSelect) Scan

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

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

func (*AnswerSelect) ScanX

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

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

func (*AnswerSelect) String

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

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

func (*AnswerSelect) StringX

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

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

func (*AnswerSelect) Strings

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

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

func (*AnswerSelect) StringsX

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

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

type AnswerUpdate

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

AnswerUpdate is the builder for updating Answer entities.

func (*AnswerUpdate) ClearAuthor

func (au *AnswerUpdate) ClearAuthor() *AnswerUpdate

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

func (*AnswerUpdate) ClearQuestion

func (au *AnswerUpdate) ClearQuestion() *AnswerUpdate

ClearQuestion clears the "question" edge to the Question entity.

func (*AnswerUpdate) Exec

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

Exec executes the query.

func (*AnswerUpdate) ExecX

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

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

func (*AnswerUpdate) Mutation

func (au *AnswerUpdate) Mutation() *AnswerMutation

Mutation returns the AnswerMutation object of the builder.

func (*AnswerUpdate) Save

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

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

func (*AnswerUpdate) SaveX

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

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

func (*AnswerUpdate) SetAuthor

func (au *AnswerUpdate) SetAuthor(u *User) *AnswerUpdate

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

func (*AnswerUpdate) SetAuthorID

func (au *AnswerUpdate) SetAuthorID(id int) *AnswerUpdate

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

func (*AnswerUpdate) SetContent

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

SetContent sets the "content" field.

func (*AnswerUpdate) SetNillableAuthorID

func (au *AnswerUpdate) SetNillableAuthorID(id *int) *AnswerUpdate

SetNillableAuthorID sets the "author" edge to the User entity by ID if the given value is not nil.

func (*AnswerUpdate) SetNillableQuestionID

func (au *AnswerUpdate) SetNillableQuestionID(id *int) *AnswerUpdate

SetNillableQuestionID sets the "question" edge to the Question entity by ID if the given value is not nil.

func (*AnswerUpdate) SetQuestion

func (au *AnswerUpdate) SetQuestion(q *Question) *AnswerUpdate

SetQuestion sets the "question" edge to the Question entity.

func (*AnswerUpdate) SetQuestionID

func (au *AnswerUpdate) SetQuestionID(id int) *AnswerUpdate

SetQuestionID sets the "question" edge to the Question entity by ID.

func (*AnswerUpdate) Where

func (au *AnswerUpdate) Where(ps ...predicate.Answer) *AnswerUpdate

Where appends a list predicates to the AnswerUpdate builder.

type AnswerUpdateOne

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

AnswerUpdateOne is the builder for updating a single Answer entity.

func (*AnswerUpdateOne) ClearAuthor

func (auo *AnswerUpdateOne) ClearAuthor() *AnswerUpdateOne

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

func (*AnswerUpdateOne) ClearQuestion

func (auo *AnswerUpdateOne) ClearQuestion() *AnswerUpdateOne

ClearQuestion clears the "question" edge to the Question entity.

func (*AnswerUpdateOne) Exec

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

Exec executes the query on the entity.

func (*AnswerUpdateOne) ExecX

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

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

func (*AnswerUpdateOne) Mutation

func (auo *AnswerUpdateOne) Mutation() *AnswerMutation

Mutation returns the AnswerMutation object of the builder.

func (*AnswerUpdateOne) Save

func (auo *AnswerUpdateOne) Save(ctx context.Context) (*Answer, error)

Save executes the query and returns the updated Answer entity.

func (*AnswerUpdateOne) SaveX

func (auo *AnswerUpdateOne) SaveX(ctx context.Context) *Answer

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

func (*AnswerUpdateOne) Select

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

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

func (*AnswerUpdateOne) SetAuthor

func (auo *AnswerUpdateOne) SetAuthor(u *User) *AnswerUpdateOne

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

func (*AnswerUpdateOne) SetAuthorID

func (auo *AnswerUpdateOne) SetAuthorID(id int) *AnswerUpdateOne

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

func (*AnswerUpdateOne) SetContent

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

SetContent sets the "content" field.

func (*AnswerUpdateOne) SetNillableAuthorID

func (auo *AnswerUpdateOne) SetNillableAuthorID(id *int) *AnswerUpdateOne

SetNillableAuthorID sets the "author" edge to the User entity by ID if the given value is not nil.

func (*AnswerUpdateOne) SetNillableQuestionID

func (auo *AnswerUpdateOne) SetNillableQuestionID(id *int) *AnswerUpdateOne

SetNillableQuestionID sets the "question" edge to the Question entity by ID if the given value is not nil.

func (*AnswerUpdateOne) SetQuestion

func (auo *AnswerUpdateOne) SetQuestion(q *Question) *AnswerUpdateOne

SetQuestion sets the "question" edge to the Question entity.

func (*AnswerUpdateOne) SetQuestionID

func (auo *AnswerUpdateOne) SetQuestionID(id int) *AnswerUpdateOne

SetQuestionID sets the "question" edge to the Question entity by ID.

func (*AnswerUpdateOne) Where

func (auo *AnswerUpdateOne) Where(ps ...predicate.Answer) *AnswerUpdateOne

Where appends a list predicates to the AnswerUpdate builder.

type Answers

type Answers []*Answer

Answers is a parsable slice of Answer.

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Answer is the client for interacting with the Answer builders.
	Answer *AnswerClient
	// Question is the client for interacting with the Question builders.
	Question *QuestionClient
	// Tag is the client for interacting with the Tag builders.
	Tag *TagClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// contains filtered or unexported fields
}

Client is the client that holds all ent builders.

func FromContext

func FromContext(ctx context.Context) *Client

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

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new client configured with the given options.

func Open

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

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

func (*Client) BeginTx

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

BeginTx returns a transactional client with specified options.

func (*Client) Close

func (c *Client) Close() error

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

func (*Client) Debug

func (c *Client) Debug() *Client

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

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

func (*Client) Intercept

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

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

func (*Client) Mutate

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

Mutate implements the ent.Mutator interface.

func (*Client) Tx

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

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

func (*Client) Use

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

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

type CommitFunc

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

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

func (CommitFunc) Commit

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

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

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

hook := func(next ent.Committer) ent.Committer {
	return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error {
		// Do some stuff before.
		if err := next.Commit(ctx, tx); err != nil {
			return err
		}
		// Do some stuff after.
		return nil
	})
}

type Committer

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

Committer is the interface that wraps the Commit method.

type ConstraintError

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

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

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

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

type InterceptFunc

type InterceptFunc = ent.InterceptFunc

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

type Interceptor

type Interceptor = ent.Interceptor

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

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

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

type NotFoundError

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

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

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

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

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

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

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

func Log(fn func(...any)) Option

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

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

type Policy

type Policy = ent.Policy

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

type Querier

type Querier = ent.Querier

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

type QuerierFunc

type QuerierFunc = ent.QuerierFunc

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

type Query

type Query = ent.Query

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

type QueryContext

type QueryContext = ent.QueryContext

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

type Question

type Question struct {

	// ID of the ent.
	ID int `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"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the QuestionQuery when eager-loading is set.
	Edges QuestionEdges `json:"edges"`
	// contains filtered or unexported fields
}

Question is the model entity for the Question schema.

func (*Question) QueryAnswers

func (q *Question) QueryAnswers() *AnswerQuery

QueryAnswers queries the "answers" edge of the Question entity.

func (*Question) QueryAuthor

func (q *Question) QueryAuthor() *UserQuery

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

func (*Question) QueryTags

func (q *Question) QueryTags() *TagQuery

QueryTags queries the "tags" edge of the Question entity.

func (*Question) String

func (q *Question) String() string

String implements the fmt.Stringer.

func (*Question) Unwrap

func (q *Question) Unwrap() *Question

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

func (q *Question) Update() *QuestionUpdateOne

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

func (*Question) Value

func (q *Question) Value(name string) (ent.Value, error)

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

type QuestionClient

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

QuestionClient is a client for the Question schema.

func NewQuestionClient

func NewQuestionClient(c config) *QuestionClient

NewQuestionClient returns a client for the Question from the given config.

func (*QuestionClient) Create

func (c *QuestionClient) Create() *QuestionCreate

Create returns a builder for creating a Question entity.

func (*QuestionClient) CreateBulk

func (c *QuestionClient) CreateBulk(builders ...*QuestionCreate) *QuestionCreateBulk

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

func (*QuestionClient) Delete

func (c *QuestionClient) Delete() *QuestionDelete

Delete returns a delete builder for Question.

func (*QuestionClient) DeleteOne

func (c *QuestionClient) DeleteOne(q *Question) *QuestionDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*QuestionClient) DeleteOneID

func (c *QuestionClient) DeleteOneID(id int) *QuestionDeleteOne

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

func (*QuestionClient) Get

func (c *QuestionClient) Get(ctx context.Context, id int) (*Question, error)

Get returns a Question entity by its id.

func (*QuestionClient) GetX

func (c *QuestionClient) GetX(ctx context.Context, id int) *Question

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

func (*QuestionClient) Hooks

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

Hooks returns the client hooks.

func (*QuestionClient) Intercept

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

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

func (*QuestionClient) Interceptors

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

Interceptors returns the client interceptors.

func (*QuestionClient) MapCreateBulk

func (c *QuestionClient) MapCreateBulk(slice any, setFunc func(*QuestionCreate, int)) *QuestionCreateBulk

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

func (*QuestionClient) Query

func (c *QuestionClient) Query() *QuestionQuery

Query returns a query builder for Question.

func (*QuestionClient) QueryAnswers

func (c *QuestionClient) QueryAnswers(q *Question) *AnswerQuery

QueryAnswers queries the answers edge of a Question.

func (*QuestionClient) QueryAuthor

func (c *QuestionClient) QueryAuthor(q *Question) *UserQuery

QueryAuthor queries the author edge of a Question.

func (*QuestionClient) QueryTags

func (c *QuestionClient) QueryTags(q *Question) *TagQuery

QueryTags queries the tags edge of a Question.

func (*QuestionClient) Update

func (c *QuestionClient) Update() *QuestionUpdate

Update returns an update builder for Question.

func (*QuestionClient) UpdateOne

func (c *QuestionClient) UpdateOne(q *Question) *QuestionUpdateOne

UpdateOne returns an update builder for the given entity.

func (*QuestionClient) UpdateOneID

func (c *QuestionClient) UpdateOneID(id int) *QuestionUpdateOne

UpdateOneID returns an update builder for the given id.

func (*QuestionClient) Use

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

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

type QuestionCreate

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

QuestionCreate is the builder for creating a Question entity.

func (*QuestionCreate) AddAnswerIDs

func (qc *QuestionCreate) AddAnswerIDs(ids ...int) *QuestionCreate

AddAnswerIDs adds the "answers" edge to the Answer entity by IDs.

func (*QuestionCreate) AddAnswers

func (qc *QuestionCreate) AddAnswers(a ...*Answer) *QuestionCreate

AddAnswers adds the "answers" edges to the Answer entity.

func (*QuestionCreate) AddTagIDs

func (qc *QuestionCreate) AddTagIDs(ids ...int) *QuestionCreate

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

func (*QuestionCreate) AddTags

func (qc *QuestionCreate) AddTags(t ...*Tag) *QuestionCreate

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

func (*QuestionCreate) Exec

func (qc *QuestionCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*QuestionCreate) ExecX

func (qc *QuestionCreate) ExecX(ctx context.Context)

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

func (*QuestionCreate) Mutation

func (qc *QuestionCreate) Mutation() *QuestionMutation

Mutation returns the QuestionMutation object of the builder.

func (*QuestionCreate) Save

func (qc *QuestionCreate) Save(ctx context.Context) (*Question, error)

Save creates the Question in the database.

func (*QuestionCreate) SaveX

func (qc *QuestionCreate) SaveX(ctx context.Context) *Question

SaveX calls Save and panics if Save returns an error.

func (*QuestionCreate) SetAuthor

func (qc *QuestionCreate) SetAuthor(u *User) *QuestionCreate

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

func (*QuestionCreate) SetAuthorID

func (qc *QuestionCreate) SetAuthorID(id int) *QuestionCreate

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

func (*QuestionCreate) SetContent

func (qc *QuestionCreate) SetContent(s string) *QuestionCreate

SetContent sets the "content" field.

func (*QuestionCreate) SetCreatedAt

func (qc *QuestionCreate) SetCreatedAt(t time.Time) *QuestionCreate

SetCreatedAt sets the "created_at" field.

func (*QuestionCreate) SetNillableAuthorID

func (qc *QuestionCreate) SetNillableAuthorID(id *int) *QuestionCreate

SetNillableAuthorID sets the "author" edge to the User entity by ID if the given value is not nil.

func (*QuestionCreate) SetNillableCreatedAt

func (qc *QuestionCreate) SetNillableCreatedAt(t *time.Time) *QuestionCreate

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

func (*QuestionCreate) SetTitle

func (qc *QuestionCreate) SetTitle(s string) *QuestionCreate

SetTitle sets the "title" field.

type QuestionCreateBulk

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

QuestionCreateBulk is the builder for creating many Question entities in bulk.

func (*QuestionCreateBulk) Exec

func (qcb *QuestionCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*QuestionCreateBulk) ExecX

func (qcb *QuestionCreateBulk) ExecX(ctx context.Context)

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

func (*QuestionCreateBulk) Save

func (qcb *QuestionCreateBulk) Save(ctx context.Context) ([]*Question, error)

Save creates the Question entities in the database.

func (*QuestionCreateBulk) SaveX

func (qcb *QuestionCreateBulk) SaveX(ctx context.Context) []*Question

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

type QuestionDelete

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

QuestionDelete is the builder for deleting a Question entity.

func (*QuestionDelete) Exec

func (qd *QuestionDelete) Exec(ctx context.Context) (int, error)

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

func (*QuestionDelete) ExecX

func (qd *QuestionDelete) ExecX(ctx context.Context) int

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

func (*QuestionDelete) Where

func (qd *QuestionDelete) Where(ps ...predicate.Question) *QuestionDelete

Where appends a list predicates to the QuestionDelete builder.

type QuestionDeleteOne

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

QuestionDeleteOne is the builder for deleting a single Question entity.

func (*QuestionDeleteOne) Exec

func (qdo *QuestionDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*QuestionDeleteOne) ExecX

func (qdo *QuestionDeleteOne) ExecX(ctx context.Context)

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

func (*QuestionDeleteOne) Where

Where appends a list predicates to the QuestionDelete builder.

type QuestionEdges

type QuestionEdges struct {
	// Answers holds the value of the answers edge.
	Answers []*Answer `json:"answers,omitempty"`
	// Author holds the value of the author edge.
	Author *User `json:"author,omitempty"`
	// Tags holds the value of the tags edge.
	Tags []*Tag `json:"tags,omitempty"`
	// contains filtered or unexported fields
}

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

func (QuestionEdges) AnswersOrErr

func (e QuestionEdges) AnswersOrErr() ([]*Answer, error)

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

func (QuestionEdges) AuthorOrErr

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

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

func (QuestionEdges) TagsOrErr

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

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

type QuestionGroupBy

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

QuestionGroupBy is the group-by builder for Question entities.

func (*QuestionGroupBy) Aggregate

func (qgb *QuestionGroupBy) Aggregate(fns ...AggregateFunc) *QuestionGroupBy

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

func (*QuestionGroupBy) Bool

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

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

func (*QuestionGroupBy) BoolX

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

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

func (*QuestionGroupBy) Bools

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

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

func (*QuestionGroupBy) BoolsX

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

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

func (*QuestionGroupBy) Float64

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

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

func (*QuestionGroupBy) Float64X

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

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

func (*QuestionGroupBy) Float64s

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

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

func (*QuestionGroupBy) Float64sX

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

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

func (*QuestionGroupBy) Int

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

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

func (*QuestionGroupBy) IntX

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

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

func (*QuestionGroupBy) Ints

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

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

func (*QuestionGroupBy) IntsX

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

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

func (*QuestionGroupBy) Scan

func (qgb *QuestionGroupBy) Scan(ctx context.Context, v any) error

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

func (*QuestionGroupBy) ScanX

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

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

func (*QuestionGroupBy) String

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

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

func (*QuestionGroupBy) StringX

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

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

func (*QuestionGroupBy) Strings

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

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

func (*QuestionGroupBy) StringsX

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

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

type QuestionMutation

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

QuestionMutation represents an operation that mutates the Question nodes in the graph.

func (*QuestionMutation) AddAnswerIDs

func (m *QuestionMutation) AddAnswerIDs(ids ...int)

AddAnswerIDs adds the "answers" edge to the Answer entity by ids.

func (*QuestionMutation) AddField

func (m *QuestionMutation) 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 (*QuestionMutation) AddTagIDs

func (m *QuestionMutation) AddTagIDs(ids ...int)

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

func (*QuestionMutation) AddedEdges

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

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

func (*QuestionMutation) AddedField

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

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

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

func (*QuestionMutation) AddedIDs

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

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

func (*QuestionMutation) AnswersCleared

func (m *QuestionMutation) AnswersCleared() bool

AnswersCleared reports if the "answers" edge to the Answer entity was cleared.

func (*QuestionMutation) AnswersIDs

func (m *QuestionMutation) AnswersIDs() (ids []int)

AnswersIDs returns the "answers" edge IDs in the mutation.

func (*QuestionMutation) AuthorCleared

func (m *QuestionMutation) AuthorCleared() bool

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

func (*QuestionMutation) AuthorID

func (m *QuestionMutation) AuthorID() (id int, exists bool)

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

func (*QuestionMutation) AuthorIDs

func (m *QuestionMutation) AuthorIDs() (ids []int)

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

func (*QuestionMutation) ClearAnswers

func (m *QuestionMutation) ClearAnswers()

ClearAnswers clears the "answers" edge to the Answer entity.

func (*QuestionMutation) ClearAuthor

func (m *QuestionMutation) ClearAuthor()

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

func (*QuestionMutation) ClearEdge

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

func (m *QuestionMutation) 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 (*QuestionMutation) ClearTags

func (m *QuestionMutation) ClearTags()

ClearTags clears the "tags" edge to the Tag entity.

func (*QuestionMutation) ClearedEdges

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

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

func (*QuestionMutation) ClearedFields

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

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

func (QuestionMutation) Client

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

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

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

func (*QuestionMutation) CreatedAt

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

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

func (*QuestionMutation) EdgeCleared

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

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

func (*QuestionMutation) Field

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

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

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

func (*QuestionMutation) Fields

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

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

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

func (*QuestionMutation) IDs

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

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

func (*QuestionMutation) OldContent

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

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

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

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

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

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

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

func (m *QuestionMutation) Op() Op

Op returns the operation name.

func (*QuestionMutation) RemoveAnswerIDs

func (m *QuestionMutation) RemoveAnswerIDs(ids ...int)

RemoveAnswerIDs removes the "answers" edge to the Answer entity by IDs.

func (*QuestionMutation) RemoveTagIDs

func (m *QuestionMutation) RemoveTagIDs(ids ...int)

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

func (*QuestionMutation) RemovedAnswersIDs

func (m *QuestionMutation) RemovedAnswersIDs() (ids []int)

RemovedAnswers returns the removed IDs of the "answers" edge to the Answer entity.

func (*QuestionMutation) RemovedEdges

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

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

func (*QuestionMutation) RemovedIDs

func (m *QuestionMutation) 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 (*QuestionMutation) RemovedTagsIDs

func (m *QuestionMutation) RemovedTagsIDs() (ids []int)

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

func (*QuestionMutation) ResetAnswers

func (m *QuestionMutation) ResetAnswers()

ResetAnswers resets all changes to the "answers" edge.

func (*QuestionMutation) ResetAuthor

func (m *QuestionMutation) ResetAuthor()

ResetAuthor resets all changes to the "author" edge.

func (*QuestionMutation) ResetContent

func (m *QuestionMutation) ResetContent()

ResetContent resets all changes to the "content" field.

func (*QuestionMutation) ResetCreatedAt

func (m *QuestionMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*QuestionMutation) ResetEdge

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

func (m *QuestionMutation) 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 (*QuestionMutation) ResetTags

func (m *QuestionMutation) ResetTags()

ResetTags resets all changes to the "tags" edge.

func (*QuestionMutation) ResetTitle

func (m *QuestionMutation) ResetTitle()

ResetTitle resets all changes to the "title" field.

func (*QuestionMutation) SetAuthorID

func (m *QuestionMutation) SetAuthorID(id int)

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

func (*QuestionMutation) SetContent

func (m *QuestionMutation) SetContent(s string)

SetContent sets the "content" field.

func (*QuestionMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*QuestionMutation) SetField

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

func (m *QuestionMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*QuestionMutation) SetTitle

func (m *QuestionMutation) SetTitle(s string)

SetTitle sets the "title" field.

func (*QuestionMutation) TagsCleared

func (m *QuestionMutation) TagsCleared() bool

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

func (*QuestionMutation) TagsIDs

func (m *QuestionMutation) TagsIDs() (ids []int)

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

func (*QuestionMutation) Title

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

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

func (QuestionMutation) Tx

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

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

func (*QuestionMutation) Type

func (m *QuestionMutation) Type() string

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

func (*QuestionMutation) Where

func (m *QuestionMutation) Where(ps ...predicate.Question)

Where appends a list predicates to the QuestionMutation builder.

func (*QuestionMutation) WhereP

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

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

type QuestionQuery

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

QuestionQuery is the builder for querying Question entities.

func (*QuestionQuery) Aggregate

func (qq *QuestionQuery) Aggregate(fns ...AggregateFunc) *QuestionSelect

Aggregate returns a QuestionSelect configured with the given aggregations.

func (*QuestionQuery) All

func (qq *QuestionQuery) All(ctx context.Context) ([]*Question, error)

All executes the query and returns a list of Questions.

func (*QuestionQuery) AllX

func (qq *QuestionQuery) AllX(ctx context.Context) []*Question

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

func (*QuestionQuery) Clone

func (qq *QuestionQuery) Clone() *QuestionQuery

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

func (*QuestionQuery) Count

func (qq *QuestionQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*QuestionQuery) CountX

func (qq *QuestionQuery) CountX(ctx context.Context) int

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

func (*QuestionQuery) Exist

func (qq *QuestionQuery) Exist(ctx context.Context) (bool, error)

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

func (*QuestionQuery) ExistX

func (qq *QuestionQuery) ExistX(ctx context.Context) bool

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

func (*QuestionQuery) First

func (qq *QuestionQuery) First(ctx context.Context) (*Question, error)

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

func (*QuestionQuery) FirstID

func (qq *QuestionQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*QuestionQuery) FirstIDX

func (qq *QuestionQuery) FirstIDX(ctx context.Context) int

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

func (*QuestionQuery) FirstX

func (qq *QuestionQuery) FirstX(ctx context.Context) *Question

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

func (*QuestionQuery) GroupBy

func (qq *QuestionQuery) GroupBy(field string, fields ...string) *QuestionGroupBy

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.Question.Query().
	GroupBy(question.FieldTitle).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*QuestionQuery) IDs

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

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

func (*QuestionQuery) IDsX

func (qq *QuestionQuery) IDsX(ctx context.Context) []int

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

func (*QuestionQuery) Limit

func (qq *QuestionQuery) Limit(limit int) *QuestionQuery

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

func (*QuestionQuery) Offset

func (qq *QuestionQuery) Offset(offset int) *QuestionQuery

Offset to start from.

func (*QuestionQuery) Only

func (qq *QuestionQuery) Only(ctx context.Context) (*Question, error)

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

func (*QuestionQuery) OnlyID

func (qq *QuestionQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*QuestionQuery) OnlyIDX

func (qq *QuestionQuery) OnlyIDX(ctx context.Context) int

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

func (*QuestionQuery) OnlyX

func (qq *QuestionQuery) OnlyX(ctx context.Context) *Question

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

func (*QuestionQuery) Order

Order specifies how the records should be ordered.

func (*QuestionQuery) QueryAnswers

func (qq *QuestionQuery) QueryAnswers() *AnswerQuery

QueryAnswers chains the current query on the "answers" edge.

func (*QuestionQuery) QueryAuthor

func (qq *QuestionQuery) QueryAuthor() *UserQuery

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

func (*QuestionQuery) QueryTags

func (qq *QuestionQuery) QueryTags() *TagQuery

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

func (*QuestionQuery) Select

func (qq *QuestionQuery) Select(fields ...string) *QuestionSelect

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.Question.Query().
	Select(question.FieldTitle).
	Scan(ctx, &v)

func (*QuestionQuery) Unique

func (qq *QuestionQuery) Unique(unique bool) *QuestionQuery

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

func (*QuestionQuery) Where

func (qq *QuestionQuery) Where(ps ...predicate.Question) *QuestionQuery

Where adds a new predicate for the QuestionQuery builder.

func (*QuestionQuery) WithAnswers

func (qq *QuestionQuery) WithAnswers(opts ...func(*AnswerQuery)) *QuestionQuery

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

func (*QuestionQuery) WithAuthor

func (qq *QuestionQuery) WithAuthor(opts ...func(*UserQuery)) *QuestionQuery

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

func (*QuestionQuery) WithTags

func (qq *QuestionQuery) WithTags(opts ...func(*TagQuery)) *QuestionQuery

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 QuestionSelect

type QuestionSelect struct {
	*QuestionQuery
	// contains filtered or unexported fields
}

QuestionSelect is the builder for selecting fields of Question entities.

func (*QuestionSelect) Aggregate

func (qs *QuestionSelect) Aggregate(fns ...AggregateFunc) *QuestionSelect

Aggregate adds the given aggregation functions to the selector query.

func (*QuestionSelect) Bool

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

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

func (*QuestionSelect) BoolX

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

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

func (*QuestionSelect) Bools

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

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

func (*QuestionSelect) BoolsX

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

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

func (*QuestionSelect) Float64

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

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

func (*QuestionSelect) Float64X

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

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

func (*QuestionSelect) Float64s

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

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

func (*QuestionSelect) Float64sX

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

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

func (*QuestionSelect) Int

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

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

func (*QuestionSelect) IntX

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

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

func (*QuestionSelect) Ints

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

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

func (*QuestionSelect) IntsX

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

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

func (*QuestionSelect) Scan

func (qs *QuestionSelect) Scan(ctx context.Context, v any) error

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

func (*QuestionSelect) ScanX

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

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

func (*QuestionSelect) String

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

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

func (*QuestionSelect) StringX

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

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

func (*QuestionSelect) Strings

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

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

func (*QuestionSelect) StringsX

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

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

type QuestionUpdate

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

QuestionUpdate is the builder for updating Question entities.

func (*QuestionUpdate) AddAnswerIDs

func (qu *QuestionUpdate) AddAnswerIDs(ids ...int) *QuestionUpdate

AddAnswerIDs adds the "answers" edge to the Answer entity by IDs.

func (*QuestionUpdate) AddAnswers

func (qu *QuestionUpdate) AddAnswers(a ...*Answer) *QuestionUpdate

AddAnswers adds the "answers" edges to the Answer entity.

func (*QuestionUpdate) AddTagIDs

func (qu *QuestionUpdate) AddTagIDs(ids ...int) *QuestionUpdate

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

func (*QuestionUpdate) AddTags

func (qu *QuestionUpdate) AddTags(t ...*Tag) *QuestionUpdate

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

func (*QuestionUpdate) ClearAnswers

func (qu *QuestionUpdate) ClearAnswers() *QuestionUpdate

ClearAnswers clears all "answers" edges to the Answer entity.

func (*QuestionUpdate) ClearAuthor

func (qu *QuestionUpdate) ClearAuthor() *QuestionUpdate

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

func (*QuestionUpdate) ClearTags

func (qu *QuestionUpdate) ClearTags() *QuestionUpdate

ClearTags clears all "tags" edges to the Tag entity.

func (*QuestionUpdate) Exec

func (qu *QuestionUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*QuestionUpdate) ExecX

func (qu *QuestionUpdate) ExecX(ctx context.Context)

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

func (*QuestionUpdate) Mutation

func (qu *QuestionUpdate) Mutation() *QuestionMutation

Mutation returns the QuestionMutation object of the builder.

func (*QuestionUpdate) RemoveAnswerIDs

func (qu *QuestionUpdate) RemoveAnswerIDs(ids ...int) *QuestionUpdate

RemoveAnswerIDs removes the "answers" edge to Answer entities by IDs.

func (*QuestionUpdate) RemoveAnswers

func (qu *QuestionUpdate) RemoveAnswers(a ...*Answer) *QuestionUpdate

RemoveAnswers removes "answers" edges to Answer entities.

func (*QuestionUpdate) RemoveTagIDs

func (qu *QuestionUpdate) RemoveTagIDs(ids ...int) *QuestionUpdate

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

func (*QuestionUpdate) RemoveTags

func (qu *QuestionUpdate) RemoveTags(t ...*Tag) *QuestionUpdate

RemoveTags removes "tags" edges to Tag entities.

func (*QuestionUpdate) Save

func (qu *QuestionUpdate) Save(ctx context.Context) (int, error)

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

func (*QuestionUpdate) SaveX

func (qu *QuestionUpdate) SaveX(ctx context.Context) int

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

func (*QuestionUpdate) SetAuthor

func (qu *QuestionUpdate) SetAuthor(u *User) *QuestionUpdate

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

func (*QuestionUpdate) SetAuthorID

func (qu *QuestionUpdate) SetAuthorID(id int) *QuestionUpdate

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

func (*QuestionUpdate) SetContent

func (qu *QuestionUpdate) SetContent(s string) *QuestionUpdate

SetContent sets the "content" field.

func (*QuestionUpdate) SetNillableAuthorID

func (qu *QuestionUpdate) SetNillableAuthorID(id *int) *QuestionUpdate

SetNillableAuthorID sets the "author" edge to the User entity by ID if the given value is not nil.

func (*QuestionUpdate) SetTitle

func (qu *QuestionUpdate) SetTitle(s string) *QuestionUpdate

SetTitle sets the "title" field.

func (*QuestionUpdate) Where

func (qu *QuestionUpdate) Where(ps ...predicate.Question) *QuestionUpdate

Where appends a list predicates to the QuestionUpdate builder.

type QuestionUpdateOne

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

QuestionUpdateOne is the builder for updating a single Question entity.

func (*QuestionUpdateOne) AddAnswerIDs

func (quo *QuestionUpdateOne) AddAnswerIDs(ids ...int) *QuestionUpdateOne

AddAnswerIDs adds the "answers" edge to the Answer entity by IDs.

func (*QuestionUpdateOne) AddAnswers

func (quo *QuestionUpdateOne) AddAnswers(a ...*Answer) *QuestionUpdateOne

AddAnswers adds the "answers" edges to the Answer entity.

func (*QuestionUpdateOne) AddTagIDs

func (quo *QuestionUpdateOne) AddTagIDs(ids ...int) *QuestionUpdateOne

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

func (*QuestionUpdateOne) AddTags

func (quo *QuestionUpdateOne) AddTags(t ...*Tag) *QuestionUpdateOne

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

func (*QuestionUpdateOne) ClearAnswers

func (quo *QuestionUpdateOne) ClearAnswers() *QuestionUpdateOne

ClearAnswers clears all "answers" edges to the Answer entity.

func (*QuestionUpdateOne) ClearAuthor

func (quo *QuestionUpdateOne) ClearAuthor() *QuestionUpdateOne

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

func (*QuestionUpdateOne) ClearTags

func (quo *QuestionUpdateOne) ClearTags() *QuestionUpdateOne

ClearTags clears all "tags" edges to the Tag entity.

func (*QuestionUpdateOne) Exec

func (quo *QuestionUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*QuestionUpdateOne) ExecX

func (quo *QuestionUpdateOne) ExecX(ctx context.Context)

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

func (*QuestionUpdateOne) Mutation

func (quo *QuestionUpdateOne) Mutation() *QuestionMutation

Mutation returns the QuestionMutation object of the builder.

func (*QuestionUpdateOne) RemoveAnswerIDs

func (quo *QuestionUpdateOne) RemoveAnswerIDs(ids ...int) *QuestionUpdateOne

RemoveAnswerIDs removes the "answers" edge to Answer entities by IDs.

func (*QuestionUpdateOne) RemoveAnswers

func (quo *QuestionUpdateOne) RemoveAnswers(a ...*Answer) *QuestionUpdateOne

RemoveAnswers removes "answers" edges to Answer entities.

func (*QuestionUpdateOne) RemoveTagIDs

func (quo *QuestionUpdateOne) RemoveTagIDs(ids ...int) *QuestionUpdateOne

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

func (*QuestionUpdateOne) RemoveTags

func (quo *QuestionUpdateOne) RemoveTags(t ...*Tag) *QuestionUpdateOne

RemoveTags removes "tags" edges to Tag entities.

func (*QuestionUpdateOne) Save

func (quo *QuestionUpdateOne) Save(ctx context.Context) (*Question, error)

Save executes the query and returns the updated Question entity.

func (*QuestionUpdateOne) SaveX

func (quo *QuestionUpdateOne) SaveX(ctx context.Context) *Question

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

func (*QuestionUpdateOne) Select

func (quo *QuestionUpdateOne) Select(field string, fields ...string) *QuestionUpdateOne

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

func (*QuestionUpdateOne) SetAuthor

func (quo *QuestionUpdateOne) SetAuthor(u *User) *QuestionUpdateOne

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

func (*QuestionUpdateOne) SetAuthorID

func (quo *QuestionUpdateOne) SetAuthorID(id int) *QuestionUpdateOne

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

func (*QuestionUpdateOne) SetContent

func (quo *QuestionUpdateOne) SetContent(s string) *QuestionUpdateOne

SetContent sets the "content" field.

func (*QuestionUpdateOne) SetNillableAuthorID

func (quo *QuestionUpdateOne) SetNillableAuthorID(id *int) *QuestionUpdateOne

SetNillableAuthorID sets the "author" edge to the User entity by ID if the given value is not nil.

func (*QuestionUpdateOne) SetTitle

func (quo *QuestionUpdateOne) SetTitle(s string) *QuestionUpdateOne

SetTitle sets the "title" field.

func (*QuestionUpdateOne) Where

Where appends a list predicates to the QuestionUpdate builder.

type Questions

type Questions []*Question

Questions is a parsable slice of Question.

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

hook := func(next ent.Rollbacker) ent.Rollbacker {
	return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error {
		// Do some stuff before.
		if err := next.Rollback(ctx, tx); err != nil {
			return err
		}
		// Do some stuff after.
		return nil
	})
}

type Rollbacker

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

Rollbacker is the interface that wraps the Rollback method.

type Tag

type Tag struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the 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) QueryQuestions

func (t *Tag) QueryQuestions() *QuestionQuery

QueryQuestions queries the "questions" 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.

func (*Tag) Value

func (t *Tag) Value(name string) (ent.Value, error)

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

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 builder for creating a Tag entity.

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

func (*TagClient) DeleteOneID

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

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

func (*TagClient) Get

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

Get returns a Tag entity by its id.

func (*TagClient) GetX

func (c *TagClient) GetX(ctx context.Context, id int) *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) Intercept

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

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

func (*TagClient) Interceptors

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

Interceptors returns the client interceptors.

func (*TagClient) MapCreateBulk

func (c *TagClient) MapCreateBulk(slice any, setFunc func(*TagCreate, int)) *TagCreateBulk

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

func (*TagClient) Query

func (c *TagClient) Query() *TagQuery

Query returns a query builder for Tag.

func (*TagClient) QueryQuestions

func (c *TagClient) QueryQuestions(t *Tag) *QuestionQuery

QueryQuestions queries the questions 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 int) *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) AddQuestionIDs

func (tc *TagCreate) AddQuestionIDs(ids ...int) *TagCreate

AddQuestionIDs adds the "questions" edge to the Question entity by IDs.

func (*TagCreate) AddQuestions

func (tc *TagCreate) AddQuestions(q ...*Question) *TagCreate

AddQuestions adds the "questions" edges to the Question entity.

func (*TagCreate) Exec

func (tc *TagCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*TagCreate) ExecX

func (tc *TagCreate) ExecX(ctx context.Context)

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

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

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

SetName sets the "name" field.

type TagCreateBulk

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

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

func (*TagCreateBulk) Exec

func (tcb *TagCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*TagCreateBulk) ExecX

func (tcb *TagCreateBulk) ExecX(ctx context.Context)

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

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 appends a list predicates 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.

func (*TagDeleteOne) Where

func (tdo *TagDeleteOne) Where(ps ...predicate.Tag) *TagDeleteOne

Where appends a list predicates to the TagDelete builder.

type TagEdges

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

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

func (TagEdges) QuestionsOrErr

func (e TagEdges) QuestionsOrErr() ([]*Question, error)

QuestionsOrErr returns the Questions 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 (s *TagGroupBy) Bool(ctx context.Context) (_ bool, err error)

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

func (*TagGroupBy) BoolX

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

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

func (*TagGroupBy) Bools

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

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

func (*TagGroupBy) BoolsX

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

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

func (*TagGroupBy) Float64

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

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

func (*TagGroupBy) Float64X

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

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

func (*TagGroupBy) Float64s

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

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

func (*TagGroupBy) Float64sX

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

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

func (*TagGroupBy) Int

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

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

func (*TagGroupBy) IntX

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

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

func (*TagGroupBy) Ints

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

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

func (*TagGroupBy) IntsX

func (s *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 any) error

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

func (*TagGroupBy) ScanX

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

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

func (*TagGroupBy) String

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

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

func (*TagGroupBy) StringX

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

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

func (*TagGroupBy) Strings

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

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

func (*TagGroupBy) StringsX

func (s *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) AddQuestionIDs

func (m *TagMutation) AddQuestionIDs(ids ...int)

AddQuestionIDs adds the "questions" edge to the Question 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) ClearQuestions

func (m *TagMutation) ClearQuestions()

ClearQuestions clears the "questions" edge to the Question 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) 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 int, exists bool)

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

func (*TagMutation) IDs

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

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

func (*TagMutation) Name

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

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

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

func (m *TagMutation) Op() Op

Op returns the operation name.

func (*TagMutation) QuestionsCleared

func (m *TagMutation) QuestionsCleared() bool

QuestionsCleared reports if the "questions" edge to the Question entity was cleared.

func (*TagMutation) QuestionsIDs

func (m *TagMutation) QuestionsIDs() (ids []int)

QuestionsIDs returns the "questions" edge IDs in the mutation.

func (*TagMutation) RemoveQuestionIDs

func (m *TagMutation) RemoveQuestionIDs(ids ...int)

RemoveQuestionIDs removes the "questions" edge to the Question 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) RemovedQuestionsIDs

func (m *TagMutation) RemovedQuestionsIDs() (ids []int)

RemovedQuestions returns the removed IDs of the "questions" edge to the Question entity.

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

func (m *TagMutation) ResetQuestions()

ResetQuestions resets all changes to the "questions" edge.

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

func (m *TagMutation) SetName(s string)

SetName sets the "name" field.

func (*TagMutation) SetOp

func (m *TagMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

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

func (m *TagMutation) Where(ps ...predicate.Tag)

Where appends a list predicates to the TagMutation builder.

func (*TagMutation) WhereP

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

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

type TagQuery

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

TagQuery is the builder for querying Tag entities.

func (*TagQuery) Aggregate

func (tq *TagQuery) Aggregate(fns ...AggregateFunc) *TagSelect

Aggregate returns a TagSelect configured with the given aggregations.

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

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

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

func (*TagQuery) IDs

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

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

func (*TagQuery) IDsX

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

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

func (*TagQuery) Limit

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

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

func (*TagQuery) Offset

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

Offset to start from.

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 more than one Tag entity is found. Returns a *NotFoundError when no Tag entities are found.

func (*TagQuery) OnlyID

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

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

func (*TagQuery) OnlyIDX

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

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 ...tag.OrderOption) *TagQuery

Order specifies how the records should be ordered.

func (*TagQuery) QueryQuestions

func (tq *TagQuery) QueryQuestions() *QuestionQuery

QueryQuestions chains the current query on the "questions" edge.

func (*TagQuery) Select

func (tq *TagQuery) Select(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 {
	Name string `json:"name,omitempty"`
}

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

func (*TagQuery) Unique

func (tq *TagQuery) Unique(unique bool) *TagQuery

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

func (*TagQuery) Where

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

Where adds a new predicate for the TagQuery builder.

func (*TagQuery) WithQuestions

func (tq *TagQuery) WithQuestions(opts ...func(*QuestionQuery)) *TagQuery

WithQuestions tells the query-builder to eager-load the nodes that are connected to the "questions" 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) Aggregate

func (ts *TagSelect) Aggregate(fns ...AggregateFunc) *TagSelect

Aggregate adds the given aggregation functions to the selector query.

func (*TagSelect) Bool

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

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

func (*TagSelect) Bools

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

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

func (*TagSelect) Float64

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

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

func (*TagSelect) Float64s

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

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

func (*TagSelect) Int

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

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

func (*TagSelect) Ints

func (s *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 (s *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 any) error

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

func (*TagSelect) ScanX

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

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

func (*TagSelect) String

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

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

func (*TagSelect) Strings

func (s *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 (s *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) AddQuestionIDs

func (tu *TagUpdate) AddQuestionIDs(ids ...int) *TagUpdate

AddQuestionIDs adds the "questions" edge to the Question entity by IDs.

func (*TagUpdate) AddQuestions

func (tu *TagUpdate) AddQuestions(q ...*Question) *TagUpdate

AddQuestions adds the "questions" edges to the Question entity.

func (*TagUpdate) ClearQuestions

func (tu *TagUpdate) ClearQuestions() *TagUpdate

ClearQuestions clears all "questions" edges to the Question 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) RemoveQuestionIDs

func (tu *TagUpdate) RemoveQuestionIDs(ids ...int) *TagUpdate

RemoveQuestionIDs removes the "questions" edge to Question entities by IDs.

func (*TagUpdate) RemoveQuestions

func (tu *TagUpdate) RemoveQuestions(q ...*Question) *TagUpdate

RemoveQuestions removes "questions" edges to Question 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) SetName

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

SetName sets the "name" field.

func (*TagUpdate) Where

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

Where appends a list predicates to 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) AddQuestionIDs

func (tuo *TagUpdateOne) AddQuestionIDs(ids ...int) *TagUpdateOne

AddQuestionIDs adds the "questions" edge to the Question entity by IDs.

func (*TagUpdateOne) AddQuestions

func (tuo *TagUpdateOne) AddQuestions(q ...*Question) *TagUpdateOne

AddQuestions adds the "questions" edges to the Question entity.

func (*TagUpdateOne) ClearQuestions

func (tuo *TagUpdateOne) ClearQuestions() *TagUpdateOne

ClearQuestions clears all "questions" edges to the Question 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) RemoveQuestionIDs

func (tuo *TagUpdateOne) RemoveQuestionIDs(ids ...int) *TagUpdateOne

RemoveQuestionIDs removes the "questions" edge to Question entities by IDs.

func (*TagUpdateOne) RemoveQuestions

func (tuo *TagUpdateOne) RemoveQuestions(q ...*Question) *TagUpdateOne

RemoveQuestions removes "questions" edges to Question 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) Select

func (tuo *TagUpdateOne) Select(field string, fields ...string) *TagUpdateOne

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

func (*TagUpdateOne) SetName

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

SetName sets the "name" field.

func (*TagUpdateOne) Where

func (tuo *TagUpdateOne) Where(ps ...predicate.Tag) *TagUpdateOne

Where appends a list predicates to the TagUpdate builder.

type Tags

type Tags []*Tag

Tags is a parsable slice of Tag.

type TraverseFunc

type TraverseFunc = ent.TraverseFunc

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

type Traverser

type Traverser = ent.Traverser

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

type Tx

type Tx struct {

	// Answer is the client for interacting with the Answer builders.
	Answer *AnswerClient
	// Question is the client for interacting with the Question builders.
	Question *QuestionClient
	// Tag is the client for interacting with the Tag builders.
	Tag *TagClient
	// User is the client for interacting with the User builders.
	User *UserClient
	// contains filtered or unexported fields
}

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

func TxFromContext

func TxFromContext(ctx context.Context) *Tx

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

func (*Tx) Client

func (tx *Tx) Client() *Client

Client returns a Client that binds to current transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) OnCommit

func (tx *Tx) OnCommit(f CommitHook)

OnCommit adds a hook to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f RollbackHook)

OnRollback adds a hook to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

type User

type User struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Username holds the value of the "username" field.
	Username string `json:"username,omitempty"`
	// Email holds the value of the "email" field.
	Email string `json:"email,omitempty"`
	// Password holds the value of the "password" field.
	Password string `json:"-"`
	// CreatedAt holds the value of the "created_at" field.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// Superuser holds the value of the "superuser" field.
	Superuser bool `json:"superuser,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the UserQuery when eager-loading is set.
	Edges UserEdges `json:"edges"`
	// contains filtered or unexported fields
}

User is the model entity for the User schema.

func (*User) QueryAnswers

func (u *User) QueryAnswers() *AnswerQuery

QueryAnswers queries the "answers" edge of the User entity.

func (*User) QueryQuestions

func (u *User) QueryQuestions() *QuestionQuery

QueryQuestions queries the "questions" edge of the User entity.

func (*User) QueryTags

func (u *User) QueryTags() *TagQuery

QueryTags queries the "tags" edge of the User entity.

func (*User) String

func (u *User) String() string

String implements the fmt.Stringer.

func (*User) Unwrap

func (u *User) Unwrap() *User

Unwrap unwraps the User entity that was returned from a transaction after it was closed, so that all future queries will be executed through the driver which created the transaction.

func (*User) Update

func (u *User) Update() *UserUpdateOne

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

func (*User) Value

func (u *User) Value(name string) (ent.Value, error)

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

type UserClient

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

UserClient is a client for the User schema.

func NewUserClient

func NewUserClient(c config) *UserClient

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

func (*UserClient) Create

func (c *UserClient) Create() *UserCreate

Create returns a builder for creating a User entity.

func (*UserClient) CreateBulk

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

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

func (*UserClient) Delete

func (c *UserClient) Delete() *UserDelete

Delete returns a delete builder for User.

func (*UserClient) DeleteOne

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

DeleteOne returns a builder for deleting the given entity.

func (*UserClient) DeleteOneID

func (c *UserClient) DeleteOneID(id int) *UserDeleteOne

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

func (*UserClient) Get

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

Get returns a User entity by its id.

func (*UserClient) GetX

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

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

func (*UserClient) Hooks

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

Hooks returns the client hooks.

func (*UserClient) Intercept

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

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

func (*UserClient) Interceptors

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

Interceptors returns the client interceptors.

func (*UserClient) MapCreateBulk

func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk

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

func (*UserClient) Query

func (c *UserClient) Query() *UserQuery

Query returns a query builder for User.

func (*UserClient) QueryAnswers

func (c *UserClient) QueryAnswers(u *User) *AnswerQuery

QueryAnswers queries the answers edge of a User.

func (*UserClient) QueryQuestions

func (c *UserClient) QueryQuestions(u *User) *QuestionQuery

QueryQuestions queries the questions edge of a User.

func (*UserClient) QueryTags

func (c *UserClient) QueryTags(u *User) *TagQuery

QueryTags queries the tags edge of a User.

func (*UserClient) Update

func (c *UserClient) Update() *UserUpdate

Update returns an update builder for User.

func (*UserClient) UpdateOne

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

UpdateOne returns an update builder for the given entity.

func (*UserClient) UpdateOneID

func (c *UserClient) UpdateOneID(id int) *UserUpdateOne

UpdateOneID returns an update builder for the given id.

func (*UserClient) Use

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

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

type UserCreate

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

UserCreate is the builder for creating a User entity.

func (*UserCreate) AddAnswerIDs

func (uc *UserCreate) AddAnswerIDs(ids ...int) *UserCreate

AddAnswerIDs adds the "answers" edge to the Answer entity by IDs.

func (*UserCreate) AddAnswers

func (uc *UserCreate) AddAnswers(a ...*Answer) *UserCreate

AddAnswers adds the "answers" edges to the Answer entity.

func (*UserCreate) AddQuestionIDs

func (uc *UserCreate) AddQuestionIDs(ids ...int) *UserCreate

AddQuestionIDs adds the "questions" edge to the Question entity by IDs.

func (*UserCreate) AddQuestions

func (uc *UserCreate) AddQuestions(q ...*Question) *UserCreate

AddQuestions adds the "questions" edges to the Question entity.

func (*UserCreate) AddTagIDs

func (uc *UserCreate) AddTagIDs(ids ...int) *UserCreate

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

func (*UserCreate) AddTags

func (uc *UserCreate) AddTags(t ...*Tag) *UserCreate

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

func (*UserCreate) Exec

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

Exec executes the query.

func (*UserCreate) ExecX

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

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

func (*UserCreate) Mutation

func (uc *UserCreate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserCreate) Save

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

Save creates the User in the database.

func (*UserCreate) SaveX

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

SaveX calls Save and panics if Save returns an error.

func (*UserCreate) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*UserCreate) SetEmail

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

SetEmail sets the "email" field.

func (*UserCreate) SetNillableCreatedAt

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

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

func (*UserCreate) SetNillableSuperuser

func (uc *UserCreate) SetNillableSuperuser(b *bool) *UserCreate

SetNillableSuperuser sets the "superuser" field if the given value is not nil.

func (*UserCreate) SetPassword

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

SetPassword sets the "password" field.

func (*UserCreate) SetSuperuser

func (uc *UserCreate) SetSuperuser(b bool) *UserCreate

SetSuperuser sets the "superuser" field.

func (*UserCreate) SetUsername

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

SetUsername sets the "username" field.

type UserCreateBulk

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

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

func (*UserCreateBulk) Exec

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

Exec executes the query.

func (*UserCreateBulk) ExecX

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

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

func (*UserCreateBulk) Save

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

Save creates the User entities in the database.

func (*UserCreateBulk) SaveX

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

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

type UserDelete

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

UserDelete is the builder for deleting a User entity.

func (*UserDelete) Exec

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

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

func (*UserDelete) ExecX

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

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

func (*UserDelete) Where

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

Where appends a list predicates to the UserDelete builder.

type UserDeleteOne

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

UserDeleteOne is the builder for deleting a single User entity.

func (*UserDeleteOne) Exec

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

Exec executes the deletion query.

func (*UserDeleteOne) ExecX

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

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

func (*UserDeleteOne) Where

func (udo *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne

Where appends a list predicates to the UserDelete builder.

type UserEdges

type UserEdges struct {
	// Questions holds the value of the questions edge.
	Questions []*Question `json:"questions,omitempty"`
	// Answers holds the value of the answers edge.
	Answers []*Answer `json:"answers,omitempty"`
	// Tags holds the value of the tags edge.
	Tags []*Tag `json:"tags,omitempty"`
	// contains filtered or unexported fields
}

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

func (UserEdges) AnswersOrErr

func (e UserEdges) AnswersOrErr() ([]*Answer, error)

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

func (UserEdges) QuestionsOrErr

func (e UserEdges) QuestionsOrErr() ([]*Question, error)

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

func (UserEdges) TagsOrErr

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

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

type UserGroupBy

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

UserGroupBy is the group-by builder for User entities.

func (*UserGroupBy) Aggregate

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

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

func (*UserGroupBy) Bool

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

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

func (*UserGroupBy) BoolX

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

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

func (*UserGroupBy) Bools

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

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

func (*UserGroupBy) BoolsX

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

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

func (*UserGroupBy) Float64

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

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

func (*UserGroupBy) Float64X

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

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

func (*UserGroupBy) Float64s

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

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

func (*UserGroupBy) Float64sX

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

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

func (*UserGroupBy) Int

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

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

func (*UserGroupBy) IntX

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

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

func (*UserGroupBy) Ints

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

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

func (*UserGroupBy) IntsX

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

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

func (*UserGroupBy) Scan

func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error

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

func (*UserGroupBy) ScanX

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

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

func (*UserGroupBy) String

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

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

func (*UserGroupBy) StringX

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

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

func (*UserGroupBy) Strings

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

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

func (*UserGroupBy) StringsX

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

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

type UserMutation

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

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

func (*UserMutation) AddAnswerIDs

func (m *UserMutation) AddAnswerIDs(ids ...int)

AddAnswerIDs adds the "answers" edge to the Answer entity by ids.

func (*UserMutation) AddField

func (m *UserMutation) AddField(name string, value ent.Value) error

AddField adds the value to the field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

func (*UserMutation) AddQuestionIDs

func (m *UserMutation) AddQuestionIDs(ids ...int)

AddQuestionIDs adds the "questions" edge to the Question entity by ids.

func (*UserMutation) AddTagIDs

func (m *UserMutation) AddTagIDs(ids ...int)

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

func (*UserMutation) AddedEdges

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

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

func (*UserMutation) AddedField

func (m *UserMutation) AddedField(name string) (ent.Value, bool)

AddedField returns the numeric value that was incremented/decremented on a field with the given name. The second boolean return value indicates that this field was not set, or was not defined in the schema.

func (*UserMutation) AddedFields

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

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

func (*UserMutation) AddedIDs

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

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

func (*UserMutation) AnswersCleared

func (m *UserMutation) AnswersCleared() bool

AnswersCleared reports if the "answers" edge to the Answer entity was cleared.

func (*UserMutation) AnswersIDs

func (m *UserMutation) AnswersIDs() (ids []int)

AnswersIDs returns the "answers" edge IDs in the mutation.

func (*UserMutation) ClearAnswers

func (m *UserMutation) ClearAnswers()

ClearAnswers clears the "answers" edge to the Answer entity.

func (*UserMutation) ClearEdge

func (m *UserMutation) ClearEdge(name string) error

ClearEdge clears the value of the edge with the given name. It returns an error if that edge is not defined in the schema.

func (*UserMutation) ClearField

func (m *UserMutation) ClearField(name string) error

ClearField clears the value of the field with the given name. It returns an error if the field is not defined in the schema.

func (*UserMutation) ClearQuestions

func (m *UserMutation) ClearQuestions()

ClearQuestions clears the "questions" edge to the Question entity.

func (*UserMutation) ClearTags

func (m *UserMutation) ClearTags()

ClearTags clears the "tags" edge to the Tag entity.

func (*UserMutation) ClearedEdges

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

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

func (*UserMutation) ClearedFields

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

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

func (UserMutation) Client

func (m UserMutation) Client() *Client

Client returns a new `ent.Client` from the mutation. If the mutation was executed in a transaction (ent.Tx), a transactional client is returned.

func (*UserMutation) CreatedAt

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

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

func (*UserMutation) EdgeCleared

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

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

func (*UserMutation) Email

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

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

func (*UserMutation) Field

func (m *UserMutation) Field(name string) (ent.Value, bool)

Field returns the value of a field with the given name. The second boolean return value indicates that this field was not set, or was not defined in the schema.

func (*UserMutation) FieldCleared

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

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

func (*UserMutation) Fields

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

Fields returns all fields that were changed during this mutation. Note that in order to get all numeric fields that were incremented/decremented, call AddedFields().

func (*UserMutation) ID

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

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

func (*UserMutation) IDs

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

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

func (*UserMutation) OldCreatedAt

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

OldCreatedAt returns the old "created_at" field's value of the User entity. If the User object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*UserMutation) OldEmail

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

OldEmail returns the old "email" field's value of the User entity. If the User object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*UserMutation) OldField

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

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

func (*UserMutation) OldPassword

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

OldPassword returns the old "password" field's value of the User entity. If the User object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*UserMutation) OldSuperuser

func (m *UserMutation) OldSuperuser(ctx context.Context) (v bool, err error)

OldSuperuser returns the old "superuser" field's value of the User entity. If the User object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*UserMutation) OldUsername

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

OldUsername returns the old "username" field's value of the User entity. If the User object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*UserMutation) Op

func (m *UserMutation) Op() Op

Op returns the operation name.

func (*UserMutation) Password

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

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

func (*UserMutation) QuestionsCleared

func (m *UserMutation) QuestionsCleared() bool

QuestionsCleared reports if the "questions" edge to the Question entity was cleared.

func (*UserMutation) QuestionsIDs

func (m *UserMutation) QuestionsIDs() (ids []int)

QuestionsIDs returns the "questions" edge IDs in the mutation.

func (*UserMutation) RemoveAnswerIDs

func (m *UserMutation) RemoveAnswerIDs(ids ...int)

RemoveAnswerIDs removes the "answers" edge to the Answer entity by IDs.

func (*UserMutation) RemoveQuestionIDs

func (m *UserMutation) RemoveQuestionIDs(ids ...int)

RemoveQuestionIDs removes the "questions" edge to the Question entity by IDs.

func (*UserMutation) RemoveTagIDs

func (m *UserMutation) RemoveTagIDs(ids ...int)

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

func (*UserMutation) RemovedAnswersIDs

func (m *UserMutation) RemovedAnswersIDs() (ids []int)

RemovedAnswers returns the removed IDs of the "answers" edge to the Answer entity.

func (*UserMutation) RemovedEdges

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

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

func (*UserMutation) RemovedIDs

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

RemovedIDs returns all IDs (to other nodes) that were removed for the edge with the given name in this mutation.

func (*UserMutation) RemovedQuestionsIDs

func (m *UserMutation) RemovedQuestionsIDs() (ids []int)

RemovedQuestions returns the removed IDs of the "questions" edge to the Question entity.

func (*UserMutation) RemovedTagsIDs

func (m *UserMutation) RemovedTagsIDs() (ids []int)

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

func (*UserMutation) ResetAnswers

func (m *UserMutation) ResetAnswers()

ResetAnswers resets all changes to the "answers" edge.

func (*UserMutation) ResetCreatedAt

func (m *UserMutation) ResetCreatedAt()

ResetCreatedAt resets all changes to the "created_at" field.

func (*UserMutation) ResetEdge

func (m *UserMutation) ResetEdge(name string) error

ResetEdge resets all changes to the edge with the given name in this mutation. It returns an error if the edge is not defined in the schema.

func (*UserMutation) ResetEmail

func (m *UserMutation) ResetEmail()

ResetEmail resets all changes to the "email" field.

func (*UserMutation) ResetField

func (m *UserMutation) ResetField(name string) error

ResetField resets all changes in the mutation for the field with the given name. It returns an error if the field is not defined in the schema.

func (*UserMutation) ResetPassword

func (m *UserMutation) ResetPassword()

ResetPassword resets all changes to the "password" field.

func (*UserMutation) ResetQuestions

func (m *UserMutation) ResetQuestions()

ResetQuestions resets all changes to the "questions" edge.

func (*UserMutation) ResetSuperuser

func (m *UserMutation) ResetSuperuser()

ResetSuperuser resets all changes to the "superuser" field.

func (*UserMutation) ResetTags

func (m *UserMutation) ResetTags()

ResetTags resets all changes to the "tags" edge.

func (*UserMutation) ResetUsername

func (m *UserMutation) ResetUsername()

ResetUsername resets all changes to the "username" field.

func (*UserMutation) SetCreatedAt

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

SetCreatedAt sets the "created_at" field.

func (*UserMutation) SetEmail

func (m *UserMutation) SetEmail(s string)

SetEmail sets the "email" field.

func (*UserMutation) SetField

func (m *UserMutation) SetField(name string, value ent.Value) error

SetField sets the value of a field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

func (*UserMutation) SetOp

func (m *UserMutation) SetOp(op Op)

SetOp allows setting the mutation operation.

func (*UserMutation) SetPassword

func (m *UserMutation) SetPassword(s string)

SetPassword sets the "password" field.

func (*UserMutation) SetSuperuser

func (m *UserMutation) SetSuperuser(b bool)

SetSuperuser sets the "superuser" field.

func (*UserMutation) SetUsername

func (m *UserMutation) SetUsername(s string)

SetUsername sets the "username" field.

func (*UserMutation) Superuser

func (m *UserMutation) Superuser() (r bool, exists bool)

Superuser returns the value of the "superuser" field in the mutation.

func (*UserMutation) TagsCleared

func (m *UserMutation) TagsCleared() bool

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

func (*UserMutation) TagsIDs

func (m *UserMutation) TagsIDs() (ids []int)

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

func (UserMutation) Tx

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

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

func (*UserMutation) Type

func (m *UserMutation) Type() string

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

func (*UserMutation) Username

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

Username returns the value of the "username" field in the mutation.

func (*UserMutation) Where

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

Where appends a list predicates to the UserMutation builder.

func (*UserMutation) WhereP

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

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

type UserQuery

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

UserQuery is the builder for querying User entities.

func (*UserQuery) Aggregate

func (uq *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect

Aggregate returns a UserSelect configured with the given aggregations.

func (*UserQuery) All

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

All executes the query and returns a list of Users.

func (*UserQuery) AllX

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

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

func (*UserQuery) Clone

func (uq *UserQuery) Clone() *UserQuery

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

func (*UserQuery) Count

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

Count returns the count of the given query.

func (*UserQuery) CountX

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

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

func (*UserQuery) Exist

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

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

func (*UserQuery) ExistX

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

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

func (*UserQuery) First

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

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

func (*UserQuery) FirstID

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

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

func (*UserQuery) FirstIDX

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

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

func (*UserQuery) FirstX

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

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

func (*UserQuery) GroupBy

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

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

Example:

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

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

func (*UserQuery) IDs

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

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

func (*UserQuery) IDsX

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

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

func (*UserQuery) Limit

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

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

func (*UserQuery) Offset

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

Offset to start from.

func (*UserQuery) Only

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

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

func (*UserQuery) OnlyID

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

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

func (*UserQuery) OnlyIDX

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

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

func (*UserQuery) OnlyX

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

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

func (*UserQuery) Order

func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery

Order specifies how the records should be ordered.

func (*UserQuery) QueryAnswers

func (uq *UserQuery) QueryAnswers() *AnswerQuery

QueryAnswers chains the current query on the "answers" edge.

func (*UserQuery) QueryQuestions

func (uq *UserQuery) QueryQuestions() *QuestionQuery

QueryQuestions chains the current query on the "questions" edge.

func (*UserQuery) QueryTags

func (uq *UserQuery) QueryTags() *TagQuery

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

func (*UserQuery) Select

func (uq *UserQuery) Select(fields ...string) *UserSelect

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

Example:

var v []struct {
	Username string `json:"username,omitempty"`
}

client.User.Query().
	Select(user.FieldUsername).
	Scan(ctx, &v)

func (*UserQuery) Unique

func (uq *UserQuery) Unique(unique bool) *UserQuery

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

func (*UserQuery) Where

func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery

Where adds a new predicate for the UserQuery builder.

func (*UserQuery) WithAnswers

func (uq *UserQuery) WithAnswers(opts ...func(*AnswerQuery)) *UserQuery

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

func (*UserQuery) WithQuestions

func (uq *UserQuery) WithQuestions(opts ...func(*QuestionQuery)) *UserQuery

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

func (*UserQuery) WithTags

func (uq *UserQuery) WithTags(opts ...func(*TagQuery)) *UserQuery

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 UserSelect

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

UserSelect is the builder for selecting fields of User entities.

func (*UserSelect) Aggregate

func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect

Aggregate adds the given aggregation functions to the selector query.

func (*UserSelect) Bool

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

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

func (*UserSelect) BoolX

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

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

func (*UserSelect) Bools

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

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

func (*UserSelect) BoolsX

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

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

func (*UserSelect) Float64

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

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

func (*UserSelect) Float64X

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

Float64X is like Float64, but panics if an error occurs.

func (*UserSelect) Float64s

func (s *UserSelect) Float64s(ctx context.Context) ([]float64, error)

Float64s returns list of float64s from a selector. It is only allowed when selecting one field.

func (*UserSelect) Float64sX

func (s *UserSelect) Float64sX(ctx context.Context) []float64

Float64sX is like Float64s, but panics if an error occurs.

func (*UserSelect) Int

func (s *UserSelect) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a selector. It is only allowed when selecting one field.

func (*UserSelect) IntX

func (s *UserSelect) IntX(ctx context.Context) int

IntX is like Int, but panics if an error occurs.

func (*UserSelect) Ints

func (s *UserSelect) Ints(ctx context.Context) ([]int, error)

Ints returns list of ints from a selector. It is only allowed when selecting one field.

func (*UserSelect) IntsX

func (s *UserSelect) IntsX(ctx context.Context) []int

IntsX is like Ints, but panics if an error occurs.

func (*UserSelect) Scan

func (us *UserSelect) Scan(ctx context.Context, v any) error

Scan applies the selector query and scans the result into the given value.

func (*UserSelect) ScanX

func (s *UserSelect) ScanX(ctx context.Context, v any)

ScanX is like Scan, but panics if an error occurs.

func (*UserSelect) String

func (s *UserSelect) String(ctx context.Context) (_ string, err error)

String returns a single string from a selector. It is only allowed when selecting one field.

func (*UserSelect) StringX

func (s *UserSelect) StringX(ctx context.Context) string

StringX is like String, but panics if an error occurs.

func (*UserSelect) Strings

func (s *UserSelect) Strings(ctx context.Context) ([]string, error)

Strings returns list of strings from a selector. It is only allowed when selecting one field.

func (*UserSelect) StringsX

func (s *UserSelect) StringsX(ctx context.Context) []string

StringsX is like Strings, but panics if an error occurs.

type UserUpdate

type UserUpdate struct {
	// contains filtered or unexported fields
}

UserUpdate is the builder for updating User entities.

func (*UserUpdate) AddAnswerIDs

func (uu *UserUpdate) AddAnswerIDs(ids ...int) *UserUpdate

AddAnswerIDs adds the "answers" edge to the Answer entity by IDs.

func (*UserUpdate) AddAnswers

func (uu *UserUpdate) AddAnswers(a ...*Answer) *UserUpdate

AddAnswers adds the "answers" edges to the Answer entity.

func (*UserUpdate) AddQuestionIDs

func (uu *UserUpdate) AddQuestionIDs(ids ...int) *UserUpdate

AddQuestionIDs adds the "questions" edge to the Question entity by IDs.

func (*UserUpdate) AddQuestions

func (uu *UserUpdate) AddQuestions(q ...*Question) *UserUpdate

AddQuestions adds the "questions" edges to the Question entity.

func (*UserUpdate) AddTagIDs

func (uu *UserUpdate) AddTagIDs(ids ...int) *UserUpdate

AddTagIDs adds the "tags" edge to the Tag entity by IDs.

func (*UserUpdate) AddTags

func (uu *UserUpdate) AddTags(t ...*Tag) *UserUpdate

AddTags adds the "tags" edges to the Tag entity.

func (*UserUpdate) ClearAnswers

func (uu *UserUpdate) ClearAnswers() *UserUpdate

ClearAnswers clears all "answers" edges to the Answer entity.

func (*UserUpdate) ClearQuestions

func (uu *UserUpdate) ClearQuestions() *UserUpdate

ClearQuestions clears all "questions" edges to the Question entity.

func (*UserUpdate) ClearTags

func (uu *UserUpdate) ClearTags() *UserUpdate

ClearTags clears all "tags" edges to the Tag entity.

func (*UserUpdate) Exec

func (uu *UserUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*UserUpdate) ExecX

func (uu *UserUpdate) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*UserUpdate) Mutation

func (uu *UserUpdate) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdate) RemoveAnswerIDs

func (uu *UserUpdate) RemoveAnswerIDs(ids ...int) *UserUpdate

RemoveAnswerIDs removes the "answers" edge to Answer entities by IDs.

func (*UserUpdate) RemoveAnswers

func (uu *UserUpdate) RemoveAnswers(a ...*Answer) *UserUpdate

RemoveAnswers removes "answers" edges to Answer entities.

func (*UserUpdate) RemoveQuestionIDs

func (uu *UserUpdate) RemoveQuestionIDs(ids ...int) *UserUpdate

RemoveQuestionIDs removes the "questions" edge to Question entities by IDs.

func (*UserUpdate) RemoveQuestions

func (uu *UserUpdate) RemoveQuestions(q ...*Question) *UserUpdate

RemoveQuestions removes "questions" edges to Question entities.

func (*UserUpdate) RemoveTagIDs

func (uu *UserUpdate) RemoveTagIDs(ids ...int) *UserUpdate

RemoveTagIDs removes the "tags" edge to Tag entities by IDs.

func (*UserUpdate) RemoveTags

func (uu *UserUpdate) RemoveTags(t ...*Tag) *UserUpdate

RemoveTags removes "tags" edges to Tag entities.

func (*UserUpdate) Save

func (uu *UserUpdate) Save(ctx context.Context) (int, error)

Save executes the query and returns the number of nodes affected by the update operation.

func (*UserUpdate) SaveX

func (uu *UserUpdate) SaveX(ctx context.Context) int

SaveX is like Save, but panics if an error occurs.

func (*UserUpdate) SetEmail

func (uu *UserUpdate) SetEmail(s string) *UserUpdate

SetEmail sets the "email" field.

func (*UserUpdate) SetNillableSuperuser

func (uu *UserUpdate) SetNillableSuperuser(b *bool) *UserUpdate

SetNillableSuperuser sets the "superuser" field if the given value is not nil.

func (*UserUpdate) SetPassword

func (uu *UserUpdate) SetPassword(s string) *UserUpdate

SetPassword sets the "password" field.

func (*UserUpdate) SetSuperuser

func (uu *UserUpdate) SetSuperuser(b bool) *UserUpdate

SetSuperuser sets the "superuser" field.

func (*UserUpdate) SetUsername

func (uu *UserUpdate) SetUsername(s string) *UserUpdate

SetUsername sets the "username" field.

func (*UserUpdate) Where

func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate

Where appends a list predicates to the UserUpdate builder.

type UserUpdateOne

type UserUpdateOne struct {
	// contains filtered or unexported fields
}

UserUpdateOne is the builder for updating a single User entity.

func (*UserUpdateOne) AddAnswerIDs

func (uuo *UserUpdateOne) AddAnswerIDs(ids ...int) *UserUpdateOne

AddAnswerIDs adds the "answers" edge to the Answer entity by IDs.

func (*UserUpdateOne) AddAnswers

func (uuo *UserUpdateOne) AddAnswers(a ...*Answer) *UserUpdateOne

AddAnswers adds the "answers" edges to the Answer entity.

func (*UserUpdateOne) AddQuestionIDs

func (uuo *UserUpdateOne) AddQuestionIDs(ids ...int) *UserUpdateOne

AddQuestionIDs adds the "questions" edge to the Question entity by IDs.

func (*UserUpdateOne) AddQuestions

func (uuo *UserUpdateOne) AddQuestions(q ...*Question) *UserUpdateOne

AddQuestions adds the "questions" edges to the Question entity.

func (*UserUpdateOne) AddTagIDs

func (uuo *UserUpdateOne) AddTagIDs(ids ...int) *UserUpdateOne

AddTagIDs adds the "tags" edge to the Tag entity by IDs.

func (*UserUpdateOne) AddTags

func (uuo *UserUpdateOne) AddTags(t ...*Tag) *UserUpdateOne

AddTags adds the "tags" edges to the Tag entity.

func (*UserUpdateOne) ClearAnswers

func (uuo *UserUpdateOne) ClearAnswers() *UserUpdateOne

ClearAnswers clears all "answers" edges to the Answer entity.

func (*UserUpdateOne) ClearQuestions

func (uuo *UserUpdateOne) ClearQuestions() *UserUpdateOne

ClearQuestions clears all "questions" edges to the Question entity.

func (*UserUpdateOne) ClearTags

func (uuo *UserUpdateOne) ClearTags() *UserUpdateOne

ClearTags clears all "tags" edges to the Tag entity.

func (*UserUpdateOne) Exec

func (uuo *UserUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*UserUpdateOne) ExecX

func (uuo *UserUpdateOne) ExecX(ctx context.Context)

ExecX is like Exec, but panics if an error occurs.

func (*UserUpdateOne) Mutation

func (uuo *UserUpdateOne) Mutation() *UserMutation

Mutation returns the UserMutation object of the builder.

func (*UserUpdateOne) RemoveAnswerIDs

func (uuo *UserUpdateOne) RemoveAnswerIDs(ids ...int) *UserUpdateOne

RemoveAnswerIDs removes the "answers" edge to Answer entities by IDs.

func (*UserUpdateOne) RemoveAnswers

func (uuo *UserUpdateOne) RemoveAnswers(a ...*Answer) *UserUpdateOne

RemoveAnswers removes "answers" edges to Answer entities.

func (*UserUpdateOne) RemoveQuestionIDs

func (uuo *UserUpdateOne) RemoveQuestionIDs(ids ...int) *UserUpdateOne

RemoveQuestionIDs removes the "questions" edge to Question entities by IDs.

func (*UserUpdateOne) RemoveQuestions

func (uuo *UserUpdateOne) RemoveQuestions(q ...*Question) *UserUpdateOne

RemoveQuestions removes "questions" edges to Question entities.

func (*UserUpdateOne) RemoveTagIDs

func (uuo *UserUpdateOne) RemoveTagIDs(ids ...int) *UserUpdateOne

RemoveTagIDs removes the "tags" edge to Tag entities by IDs.

func (*UserUpdateOne) RemoveTags

func (uuo *UserUpdateOne) RemoveTags(t ...*Tag) *UserUpdateOne

RemoveTags removes "tags" edges to Tag entities.

func (*UserUpdateOne) Save

func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error)

Save executes the query and returns the updated User entity.

func (*UserUpdateOne) SaveX

func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User

SaveX is like Save, but panics if an error occurs.

func (*UserUpdateOne) Select

func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne

Select allows selecting one or more fields (columns) of the returned entity. The default is selecting all fields defined in the entity schema.

func (*UserUpdateOne) SetEmail

func (uuo *UserUpdateOne) SetEmail(s string) *UserUpdateOne

SetEmail sets the "email" field.

func (*UserUpdateOne) SetNillableSuperuser

func (uuo *UserUpdateOne) SetNillableSuperuser(b *bool) *UserUpdateOne

SetNillableSuperuser sets the "superuser" field if the given value is not nil.

func (*UserUpdateOne) SetPassword

func (uuo *UserUpdateOne) SetPassword(s string) *UserUpdateOne

SetPassword sets the "password" field.

func (*UserUpdateOne) SetSuperuser

func (uuo *UserUpdateOne) SetSuperuser(b bool) *UserUpdateOne

SetSuperuser sets the "superuser" field.

func (*UserUpdateOne) SetUsername

func (uuo *UserUpdateOne) SetUsername(s string) *UserUpdateOne

SetUsername sets the "username" field.

func (*UserUpdateOne) Where

func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne

Where appends a list predicates to the UserUpdate builder.

type Users

type Users []*User

Users is a parsable slice of User.

type ValidationError

type ValidationError struct {
	Name string // Field or edge name.
	// contains filtered or unexported fields
}

ValidationError returns when validating a field or edge fails.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Value

type Value = ent.Value

ent aliases to avoid import conflicts in user's code.

Directories

Path Synopsis
Code generated by ogen, DO NOT EDIT.
Code generated by ogen, DO NOT EDIT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL