ent

package
v0.0.0-...-fc31239 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

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

	// Node types.
	TypeLike  = "Like"
	TypeTweet = "Tweet"
	TypeUser  = "User"
)

Variables

This section is empty.

Functions

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func IsValidationError

func IsValidationError(err error) bool

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

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

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

NewContext returns a new context with the given Client attached.

func NewTxContext

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

NewTxContext returns a new context with the given Tx attached.

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector) string

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

func As

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

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

func Count

func Count() AggregateFunc

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

func Max

func Max(field string) AggregateFunc

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

func Mean

func Mean(field string) AggregateFunc

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

func Min

func Min(field string) AggregateFunc

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

func Sum

func Sum(field string) AggregateFunc

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

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Like is the client for interacting with the Like builders.
	Like *LikeClient
	// Tweet is the client for interacting with the Tweet builders.
	Tweet *TweetClient
	// 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().
	Like.
	Query().
	Count(ctx)

func (*Client) Tx

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

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

func (*Client) Use

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

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

type CommitFunc

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

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

func (CommitFunc) Commit

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

Commit calls f(ctx, m).

type CommitHook

type CommitHook func(Committer) Committer

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

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

type Committer

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

Committer is the interface that wraps the Commit method.

type ConstraintError

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

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

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Hook

type Hook = ent.Hook

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

type Like

type Like struct {

	// UserID holds the value of the "user_id" field.
	UserID int `json:"user_id,omitempty"`
	// TweetID holds the value of the "tweet_id" field.
	TweetID int `json:"tweet_id,omitempty"`
	// LikedAt holds the value of the "liked_at" field.
	LikedAt time.Time `json:"liked_at,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the LikeQuery when eager-loading is set.
	Edges LikeEdges `json:"edges"`
	// contains filtered or unexported fields
}

Like is the model entity for the Like schema.

func (*Like) QueryTweet

func (l *Like) QueryTweet() *TweetQuery

QueryTweet queries the "tweet" edge of the Like entity.

func (*Like) QueryUser

func (l *Like) QueryUser() *UserQuery

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

func (*Like) String

func (l *Like) String() string

String implements the fmt.Stringer.

func (*Like) Unwrap

func (l *Like) Unwrap() *Like

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

func (l *Like) Update() *LikeUpdateOne

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

type LikeClient

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

LikeClient is a client for the Like schema.

func NewLikeClient

func NewLikeClient(c config) *LikeClient

NewLikeClient returns a client for the Like from the given config.

func (*LikeClient) Create

func (c *LikeClient) Create() *LikeCreate

Create returns a builder for creating a Like entity.

func (*LikeClient) CreateBulk

func (c *LikeClient) CreateBulk(builders ...*LikeCreate) *LikeCreateBulk

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

func (*LikeClient) Delete

func (c *LikeClient) Delete() *LikeDelete

Delete returns a delete builder for Like.

func (*LikeClient) Hooks

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

Hooks returns the client hooks.

func (*LikeClient) Query

func (c *LikeClient) Query() *LikeQuery

Query returns a query builder for Like.

func (*LikeClient) QueryTweet

func (c *LikeClient) QueryTweet(l *Like) *TweetQuery

QueryTweet queries the tweet edge of a Like.

func (*LikeClient) QueryUser

func (c *LikeClient) QueryUser(l *Like) *UserQuery

QueryUser queries the user edge of a Like.

func (*LikeClient) Update

func (c *LikeClient) Update() *LikeUpdate

Update returns an update builder for Like.

func (*LikeClient) UpdateOne

func (c *LikeClient) UpdateOne(l *Like) *LikeUpdateOne

UpdateOne returns an update builder for the given entity.

func (*LikeClient) Use

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

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

type LikeCreate

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

LikeCreate is the builder for creating a Like entity.

func (*LikeCreate) Exec

func (lc *LikeCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*LikeCreate) ExecX

func (lc *LikeCreate) ExecX(ctx context.Context)

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

func (*LikeCreate) Mutation

func (lc *LikeCreate) Mutation() *LikeMutation

Mutation returns the LikeMutation object of the builder.

func (*LikeCreate) Save

func (lc *LikeCreate) Save(ctx context.Context) (*Like, error)

Save creates the Like in the database.

func (*LikeCreate) SaveX

func (lc *LikeCreate) SaveX(ctx context.Context) *Like

SaveX calls Save and panics if Save returns an error.

func (*LikeCreate) SetLikedAt

func (lc *LikeCreate) SetLikedAt(t time.Time) *LikeCreate

SetLikedAt sets the "liked_at" field.

func (*LikeCreate) SetNillableLikedAt

func (lc *LikeCreate) SetNillableLikedAt(t *time.Time) *LikeCreate

SetNillableLikedAt sets the "liked_at" field if the given value is not nil.

func (*LikeCreate) SetTweet

func (lc *LikeCreate) SetTweet(t *Tweet) *LikeCreate

SetTweet sets the "tweet" edge to the Tweet entity.

func (*LikeCreate) SetTweetID

func (lc *LikeCreate) SetTweetID(i int) *LikeCreate

SetTweetID sets the "tweet_id" field.

func (*LikeCreate) SetUser

func (lc *LikeCreate) SetUser(u *User) *LikeCreate

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

func (*LikeCreate) SetUserID

func (lc *LikeCreate) SetUserID(i int) *LikeCreate

SetUserID sets the "user_id" field.

type LikeCreateBulk

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

LikeCreateBulk is the builder for creating many Like entities in bulk.

func (*LikeCreateBulk) Exec

func (lcb *LikeCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*LikeCreateBulk) ExecX

func (lcb *LikeCreateBulk) ExecX(ctx context.Context)

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

func (*LikeCreateBulk) Save

func (lcb *LikeCreateBulk) Save(ctx context.Context) ([]*Like, error)

Save creates the Like entities in the database.

func (*LikeCreateBulk) SaveX

func (lcb *LikeCreateBulk) SaveX(ctx context.Context) []*Like

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

type LikeDelete

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

LikeDelete is the builder for deleting a Like entity.

func (*LikeDelete) Exec

func (ld *LikeDelete) Exec(ctx context.Context) (int, error)

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

func (*LikeDelete) ExecX

func (ld *LikeDelete) ExecX(ctx context.Context) int

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

func (*LikeDelete) Where

func (ld *LikeDelete) Where(ps ...predicate.Like) *LikeDelete

Where appends a list predicates to the LikeDelete builder.

type LikeDeleteOne

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

LikeDeleteOne is the builder for deleting a single Like entity.

func (*LikeDeleteOne) Exec

func (ldo *LikeDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*LikeDeleteOne) ExecX

func (ldo *LikeDeleteOne) ExecX(ctx context.Context)

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

type LikeEdges

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

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

func (LikeEdges) TweetOrErr

func (e LikeEdges) TweetOrErr() (*Tweet, error)

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

func (LikeEdges) UserOrErr

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

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

type LikeGroupBy

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

LikeGroupBy is the group-by builder for Like entities.

func (*LikeGroupBy) Aggregate

func (lgb *LikeGroupBy) Aggregate(fns ...AggregateFunc) *LikeGroupBy

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

func (*LikeGroupBy) Bool

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

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

func (*LikeGroupBy) BoolX

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

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

func (*LikeGroupBy) Bools

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

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

func (*LikeGroupBy) BoolsX

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

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

func (*LikeGroupBy) Float64

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

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

func (*LikeGroupBy) Float64X

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

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

func (*LikeGroupBy) Float64s

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

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

func (*LikeGroupBy) Float64sX

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

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

func (*LikeGroupBy) Int

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

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

func (*LikeGroupBy) IntX

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

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

func (*LikeGroupBy) Ints

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

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

func (*LikeGroupBy) IntsX

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

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

func (*LikeGroupBy) Scan

func (lgb *LikeGroupBy) Scan(ctx context.Context, v any) error

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

func (*LikeGroupBy) ScanX

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

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

func (*LikeGroupBy) String

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

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

func (*LikeGroupBy) StringX

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

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

func (*LikeGroupBy) Strings

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

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

func (*LikeGroupBy) StringsX

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

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

type LikeMutation

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

LikeMutation represents an operation that mutates the Like nodes in the graph.

func (*LikeMutation) AddField

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

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

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

func (*LikeMutation) AddedField

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

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

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

func (*LikeMutation) AddedIDs

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

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

func (*LikeMutation) ClearEdge

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

func (m *LikeMutation) 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 (*LikeMutation) ClearTweet

func (m *LikeMutation) ClearTweet()

ClearTweet clears the "tweet" edge to the Tweet entity.

func (*LikeMutation) ClearUser

func (m *LikeMutation) ClearUser()

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

func (*LikeMutation) ClearedEdges

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

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

func (*LikeMutation) ClearedFields

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

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

func (LikeMutation) Client

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

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

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

func (*LikeMutation) Field

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

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

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

func (*LikeMutation) Fields

func (m *LikeMutation) 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 (*LikeMutation) LikedAt

func (m *LikeMutation) LikedAt() (r time.Time, exists bool)

LikedAt returns the value of the "liked_at" field in the mutation.

func (*LikeMutation) OldField

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

func (m *LikeMutation) Op() Op

Op returns the operation name.

func (*LikeMutation) RemovedEdges

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

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

func (*LikeMutation) RemovedIDs

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

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

func (m *LikeMutation) 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 (*LikeMutation) ResetLikedAt

func (m *LikeMutation) ResetLikedAt()

ResetLikedAt resets all changes to the "liked_at" field.

func (*LikeMutation) ResetTweet

func (m *LikeMutation) ResetTweet()

ResetTweet resets all changes to the "tweet" edge.

func (*LikeMutation) ResetTweetID

func (m *LikeMutation) ResetTweetID()

ResetTweetID resets all changes to the "tweet_id" field.

func (*LikeMutation) ResetUser

func (m *LikeMutation) ResetUser()

ResetUser resets all changes to the "user" edge.

func (*LikeMutation) ResetUserID

func (m *LikeMutation) ResetUserID()

ResetUserID resets all changes to the "user_id" field.

func (*LikeMutation) SetField

func (m *LikeMutation) 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 (*LikeMutation) SetLikedAt

func (m *LikeMutation) SetLikedAt(t time.Time)

SetLikedAt sets the "liked_at" field.

func (*LikeMutation) SetTweetID

func (m *LikeMutation) SetTweetID(i int)

SetTweetID sets the "tweet_id" field.

func (*LikeMutation) SetUserID

func (m *LikeMutation) SetUserID(i int)

SetUserID sets the "user_id" field.

func (*LikeMutation) TweetCleared

func (m *LikeMutation) TweetCleared() bool

TweetCleared reports if the "tweet" edge to the Tweet entity was cleared.

func (*LikeMutation) TweetID

func (m *LikeMutation) TweetID() (r int, exists bool)

TweetID returns the value of the "tweet_id" field in the mutation.

func (*LikeMutation) TweetIDs

func (m *LikeMutation) TweetIDs() (ids []int)

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

func (LikeMutation) Tx

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

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

func (*LikeMutation) Type

func (m *LikeMutation) Type() string

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

func (*LikeMutation) UserCleared

func (m *LikeMutation) UserCleared() bool

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

func (*LikeMutation) UserID

func (m *LikeMutation) UserID() (r int, exists bool)

UserID returns the value of the "user_id" field in the mutation.

func (*LikeMutation) UserIDs

func (m *LikeMutation) UserIDs() (ids []int)

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

func (*LikeMutation) Where

func (m *LikeMutation) Where(ps ...predicate.Like)

Where appends a list predicates to the LikeMutation builder.

type LikeQuery

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

LikeQuery is the builder for querying Like entities.

func (*LikeQuery) Aggregate

func (lq *LikeQuery) Aggregate(fns ...AggregateFunc) *LikeSelect

Aggregate returns a LikeSelect configured with the given aggregations.

func (*LikeQuery) All

func (lq *LikeQuery) All(ctx context.Context) ([]*Like, error)

All executes the query and returns a list of Likes.

func (*LikeQuery) AllX

func (lq *LikeQuery) AllX(ctx context.Context) []*Like

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

func (*LikeQuery) Clone

func (lq *LikeQuery) Clone() *LikeQuery

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

func (*LikeQuery) Count

func (lq *LikeQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*LikeQuery) CountX

func (lq *LikeQuery) CountX(ctx context.Context) int

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

func (*LikeQuery) Exist

func (lq *LikeQuery) Exist(ctx context.Context) (bool, error)

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

func (*LikeQuery) ExistX

func (lq *LikeQuery) ExistX(ctx context.Context) bool

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

func (*LikeQuery) First

func (lq *LikeQuery) First(ctx context.Context) (*Like, error)

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

func (*LikeQuery) FirstX

func (lq *LikeQuery) FirstX(ctx context.Context) *Like

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

func (*LikeQuery) GroupBy

func (lq *LikeQuery) GroupBy(field string, fields ...string) *LikeGroupBy

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 {
	UserID int `json:"user_id,omitempty"`
	Count int `json:"count,omitempty"`
}

client.Like.Query().
	GroupBy(like.FieldUserID).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*LikeQuery) Limit

func (lq *LikeQuery) Limit(limit int) *LikeQuery

Limit adds a limit step to the query.

func (*LikeQuery) Offset

func (lq *LikeQuery) Offset(offset int) *LikeQuery

Offset adds an offset step to the query.

func (*LikeQuery) Only

func (lq *LikeQuery) Only(ctx context.Context) (*Like, error)

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

func (*LikeQuery) OnlyX

func (lq *LikeQuery) OnlyX(ctx context.Context) *Like

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

func (*LikeQuery) Order

func (lq *LikeQuery) Order(o ...OrderFunc) *LikeQuery

Order adds an order step to the query.

func (*LikeQuery) QueryTweet

func (lq *LikeQuery) QueryTweet() *TweetQuery

QueryTweet chains the current query on the "tweet" edge.

func (*LikeQuery) QueryUser

func (lq *LikeQuery) QueryUser() *UserQuery

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

func (*LikeQuery) Select

func (lq *LikeQuery) Select(fields ...string) *LikeSelect

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 {
	UserID int `json:"user_id,omitempty"`
}

client.Like.Query().
	Select(like.FieldUserID).
	Scan(ctx, &v)

func (*LikeQuery) Unique

func (lq *LikeQuery) Unique(unique bool) *LikeQuery

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

func (lq *LikeQuery) Where(ps ...predicate.Like) *LikeQuery

Where adds a new predicate for the LikeQuery builder.

func (*LikeQuery) WithTweet

func (lq *LikeQuery) WithTweet(opts ...func(*TweetQuery)) *LikeQuery

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

func (*LikeQuery) WithUser

func (lq *LikeQuery) WithUser(opts ...func(*UserQuery)) *LikeQuery

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

type LikeSelect

type LikeSelect struct {
	*LikeQuery
	// contains filtered or unexported fields
}

LikeSelect is the builder for selecting fields of Like entities.

func (*LikeSelect) Aggregate

func (ls *LikeSelect) Aggregate(fns ...AggregateFunc) *LikeSelect

Aggregate adds the given aggregation functions to the selector query.

func (*LikeSelect) Bool

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

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

func (*LikeSelect) BoolX

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

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

func (*LikeSelect) Bools

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

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

func (*LikeSelect) BoolsX

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

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

func (*LikeSelect) Float64

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

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

func (*LikeSelect) Float64X

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

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

func (*LikeSelect) Float64s

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

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

func (*LikeSelect) Float64sX

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

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

func (*LikeSelect) Int

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

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

func (*LikeSelect) IntX

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

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

func (*LikeSelect) Ints

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

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

func (*LikeSelect) IntsX

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

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

func (*LikeSelect) Scan

func (ls *LikeSelect) Scan(ctx context.Context, v any) error

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

func (*LikeSelect) ScanX

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

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

func (*LikeSelect) String

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

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

func (*LikeSelect) StringX

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

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

func (*LikeSelect) Strings

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

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

func (*LikeSelect) StringsX

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

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

type LikeUpdate

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

LikeUpdate is the builder for updating Like entities.

func (*LikeUpdate) ClearTweet

func (lu *LikeUpdate) ClearTweet() *LikeUpdate

ClearTweet clears the "tweet" edge to the Tweet entity.

func (*LikeUpdate) ClearUser

func (lu *LikeUpdate) ClearUser() *LikeUpdate

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

func (*LikeUpdate) Exec

func (lu *LikeUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*LikeUpdate) ExecX

func (lu *LikeUpdate) ExecX(ctx context.Context)

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

func (*LikeUpdate) Mutation

func (lu *LikeUpdate) Mutation() *LikeMutation

Mutation returns the LikeMutation object of the builder.

func (*LikeUpdate) Save

func (lu *LikeUpdate) Save(ctx context.Context) (int, error)

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

func (*LikeUpdate) SaveX

func (lu *LikeUpdate) SaveX(ctx context.Context) int

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

func (*LikeUpdate) SetLikedAt

func (lu *LikeUpdate) SetLikedAt(t time.Time) *LikeUpdate

SetLikedAt sets the "liked_at" field.

func (*LikeUpdate) SetNillableLikedAt

func (lu *LikeUpdate) SetNillableLikedAt(t *time.Time) *LikeUpdate

SetNillableLikedAt sets the "liked_at" field if the given value is not nil.

func (*LikeUpdate) SetTweet

func (lu *LikeUpdate) SetTweet(t *Tweet) *LikeUpdate

SetTweet sets the "tweet" edge to the Tweet entity.

func (*LikeUpdate) SetTweetID

func (lu *LikeUpdate) SetTweetID(i int) *LikeUpdate

SetTweetID sets the "tweet_id" field.

func (*LikeUpdate) SetUser

func (lu *LikeUpdate) SetUser(u *User) *LikeUpdate

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

func (*LikeUpdate) SetUserID

func (lu *LikeUpdate) SetUserID(i int) *LikeUpdate

SetUserID sets the "user_id" field.

func (*LikeUpdate) Where

func (lu *LikeUpdate) Where(ps ...predicate.Like) *LikeUpdate

Where appends a list predicates to the LikeUpdate builder.

type LikeUpdateOne

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

LikeUpdateOne is the builder for updating a single Like entity.

func (*LikeUpdateOne) ClearTweet

func (luo *LikeUpdateOne) ClearTweet() *LikeUpdateOne

ClearTweet clears the "tweet" edge to the Tweet entity.

func (*LikeUpdateOne) ClearUser

func (luo *LikeUpdateOne) ClearUser() *LikeUpdateOne

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

func (*LikeUpdateOne) Exec

func (luo *LikeUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*LikeUpdateOne) ExecX

func (luo *LikeUpdateOne) ExecX(ctx context.Context)

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

func (*LikeUpdateOne) Mutation

func (luo *LikeUpdateOne) Mutation() *LikeMutation

Mutation returns the LikeMutation object of the builder.

func (*LikeUpdateOne) Save

func (luo *LikeUpdateOne) Save(ctx context.Context) (*Like, error)

Save executes the query and returns the updated Like entity.

func (*LikeUpdateOne) SaveX

func (luo *LikeUpdateOne) SaveX(ctx context.Context) *Like

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

func (*LikeUpdateOne) Select

func (luo *LikeUpdateOne) Select(field string, fields ...string) *LikeUpdateOne

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

func (*LikeUpdateOne) SetLikedAt

func (luo *LikeUpdateOne) SetLikedAt(t time.Time) *LikeUpdateOne

SetLikedAt sets the "liked_at" field.

func (*LikeUpdateOne) SetNillableLikedAt

func (luo *LikeUpdateOne) SetNillableLikedAt(t *time.Time) *LikeUpdateOne

SetNillableLikedAt sets the "liked_at" field if the given value is not nil.

func (*LikeUpdateOne) SetTweet

func (luo *LikeUpdateOne) SetTweet(t *Tweet) *LikeUpdateOne

SetTweet sets the "tweet" edge to the Tweet entity.

func (*LikeUpdateOne) SetTweetID

func (luo *LikeUpdateOne) SetTweetID(i int) *LikeUpdateOne

SetTweetID sets the "tweet_id" field.

func (*LikeUpdateOne) SetUser

func (luo *LikeUpdateOne) SetUser(u *User) *LikeUpdateOne

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

func (*LikeUpdateOne) SetUserID

func (luo *LikeUpdateOne) SetUserID(i int) *LikeUpdateOne

SetUserID sets the "user_id" field.

type Likes

type Likes []*Like

Likes is a parsable slice of Like.

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.

func Asc

func Asc(fields ...string) OrderFunc

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) OrderFunc

Desc applies the given fields in DESC order.

type Policy

type Policy = ent.Policy

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

type Query

type Query = ent.Query

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

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

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

type Rollbacker

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

Rollbacker is the interface that wraps the Rollback method.

type Tweet

type Tweet struct {

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

Tweet is the model entity for the Tweet schema.

func (*Tweet) QueryLikedUsers

func (t *Tweet) QueryLikedUsers() *UserQuery

QueryLikedUsers queries the "liked_users" edge of the Tweet entity.

func (*Tweet) QueryLikes

func (t *Tweet) QueryLikes() *LikeQuery

QueryLikes queries the "likes" edge of the Tweet entity.

func (*Tweet) String

func (t *Tweet) String() string

String implements the fmt.Stringer.

func (*Tweet) Unwrap

func (t *Tweet) Unwrap() *Tweet

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

func (t *Tweet) Update() *TweetUpdateOne

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

type TweetClient

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

TweetClient is a client for the Tweet schema.

func NewTweetClient

func NewTweetClient(c config) *TweetClient

NewTweetClient returns a client for the Tweet from the given config.

func (*TweetClient) Create

func (c *TweetClient) Create() *TweetCreate

Create returns a builder for creating a Tweet entity.

func (*TweetClient) CreateBulk

func (c *TweetClient) CreateBulk(builders ...*TweetCreate) *TweetCreateBulk

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

func (*TweetClient) Delete

func (c *TweetClient) Delete() *TweetDelete

Delete returns a delete builder for Tweet.

func (*TweetClient) DeleteOne

func (c *TweetClient) DeleteOne(t *Tweet) *TweetDeleteOne

DeleteOne returns a builder for deleting the given entity.

func (*TweetClient) DeleteOneID

func (c *TweetClient) DeleteOneID(id int) *TweetDeleteOne

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

func (*TweetClient) Get

func (c *TweetClient) Get(ctx context.Context, id int) (*Tweet, error)

Get returns a Tweet entity by its id.

func (*TweetClient) GetX

func (c *TweetClient) GetX(ctx context.Context, id int) *Tweet

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

func (*TweetClient) Hooks

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

Hooks returns the client hooks.

func (*TweetClient) Query

func (c *TweetClient) Query() *TweetQuery

Query returns a query builder for Tweet.

func (*TweetClient) QueryLikedUsers

func (c *TweetClient) QueryLikedUsers(t *Tweet) *UserQuery

QueryLikedUsers queries the liked_users edge of a Tweet.

func (*TweetClient) QueryLikes

func (c *TweetClient) QueryLikes(t *Tweet) *LikeQuery

QueryLikes queries the likes edge of a Tweet.

func (*TweetClient) Update

func (c *TweetClient) Update() *TweetUpdate

Update returns an update builder for Tweet.

func (*TweetClient) UpdateOne

func (c *TweetClient) UpdateOne(t *Tweet) *TweetUpdateOne

UpdateOne returns an update builder for the given entity.

func (*TweetClient) UpdateOneID

func (c *TweetClient) UpdateOneID(id int) *TweetUpdateOne

UpdateOneID returns an update builder for the given id.

func (*TweetClient) Use

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

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

type TweetCreate

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

TweetCreate is the builder for creating a Tweet entity.

func (*TweetCreate) AddLikedUserIDs

func (tc *TweetCreate) AddLikedUserIDs(ids ...int) *TweetCreate

AddLikedUserIDs adds the "liked_users" edge to the User entity by IDs.

func (*TweetCreate) AddLikedUsers

func (tc *TweetCreate) AddLikedUsers(u ...*User) *TweetCreate

AddLikedUsers adds the "liked_users" edges to the User entity.

func (*TweetCreate) Exec

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

Exec executes the query.

func (*TweetCreate) ExecX

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

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

func (*TweetCreate) Mutation

func (tc *TweetCreate) Mutation() *TweetMutation

Mutation returns the TweetMutation object of the builder.

func (*TweetCreate) Save

func (tc *TweetCreate) Save(ctx context.Context) (*Tweet, error)

Save creates the Tweet in the database.

func (*TweetCreate) SaveX

func (tc *TweetCreate) SaveX(ctx context.Context) *Tweet

SaveX calls Save and panics if Save returns an error.

func (*TweetCreate) SetText

func (tc *TweetCreate) SetText(s string) *TweetCreate

SetText sets the "text" field.

type TweetCreateBulk

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

TweetCreateBulk is the builder for creating many Tweet entities in bulk.

func (*TweetCreateBulk) Exec

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

Exec executes the query.

func (*TweetCreateBulk) ExecX

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

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

func (*TweetCreateBulk) Save

func (tcb *TweetCreateBulk) Save(ctx context.Context) ([]*Tweet, error)

Save creates the Tweet entities in the database.

func (*TweetCreateBulk) SaveX

func (tcb *TweetCreateBulk) SaveX(ctx context.Context) []*Tweet

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

type TweetDelete

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

TweetDelete is the builder for deleting a Tweet entity.

func (*TweetDelete) Exec

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

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

func (*TweetDelete) ExecX

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

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

func (*TweetDelete) Where

func (td *TweetDelete) Where(ps ...predicate.Tweet) *TweetDelete

Where appends a list predicates to the TweetDelete builder.

type TweetDeleteOne

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

TweetDeleteOne is the builder for deleting a single Tweet entity.

func (*TweetDeleteOne) Exec

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

Exec executes the deletion query.

func (*TweetDeleteOne) ExecX

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

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

type TweetEdges

type TweetEdges struct {
	// LikedUsers holds the value of the liked_users edge.
	LikedUsers []*User `json:"liked_users,omitempty"`
	// Likes holds the value of the likes edge.
	Likes []*Like `json:"likes,omitempty"`
	// contains filtered or unexported fields
}

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

func (TweetEdges) LikedUsersOrErr

func (e TweetEdges) LikedUsersOrErr() ([]*User, error)

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

func (TweetEdges) LikesOrErr

func (e TweetEdges) LikesOrErr() ([]*Like, error)

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

type TweetGroupBy

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

TweetGroupBy is the group-by builder for Tweet entities.

func (*TweetGroupBy) Aggregate

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

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

func (*TweetGroupBy) Bool

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

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

func (*TweetGroupBy) BoolX

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

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

func (*TweetGroupBy) Bools

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

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

func (*TweetGroupBy) BoolsX

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

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

func (*TweetGroupBy) Float64

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

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

func (*TweetGroupBy) Float64X

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

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

func (*TweetGroupBy) Float64s

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

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

func (*TweetGroupBy) Float64sX

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

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

func (*TweetGroupBy) Int

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

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

func (*TweetGroupBy) IntX

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

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

func (*TweetGroupBy) Ints

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

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

func (*TweetGroupBy) IntsX

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

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

func (*TweetGroupBy) Scan

func (tgb *TweetGroupBy) Scan(ctx context.Context, v any) error

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

func (*TweetGroupBy) ScanX

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

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

func (*TweetGroupBy) String

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

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

func (*TweetGroupBy) StringX

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

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

func (*TweetGroupBy) Strings

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

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

func (*TweetGroupBy) StringsX

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

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

type TweetMutation

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

TweetMutation represents an operation that mutates the Tweet nodes in the graph.

func (*TweetMutation) AddField

func (m *TweetMutation) 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 (*TweetMutation) AddLikedUserIDs

func (m *TweetMutation) AddLikedUserIDs(ids ...int)

AddLikedUserIDs adds the "liked_users" edge to the User entity by ids.

func (*TweetMutation) AddedEdges

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

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

func (*TweetMutation) AddedField

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

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

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

func (*TweetMutation) AddedIDs

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

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

func (*TweetMutation) ClearEdge

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

func (m *TweetMutation) 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 (*TweetMutation) ClearLikedUsers

func (m *TweetMutation) ClearLikedUsers()

ClearLikedUsers clears the "liked_users" edge to the User entity.

func (*TweetMutation) ClearedEdges

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

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

func (*TweetMutation) ClearedFields

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

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

func (TweetMutation) Client

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

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

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

func (*TweetMutation) Field

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

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

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

func (*TweetMutation) Fields

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

func (m *TweetMutation) 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 (*TweetMutation) IDs

func (m *TweetMutation) 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 (*TweetMutation) LikedUsersCleared

func (m *TweetMutation) LikedUsersCleared() bool

LikedUsersCleared reports if the "liked_users" edge to the User entity was cleared.

func (*TweetMutation) LikedUsersIDs

func (m *TweetMutation) LikedUsersIDs() (ids []int)

LikedUsersIDs returns the "liked_users" edge IDs in the mutation.

func (*TweetMutation) OldField

func (m *TweetMutation) 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 (*TweetMutation) OldText

func (m *TweetMutation) OldText(ctx context.Context) (v string, err error)

OldText returns the old "text" field's value of the Tweet entity. If the Tweet 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 (*TweetMutation) Op

func (m *TweetMutation) Op() Op

Op returns the operation name.

func (*TweetMutation) RemoveLikedUserIDs

func (m *TweetMutation) RemoveLikedUserIDs(ids ...int)

RemoveLikedUserIDs removes the "liked_users" edge to the User entity by IDs.

func (*TweetMutation) RemovedEdges

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

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

func (*TweetMutation) RemovedIDs

func (m *TweetMutation) 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 (*TweetMutation) RemovedLikedUsersIDs

func (m *TweetMutation) RemovedLikedUsersIDs() (ids []int)

RemovedLikedUsers returns the removed IDs of the "liked_users" edge to the User entity.

func (*TweetMutation) ResetEdge

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

func (m *TweetMutation) 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 (*TweetMutation) ResetLikedUsers

func (m *TweetMutation) ResetLikedUsers()

ResetLikedUsers resets all changes to the "liked_users" edge.

func (*TweetMutation) ResetText

func (m *TweetMutation) ResetText()

ResetText resets all changes to the "text" field.

func (*TweetMutation) SetField

func (m *TweetMutation) 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 (*TweetMutation) SetText

func (m *TweetMutation) SetText(s string)

SetText sets the "text" field.

func (*TweetMutation) Text

func (m *TweetMutation) Text() (r string, exists bool)

Text returns the value of the "text" field in the mutation.

func (TweetMutation) Tx

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

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

func (*TweetMutation) Type

func (m *TweetMutation) Type() string

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

func (*TweetMutation) Where

func (m *TweetMutation) Where(ps ...predicate.Tweet)

Where appends a list predicates to the TweetMutation builder.

type TweetQuery

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

TweetQuery is the builder for querying Tweet entities.

func (*TweetQuery) Aggregate

func (tq *TweetQuery) Aggregate(fns ...AggregateFunc) *TweetSelect

Aggregate returns a TweetSelect configured with the given aggregations.

func (*TweetQuery) All

func (tq *TweetQuery) All(ctx context.Context) ([]*Tweet, error)

All executes the query and returns a list of Tweets.

func (*TweetQuery) AllX

func (tq *TweetQuery) AllX(ctx context.Context) []*Tweet

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

func (*TweetQuery) Clone

func (tq *TweetQuery) Clone() *TweetQuery

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

func (*TweetQuery) Count

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

Count returns the count of the given query.

func (*TweetQuery) CountX

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

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

func (*TweetQuery) Exist

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

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

func (*TweetQuery) ExistX

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

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

func (*TweetQuery) First

func (tq *TweetQuery) First(ctx context.Context) (*Tweet, error)

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

func (*TweetQuery) FirstID

func (tq *TweetQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*TweetQuery) FirstIDX

func (tq *TweetQuery) FirstIDX(ctx context.Context) int

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

func (*TweetQuery) FirstX

func (tq *TweetQuery) FirstX(ctx context.Context) *Tweet

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

func (*TweetQuery) GroupBy

func (tq *TweetQuery) GroupBy(field string, fields ...string) *TweetGroupBy

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

client.Tweet.Query().
	GroupBy(tweet.FieldText).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*TweetQuery) IDs

func (tq *TweetQuery) IDs(ctx context.Context) ([]int, error)

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

func (*TweetQuery) IDsX

func (tq *TweetQuery) IDsX(ctx context.Context) []int

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

func (*TweetQuery) Limit

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

Limit adds a limit step to the query.

func (*TweetQuery) Offset

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

Offset adds an offset step to the query.

func (*TweetQuery) Only

func (tq *TweetQuery) Only(ctx context.Context) (*Tweet, error)

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

func (*TweetQuery) OnlyID

func (tq *TweetQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*TweetQuery) OnlyIDX

func (tq *TweetQuery) OnlyIDX(ctx context.Context) int

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

func (*TweetQuery) OnlyX

func (tq *TweetQuery) OnlyX(ctx context.Context) *Tweet

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

func (*TweetQuery) Order

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

Order adds an order step to the query.

func (*TweetQuery) QueryLikedUsers

func (tq *TweetQuery) QueryLikedUsers() *UserQuery

QueryLikedUsers chains the current query on the "liked_users" edge.

func (*TweetQuery) QueryLikes

func (tq *TweetQuery) QueryLikes() *LikeQuery

QueryLikes chains the current query on the "likes" edge.

func (*TweetQuery) Select

func (tq *TweetQuery) Select(fields ...string) *TweetSelect

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

client.Tweet.Query().
	Select(tweet.FieldText).
	Scan(ctx, &v)

func (*TweetQuery) Unique

func (tq *TweetQuery) Unique(unique bool) *TweetQuery

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

func (tq *TweetQuery) Where(ps ...predicate.Tweet) *TweetQuery

Where adds a new predicate for the TweetQuery builder.

func (*TweetQuery) WithLikedUsers

func (tq *TweetQuery) WithLikedUsers(opts ...func(*UserQuery)) *TweetQuery

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

func (*TweetQuery) WithLikes

func (tq *TweetQuery) WithLikes(opts ...func(*LikeQuery)) *TweetQuery

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

type TweetSelect

type TweetSelect struct {
	*TweetQuery
	// contains filtered or unexported fields
}

TweetSelect is the builder for selecting fields of Tweet entities.

func (*TweetSelect) Aggregate

func (ts *TweetSelect) Aggregate(fns ...AggregateFunc) *TweetSelect

Aggregate adds the given aggregation functions to the selector query.

func (*TweetSelect) Bool

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

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

func (*TweetSelect) BoolX

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

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

func (*TweetSelect) Bools

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

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

func (*TweetSelect) BoolsX

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

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

func (*TweetSelect) Float64

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

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

func (*TweetSelect) Float64X

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

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

func (*TweetSelect) Float64s

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

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

func (*TweetSelect) Float64sX

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

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

func (*TweetSelect) Int

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

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

func (*TweetSelect) IntX

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

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

func (*TweetSelect) Ints

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

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

func (*TweetSelect) IntsX

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

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

func (*TweetSelect) Scan

func (ts *TweetSelect) Scan(ctx context.Context, v any) error

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

func (*TweetSelect) ScanX

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

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

func (*TweetSelect) String

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

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

func (*TweetSelect) StringX

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

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

func (*TweetSelect) Strings

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

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

func (*TweetSelect) StringsX

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

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

type TweetUpdate

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

TweetUpdate is the builder for updating Tweet entities.

func (*TweetUpdate) AddLikedUserIDs

func (tu *TweetUpdate) AddLikedUserIDs(ids ...int) *TweetUpdate

AddLikedUserIDs adds the "liked_users" edge to the User entity by IDs.

func (*TweetUpdate) AddLikedUsers

func (tu *TweetUpdate) AddLikedUsers(u ...*User) *TweetUpdate

AddLikedUsers adds the "liked_users" edges to the User entity.

func (*TweetUpdate) ClearLikedUsers

func (tu *TweetUpdate) ClearLikedUsers() *TweetUpdate

ClearLikedUsers clears all "liked_users" edges to the User entity.

func (*TweetUpdate) Exec

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

Exec executes the query.

func (*TweetUpdate) ExecX

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

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

func (*TweetUpdate) Mutation

func (tu *TweetUpdate) Mutation() *TweetMutation

Mutation returns the TweetMutation object of the builder.

func (*TweetUpdate) RemoveLikedUserIDs

func (tu *TweetUpdate) RemoveLikedUserIDs(ids ...int) *TweetUpdate

RemoveLikedUserIDs removes the "liked_users" edge to User entities by IDs.

func (*TweetUpdate) RemoveLikedUsers

func (tu *TweetUpdate) RemoveLikedUsers(u ...*User) *TweetUpdate

RemoveLikedUsers removes "liked_users" edges to User entities.

func (*TweetUpdate) Save

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

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

func (*TweetUpdate) SaveX

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

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

func (*TweetUpdate) SetText

func (tu *TweetUpdate) SetText(s string) *TweetUpdate

SetText sets the "text" field.

func (*TweetUpdate) Where

func (tu *TweetUpdate) Where(ps ...predicate.Tweet) *TweetUpdate

Where appends a list predicates to the TweetUpdate builder.

type TweetUpdateOne

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

TweetUpdateOne is the builder for updating a single Tweet entity.

func (*TweetUpdateOne) AddLikedUserIDs

func (tuo *TweetUpdateOne) AddLikedUserIDs(ids ...int) *TweetUpdateOne

AddLikedUserIDs adds the "liked_users" edge to the User entity by IDs.

func (*TweetUpdateOne) AddLikedUsers

func (tuo *TweetUpdateOne) AddLikedUsers(u ...*User) *TweetUpdateOne

AddLikedUsers adds the "liked_users" edges to the User entity.

func (*TweetUpdateOne) ClearLikedUsers

func (tuo *TweetUpdateOne) ClearLikedUsers() *TweetUpdateOne

ClearLikedUsers clears all "liked_users" edges to the User entity.

func (*TweetUpdateOne) Exec

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

Exec executes the query on the entity.

func (*TweetUpdateOne) ExecX

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

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

func (*TweetUpdateOne) Mutation

func (tuo *TweetUpdateOne) Mutation() *TweetMutation

Mutation returns the TweetMutation object of the builder.

func (*TweetUpdateOne) RemoveLikedUserIDs

func (tuo *TweetUpdateOne) RemoveLikedUserIDs(ids ...int) *TweetUpdateOne

RemoveLikedUserIDs removes the "liked_users" edge to User entities by IDs.

func (*TweetUpdateOne) RemoveLikedUsers

func (tuo *TweetUpdateOne) RemoveLikedUsers(u ...*User) *TweetUpdateOne

RemoveLikedUsers removes "liked_users" edges to User entities.

func (*TweetUpdateOne) Save

func (tuo *TweetUpdateOne) Save(ctx context.Context) (*Tweet, error)

Save executes the query and returns the updated Tweet entity.

func (*TweetUpdateOne) SaveX

func (tuo *TweetUpdateOne) SaveX(ctx context.Context) *Tweet

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

func (*TweetUpdateOne) Select

func (tuo *TweetUpdateOne) Select(field string, fields ...string) *TweetUpdateOne

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

func (*TweetUpdateOne) SetText

func (tuo *TweetUpdateOne) SetText(s string) *TweetUpdateOne

SetText sets the "text" field.

type Tweets

type Tweets []*Tweet

Tweets is a parsable slice of Tweet.

type Tx

type Tx struct {

	// Like is the client for interacting with the Like builders.
	Like *LikeClient
	// Tweet is the client for interacting with the Tweet builders.
	Tweet *TweetClient
	// 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"`
	// 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 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) QueryLikedTweets

func (u *User) QueryLikedTweets() *TweetQuery

QueryLikedTweets queries the "liked_tweets" edge of the User entity.

func (*User) QueryLikes

func (u *User) QueryLikes() *LikeQuery

QueryLikes queries the "likes" edge of the User entity.

func (*User) String

func (u *User) String() string

String implements the fmt.Stringer.

func (*User) Unwrap

func (u *User) Unwrap() *User

Unwrap unwraps the User entity that was returned from a transaction after it was closed, so that all future queries will be executed through the driver which created the transaction.

func (*User) Update

func (u *User) Update() *UserUpdateOne

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

type UserClient

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

UserClient is a client for the User schema.

func NewUserClient

func NewUserClient(c config) *UserClient

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

func (*UserClient) Create

func (c *UserClient) Create() *UserCreate

Create returns a 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) Query

func (c *UserClient) Query() *UserQuery

Query returns a query builder for User.

func (*UserClient) QueryLikedTweets

func (c *UserClient) QueryLikedTweets(u *User) *TweetQuery

QueryLikedTweets queries the liked_tweets edge of a User.

func (*UserClient) QueryLikes

func (c *UserClient) QueryLikes(u *User) *LikeQuery

QueryLikes queries the likes 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) AddLikedTweetIDs

func (uc *UserCreate) AddLikedTweetIDs(ids ...int) *UserCreate

AddLikedTweetIDs adds the "liked_tweets" edge to the Tweet entity by IDs.

func (*UserCreate) AddLikedTweets

func (uc *UserCreate) AddLikedTweets(t ...*Tweet) *UserCreate

AddLikedTweets adds the "liked_tweets" edges to the Tweet 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) SetName

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

SetName sets the "name" field.

func (*UserCreate) SetNillableName

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

SetNillableName sets the "name" field if the given value is not nil.

type UserCreateBulk

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

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

func (*UserCreateBulk) Exec

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

Exec executes the query.

func (*UserCreateBulk) ExecX

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

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

func (*UserCreateBulk) Save

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

Save creates the User entities in the database.

func (*UserCreateBulk) SaveX

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

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

type UserDelete

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

UserDelete is the builder for deleting a User entity.

func (*UserDelete) Exec

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

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

func (*UserDelete) ExecX

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

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

func (*UserDelete) Where

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

Where appends a list predicates to the UserDelete builder.

type UserDeleteOne

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

UserDeleteOne is the builder for deleting a single User entity.

func (*UserDeleteOne) Exec

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

Exec executes the deletion query.

func (*UserDeleteOne) ExecX

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

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

type UserEdges

type UserEdges struct {
	// LikedTweets holds the value of the liked_tweets edge.
	LikedTweets []*Tweet `json:"liked_tweets,omitempty"`
	// Likes holds the value of the likes edge.
	Likes []*Like `json:"likes,omitempty"`
	// contains filtered or unexported fields
}

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

func (UserEdges) LikedTweetsOrErr

func (e UserEdges) LikedTweetsOrErr() ([]*Tweet, error)

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

func (UserEdges) LikesOrErr

func (e UserEdges) LikesOrErr() ([]*Like, error)

LikesOrErr returns the Likes 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 group-by 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) 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) AddLikedTweetIDs

func (m *UserMutation) AddLikedTweetIDs(ids ...int)

AddLikedTweetIDs adds the "liked_tweets" edge to the Tweet 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) 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) ClearLikedTweets

func (m *UserMutation) ClearLikedTweets()

ClearLikedTweets clears the "liked_tweets" edge to the Tweet 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) 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) 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) LikedTweetsCleared

func (m *UserMutation) LikedTweetsCleared() bool

LikedTweetsCleared reports if the "liked_tweets" edge to the Tweet entity was cleared.

func (*UserMutation) LikedTweetsIDs

func (m *UserMutation) LikedTweetsIDs() (ids []int)

LikedTweetsIDs returns the "liked_tweets" edge IDs in the mutation.

func (*UserMutation) Name

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

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

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

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

OldName returns the old "name" field's value of the User entity. If the User object wasn't provided to the builder, the object is fetched from the database. An error is returned if the mutation operation is not UpdateOne, or the database query fails.

func (*UserMutation) Op

func (m *UserMutation) Op() Op

Op returns the operation name.

func (*UserMutation) RemoveLikedTweetIDs

func (m *UserMutation) RemoveLikedTweetIDs(ids ...int)

RemoveLikedTweetIDs removes the "liked_tweets" edge to the Tweet entity by IDs.

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

func (m *UserMutation) RemovedLikedTweetsIDs() (ids []int)

RemovedLikedTweets returns the removed IDs of the "liked_tweets" edge to the Tweet entity.

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

func (m *UserMutation) ResetLikedTweets()

ResetLikedTweets resets all changes to the "liked_tweets" edge.

func (*UserMutation) ResetName

func (m *UserMutation) ResetName()

ResetName resets all changes to the "name" 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) SetName

func (m *UserMutation) SetName(s string)

SetName sets the "name" field.

func (UserMutation) Tx

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

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

func (*UserMutation) Type

func (m *UserMutation) Type() string

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

func (*UserMutation) Where

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

Where appends a list predicates to the UserMutation builder.

type UserQuery

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

UserQuery is the builder for querying User entities.

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

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

func (*UserQuery) IDs

func (uq *UserQuery) IDs(ctx context.Context) ([]int, 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 adds a limit step to the query.

func (*UserQuery) Offset

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

Offset adds an offset step to the query.

func (*UserQuery) Only

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

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

func (*UserQuery) OnlyID

func (uq *UserQuery) OnlyID(ctx context.Context) (id 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 ...OrderFunc) *UserQuery

Order adds an order step to the query.

func (*UserQuery) QueryLikedTweets

func (uq *UserQuery) QueryLikedTweets() *TweetQuery

QueryLikedTweets chains the current query on the "liked_tweets" edge.

func (*UserQuery) QueryLikes

func (uq *UserQuery) QueryLikes() *LikeQuery

QueryLikes chains the current query on the "likes" 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 {
	Name string `json:"name,omitempty"`
}

client.User.Query().
	Select(user.FieldName).
	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) WithLikedTweets

func (uq *UserQuery) WithLikedTweets(opts ...func(*TweetQuery)) *UserQuery

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

func (*UserQuery) WithLikes

func (uq *UserQuery) WithLikes(opts ...func(*LikeQuery)) *UserQuery

WithLikes tells the query-builder to eager-load the nodes that are connected to the "likes" 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) AddLikedTweetIDs

func (uu *UserUpdate) AddLikedTweetIDs(ids ...int) *UserUpdate

AddLikedTweetIDs adds the "liked_tweets" edge to the Tweet entity by IDs.

func (*UserUpdate) AddLikedTweets

func (uu *UserUpdate) AddLikedTweets(t ...*Tweet) *UserUpdate

AddLikedTweets adds the "liked_tweets" edges to the Tweet entity.

func (*UserUpdate) ClearLikedTweets

func (uu *UserUpdate) ClearLikedTweets() *UserUpdate

ClearLikedTweets clears all "liked_tweets" edges to the Tweet 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) RemoveLikedTweetIDs

func (uu *UserUpdate) RemoveLikedTweetIDs(ids ...int) *UserUpdate

RemoveLikedTweetIDs removes the "liked_tweets" edge to Tweet entities by IDs.

func (*UserUpdate) RemoveLikedTweets

func (uu *UserUpdate) RemoveLikedTweets(t ...*Tweet) *UserUpdate

RemoveLikedTweets removes "liked_tweets" edges to Tweet 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) SetName

func (uu *UserUpdate) SetName(s string) *UserUpdate

SetName sets the "name" field.

func (*UserUpdate) SetNillableName

func (uu *UserUpdate) SetNillableName(s *string) *UserUpdate

SetNillableName sets the "name" field if the given value is not nil.

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

func (uuo *UserUpdateOne) AddLikedTweetIDs(ids ...int) *UserUpdateOne

AddLikedTweetIDs adds the "liked_tweets" edge to the Tweet entity by IDs.

func (*UserUpdateOne) AddLikedTweets

func (uuo *UserUpdateOne) AddLikedTweets(t ...*Tweet) *UserUpdateOne

AddLikedTweets adds the "liked_tweets" edges to the Tweet entity.

func (*UserUpdateOne) ClearLikedTweets

func (uuo *UserUpdateOne) ClearLikedTweets() *UserUpdateOne

ClearLikedTweets clears all "liked_tweets" edges to the Tweet 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) RemoveLikedTweetIDs

func (uuo *UserUpdateOne) RemoveLikedTweetIDs(ids ...int) *UserUpdateOne

RemoveLikedTweetIDs removes the "liked_tweets" edge to Tweet entities by IDs.

func (*UserUpdateOne) RemoveLikedTweets

func (uuo *UserUpdateOne) RemoveLikedTweets(t ...*Tweet) *UserUpdateOne

RemoveLikedTweets removes "liked_tweets" edges to Tweet 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) SetName

func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne

SetName sets the "name" field.

func (*UserUpdateOne) SetNillableName

func (uuo *UserUpdateOne) SetNillableName(s *string) *UserUpdateOne

SetNillableName sets the "name" field if the given value is not nil.

type Users

type Users []*User

Users is a parsable slice of User.

type ValidationError

type ValidationError struct {
	Name string // Field or edge name.
	// contains filtered or unexported fields
}

ValidationError returns when validating a field or edge fails.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Value

type Value = ent.Value

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL