ent

package
v0.0.0-...-7ece36b Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: GPL-3.0 Imports: 33 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.
	TypeDepartment = "Department"
	TypeJob        = "Job"
	TypeUser       = "User"
)

Variables

View Source
var (
	// UserOrderFieldName orders User by name.
	UserOrderFieldName = &UserOrderField{
		field: user.FieldName,
		toCursor: func(u *User) Cursor {
			return Cursor{
				ID:    u.ID,
				Value: u.Name,
			}
		},
	}
	// UserOrderFieldEmail orders User by email.
	UserOrderFieldEmail = &UserOrderField{
		field: user.FieldEmail,
		toCursor: func(u *User) Cursor {
			return Cursor{
				ID:    u.ID,
				Value: u.Email,
			}
		},
	}
	// UserOrderFieldRole orders User by role.
	UserOrderFieldRole = &UserOrderField{
		field: user.FieldRole,
		toCursor: func(u *User) Cursor {
			return Cursor{
				ID:    u.ID,
				Value: u.Role,
			}
		},
	}
)
View Source
var DefaultDepartmentOrder = &DepartmentOrder{
	Direction: OrderDirectionAsc,
	Field: &DepartmentOrderField{
		field: department.FieldID,
		toCursor: func(d *Department) Cursor {
			return Cursor{ID: d.ID}
		},
	},
}

DefaultDepartmentOrder is the default ordering of Department.

View Source
var DefaultJobOrder = &JobOrder{
	Direction: OrderDirectionAsc,
	Field: &JobOrderField{
		field: job.FieldID,
		toCursor: func(j *Job) Cursor {
			return Cursor{ID: j.ID}
		},
	},
}

DefaultJobOrder is the default ordering of Job.

View Source
var DefaultUserOrder = &UserOrder{
	Direction: OrderDirectionAsc,
	Field: &UserOrderField{
		field: user.FieldID,
		toCursor: func(u *User) Cursor {
			return Cursor{ID: u.ID}
		},
	},
}

DefaultUserOrder is the default ordering of User.

View Source
var (
	// DepartmentOrderFieldName orders Department by name.
	DepartmentOrderFieldName = &DepartmentOrderField{
		field: department.FieldName,
		toCursor: func(d *Department) Cursor {
			return Cursor{
				ID:    d.ID,
				Value: d.Name,
			}
		},
	}
)
View Source
var (
	// JobOrderFieldName orders Job by name.
	JobOrderFieldName = &JobOrderField{
		field: job.FieldName,
		toCursor: func(j *Job) Cursor {
			return Cursor{
				ID:    j.ID,
				Value: j.Name,
			}
		},
	}
)

Functions

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func IsValidationError

func IsValidationError(err error) bool

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

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

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

NewContext returns a new context with the given Client attached.

func NewTxContext

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

NewTxContext returns a new context with the given Tx attached.

func OpenTxFromContext

func OpenTxFromContext(ctx context.Context) (context.Context, driver.Tx, error)

OpenTxFromContext open transactions from client stored in context.

Types

type AggregateFunc

type AggregateFunc func(*sql.Selector, func(string) bool) string

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

func As

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

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

func Count

func Count() AggregateFunc

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

func Max

func Max(field string) AggregateFunc

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

func Mean

func Mean(field string) AggregateFunc

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

func Min

func Min(field string) AggregateFunc

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

func Sum

func Sum(field string) AggregateFunc

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

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Department is the client for interacting with the Department builders.
	Department *DepartmentClient
	// Job is the client for interacting with the Job builders.
	Job *JobClient
	// 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().
	Department.
	Query().
	Count(ctx)

func (*Client) Node

func (c *Client) Node(ctx context.Context, id int) (*Node, error)

func (*Client) Noder

func (c *Client) Noder(ctx context.Context, id int, opts ...NodeOption) (_ Noder, err error)

Noder returns a Node by its id. If the NodeType was not provided, it will be derived from the id value according to the universal-id configuration.

c.Noder(ctx, id)
c.Noder(ctx, id, ent.WithNodeType(pet.Table))

func (*Client) Noders

func (c *Client) Noders(ctx context.Context, ids []int, opts ...NodeOption) ([]Noder, error)

func (*Client) OpenTx

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

OpenTx opens a transaction and returns a transactional context along with the created transaction.

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(context.Context, tx *ent.Tx) error {
		// Do some stuff before.
		if err := next.Commit(ctx, tx); err != nil {
			return err
		}
		// Do some stuff after.
		return nil
	})
}

type Committer

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

Committer is the interface that wraps the Committer method.

type ConstraintError

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

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

func (ConstraintError) Error

func (e ConstraintError) Error() string

Error implements the error interface.

func (*ConstraintError) Unwrap

func (e *ConstraintError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Cursor

type Cursor struct {
	ID    int   `msgpack:"i"`
	Value Value `msgpack:"v,omitempty"`
}

Cursor of an edge type.

func (Cursor) MarshalGQL

func (c Cursor) MarshalGQL(w io.Writer)

MarshalGQL implements graphql.Marshaler interface.

func (*Cursor) UnmarshalGQL

func (c *Cursor) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements graphql.Unmarshaler interface.

type Department

type Department 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 DepartmentQuery when eager-loading is set.
	Edges DepartmentEdges `json:"edges"`
	// contains filtered or unexported fields
}

Department is the model entity for the Department schema.

func (*Department) Jobs

func (d *Department) Jobs(ctx context.Context) ([]*Job, error)

func (*Department) Manager

func (d *Department) Manager(ctx context.Context) (*User, error)

func (*Department) Node

func (d *Department) Node(ctx context.Context) (node *Node, err error)

func (*Department) QueryJobs

func (d *Department) QueryJobs() *JobQuery

QueryJobs queries the "jobs" edge of the Department entity.

func (*Department) QueryManager

func (d *Department) QueryManager() *UserQuery

QueryManager queries the "manager" edge of the Department entity.

func (*Department) String

func (d *Department) String() string

String implements the fmt.Stringer.

func (*Department) ToEdge

func (d *Department) ToEdge(order *DepartmentOrder) *DepartmentEdge

ToEdge converts Department into DepartmentEdge.

func (*Department) Unwrap

func (d *Department) Unwrap() *Department

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

func (d *Department) Update() *DepartmentUpdateOne

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

type DepartmentClient

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

DepartmentClient is a client for the Department schema.

func NewDepartmentClient

func NewDepartmentClient(c config) *DepartmentClient

NewDepartmentClient returns a client for the Department from the given config.

func (*DepartmentClient) Create

func (c *DepartmentClient) Create() *DepartmentCreate

Create returns a create builder for Department.

func (*DepartmentClient) CreateBulk

func (c *DepartmentClient) CreateBulk(builders ...*DepartmentCreate) *DepartmentCreateBulk

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

func (*DepartmentClient) Delete

func (c *DepartmentClient) Delete() *DepartmentDelete

Delete returns a delete builder for Department.

func (*DepartmentClient) DeleteOne

DeleteOne returns a delete builder for the given entity.

func (*DepartmentClient) DeleteOneID

func (c *DepartmentClient) DeleteOneID(id int) *DepartmentDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*DepartmentClient) Get

func (c *DepartmentClient) Get(ctx context.Context, id int) (*Department, error)

Get returns a Department entity by its id.

func (*DepartmentClient) GetX

func (c *DepartmentClient) GetX(ctx context.Context, id int) *Department

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

func (*DepartmentClient) Hooks

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

Hooks returns the client hooks.

func (*DepartmentClient) Query

func (c *DepartmentClient) Query() *DepartmentQuery

Query returns a query builder for Department.

func (*DepartmentClient) QueryJobs

func (c *DepartmentClient) QueryJobs(d *Department) *JobQuery

QueryJobs queries the jobs edge of a Department.

func (*DepartmentClient) QueryManager

func (c *DepartmentClient) QueryManager(d *Department) *UserQuery

QueryManager queries the manager edge of a Department.

func (*DepartmentClient) Update

func (c *DepartmentClient) Update() *DepartmentUpdate

Update returns an update builder for Department.

func (*DepartmentClient) UpdateOne

UpdateOne returns an update builder for the given entity.

func (*DepartmentClient) UpdateOneID

func (c *DepartmentClient) UpdateOneID(id int) *DepartmentUpdateOne

UpdateOneID returns an update builder for the given id.

func (*DepartmentClient) Use

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

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

type DepartmentConnection

type DepartmentConnection struct {
	Edges      []*DepartmentEdge `json:"edges"`
	PageInfo   PageInfo          `json:"pageInfo"`
	TotalCount int               `json:"totalCount"`
}

DepartmentConnection is the connection containing edges to Department.

type DepartmentCreate

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

DepartmentCreate is the builder for creating a Department entity.

func (*DepartmentCreate) AddJobIDs

func (dc *DepartmentCreate) AddJobIDs(ids ...int) *DepartmentCreate

AddJobIDs adds the "jobs" edge to the Job entity by IDs.

func (*DepartmentCreate) AddJobs

func (dc *DepartmentCreate) AddJobs(j ...*Job) *DepartmentCreate

AddJobs adds the "jobs" edges to the Job entity.

func (*DepartmentCreate) Mutation

func (dc *DepartmentCreate) Mutation() *DepartmentMutation

Mutation returns the DepartmentMutation object of the builder.

func (*DepartmentCreate) Save

func (dc *DepartmentCreate) Save(ctx context.Context) (*Department, error)

Save creates the Department in the database.

func (*DepartmentCreate) SaveX

func (dc *DepartmentCreate) SaveX(ctx context.Context) *Department

SaveX calls Save and panics if Save returns an error.

func (*DepartmentCreate) SetManager

func (dc *DepartmentCreate) SetManager(u *User) *DepartmentCreate

SetManager sets the "manager" edge to the User entity.

func (*DepartmentCreate) SetManagerID

func (dc *DepartmentCreate) SetManagerID(id int) *DepartmentCreate

SetManagerID sets the "manager" edge to the User entity by ID.

func (*DepartmentCreate) SetName

func (dc *DepartmentCreate) SetName(s string) *DepartmentCreate

SetName sets the "name" field.

func (*DepartmentCreate) SetNillableManagerID

func (dc *DepartmentCreate) SetNillableManagerID(id *int) *DepartmentCreate

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

type DepartmentCreateBulk

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

DepartmentCreateBulk is the builder for creating many Department entities in bulk.

func (*DepartmentCreateBulk) Save

func (dcb *DepartmentCreateBulk) Save(ctx context.Context) ([]*Department, error)

Save creates the Department entities in the database.

func (*DepartmentCreateBulk) SaveX

func (dcb *DepartmentCreateBulk) SaveX(ctx context.Context) []*Department

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

type DepartmentDelete

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

DepartmentDelete is the builder for deleting a Department entity.

func (*DepartmentDelete) Exec

func (dd *DepartmentDelete) Exec(ctx context.Context) (int, error)

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

func (*DepartmentDelete) ExecX

func (dd *DepartmentDelete) ExecX(ctx context.Context) int

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

func (*DepartmentDelete) Where

Where adds a new predicate to the DepartmentDelete builder.

type DepartmentDeleteOne

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

DepartmentDeleteOne is the builder for deleting a single Department entity.

func (*DepartmentDeleteOne) Exec

func (ddo *DepartmentDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*DepartmentDeleteOne) ExecX

func (ddo *DepartmentDeleteOne) ExecX(ctx context.Context)

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

type DepartmentEdge

type DepartmentEdge struct {
	Node   *Department `json:"node"`
	Cursor Cursor      `json:"cursor"`
}

DepartmentEdge is the edge representation of Department.

type DepartmentEdges

type DepartmentEdges struct {
	// Jobs holds the value of the jobs edge.
	Jobs []*Job `json:"jobs,omitempty"`
	// Manager holds the value of the manager edge.
	Manager *User `json:"manager,omitempty"`
	// contains filtered or unexported fields
}

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

func (DepartmentEdges) JobsOrErr

func (e DepartmentEdges) JobsOrErr() ([]*Job, error)

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

func (DepartmentEdges) ManagerOrErr

func (e DepartmentEdges) ManagerOrErr() (*User, error)

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

type DepartmentGroupBy

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

DepartmentGroupBy is the group-by builder for Department entities.

func (*DepartmentGroupBy) Aggregate

func (dgb *DepartmentGroupBy) Aggregate(fns ...AggregateFunc) *DepartmentGroupBy

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

func (*DepartmentGroupBy) Bool

func (dgb *DepartmentGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.

func (*DepartmentGroupBy) BoolX

func (dgb *DepartmentGroupBy) BoolX(ctx context.Context) bool

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

func (*DepartmentGroupBy) Bools

func (dgb *DepartmentGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*DepartmentGroupBy) BoolsX

func (dgb *DepartmentGroupBy) BoolsX(ctx context.Context) []bool

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

func (*DepartmentGroupBy) Float64

func (dgb *DepartmentGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.

func (*DepartmentGroupBy) Float64X

func (dgb *DepartmentGroupBy) Float64X(ctx context.Context) float64

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

func (*DepartmentGroupBy) Float64s

func (dgb *DepartmentGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*DepartmentGroupBy) Float64sX

func (dgb *DepartmentGroupBy) Float64sX(ctx context.Context) []float64

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

func (*DepartmentGroupBy) Int

func (dgb *DepartmentGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.

func (*DepartmentGroupBy) IntX

func (dgb *DepartmentGroupBy) IntX(ctx context.Context) int

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

func (*DepartmentGroupBy) Ints

func (dgb *DepartmentGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*DepartmentGroupBy) IntsX

func (dgb *DepartmentGroupBy) IntsX(ctx context.Context) []int

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

func (*DepartmentGroupBy) Scan

func (dgb *DepartmentGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*DepartmentGroupBy) ScanX

func (dgb *DepartmentGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*DepartmentGroupBy) String

func (dgb *DepartmentGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.

func (*DepartmentGroupBy) StringX

func (dgb *DepartmentGroupBy) StringX(ctx context.Context) string

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

func (*DepartmentGroupBy) Strings

func (dgb *DepartmentGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*DepartmentGroupBy) StringsX

func (dgb *DepartmentGroupBy) StringsX(ctx context.Context) []string

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

type DepartmentMutation

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

DepartmentMutation represents an operation that mutates the Department nodes in the graph.

func (*DepartmentMutation) AddField

func (m *DepartmentMutation) 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 (*DepartmentMutation) AddJobIDs

func (m *DepartmentMutation) AddJobIDs(ids ...int)

AddJobIDs adds the "jobs" edge to the Job entity by ids.

func (*DepartmentMutation) AddedEdges

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

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

func (*DepartmentMutation) AddedField

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

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

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

func (*DepartmentMutation) AddedIDs

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

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

func (*DepartmentMutation) ClearEdge

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

func (m *DepartmentMutation) 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 (*DepartmentMutation) ClearJobs

func (m *DepartmentMutation) ClearJobs()

ClearJobs clears the "jobs" edge to the Job entity.

func (*DepartmentMutation) ClearManager

func (m *DepartmentMutation) ClearManager()

ClearManager clears the "manager" edge to the User entity.

func (*DepartmentMutation) ClearedEdges

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

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

func (*DepartmentMutation) ClearedFields

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

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

func (DepartmentMutation) Client

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

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

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

func (*DepartmentMutation) Field

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

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

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

func (*DepartmentMutation) Fields

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

func (m *DepartmentMutation) 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.

func (*DepartmentMutation) JobsCleared

func (m *DepartmentMutation) JobsCleared() bool

JobsCleared returns if the "jobs" edge to the Job entity was cleared.

func (*DepartmentMutation) JobsIDs

func (m *DepartmentMutation) JobsIDs() (ids []int)

JobsIDs returns the "jobs" edge IDs in the mutation.

func (*DepartmentMutation) ManagerCleared

func (m *DepartmentMutation) ManagerCleared() bool

ManagerCleared returns if the "manager" edge to the User entity was cleared.

func (*DepartmentMutation) ManagerID

func (m *DepartmentMutation) ManagerID() (id int, exists bool)

ManagerID returns the "manager" edge ID in the mutation.

func (*DepartmentMutation) ManagerIDs

func (m *DepartmentMutation) ManagerIDs() (ids []int)

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

func (*DepartmentMutation) Name

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

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

func (*DepartmentMutation) OldField

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

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

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

func (m *DepartmentMutation) Op() Op

Op returns the operation name.

func (*DepartmentMutation) RemoveJobIDs

func (m *DepartmentMutation) RemoveJobIDs(ids ...int)

RemoveJobIDs removes the "jobs" edge to the Job entity by IDs.

func (*DepartmentMutation) RemovedEdges

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

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

func (*DepartmentMutation) RemovedIDs

func (m *DepartmentMutation) 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 (*DepartmentMutation) RemovedJobsIDs

func (m *DepartmentMutation) RemovedJobsIDs() (ids []int)

RemovedJobs returns the removed IDs of the "jobs" edge to the Job entity.

func (*DepartmentMutation) ResetEdge

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

func (m *DepartmentMutation) 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 (*DepartmentMutation) ResetJobs

func (m *DepartmentMutation) ResetJobs()

ResetJobs resets all changes to the "jobs" edge.

func (*DepartmentMutation) ResetManager

func (m *DepartmentMutation) ResetManager()

ResetManager resets all changes to the "manager" edge.

func (*DepartmentMutation) ResetName

func (m *DepartmentMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*DepartmentMutation) SetField

func (m *DepartmentMutation) 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 (*DepartmentMutation) SetManagerID

func (m *DepartmentMutation) SetManagerID(id int)

SetManagerID sets the "manager" edge to the User entity by id.

func (*DepartmentMutation) SetName

func (m *DepartmentMutation) SetName(s string)

SetName sets the "name" field.

func (DepartmentMutation) Tx

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

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

func (*DepartmentMutation) Type

func (m *DepartmentMutation) Type() string

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

type DepartmentOrder

type DepartmentOrder struct {
	Direction OrderDirection        `json:"direction"`
	Field     *DepartmentOrderField `json:"field"`
}

DepartmentOrder defines the ordering of Department.

type DepartmentOrderField

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

DepartmentOrderField defines the ordering field of Department.

func (DepartmentOrderField) MarshalGQL

func (f DepartmentOrderField) MarshalGQL(w io.Writer)

MarshalGQL implements graphql.Marshaler interface.

func (DepartmentOrderField) String

func (f DepartmentOrderField) String() string

String implement fmt.Stringer interface.

func (*DepartmentOrderField) UnmarshalGQL

func (f *DepartmentOrderField) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements graphql.Unmarshaler interface.

type DepartmentPaginateOption

type DepartmentPaginateOption func(*departmentPager) error

DepartmentPaginateOption enables pagination customization.

func WithDepartmentFilter

func WithDepartmentFilter(filter func(*DepartmentQuery) (*DepartmentQuery, error)) DepartmentPaginateOption

WithDepartmentFilter configures pagination filter.

func WithDepartmentOrder

func WithDepartmentOrder(order *DepartmentOrder) DepartmentPaginateOption

WithDepartmentOrder configures pagination ordering.

type DepartmentQuery

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

DepartmentQuery is the builder for querying Department entities.

func (*DepartmentQuery) All

func (dq *DepartmentQuery) All(ctx context.Context) ([]*Department, error)

All executes the query and returns a list of Departments.

func (*DepartmentQuery) AllX

func (dq *DepartmentQuery) AllX(ctx context.Context) []*Department

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

func (*DepartmentQuery) Clone

func (dq *DepartmentQuery) Clone() *DepartmentQuery

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

func (*DepartmentQuery) CollectFields

func (d *DepartmentQuery) CollectFields(ctx context.Context, satisfies ...string) *DepartmentQuery

CollectFields tells the query-builder to eagerly load connected nodes by resolver context.

func (*DepartmentQuery) Count

func (dq *DepartmentQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*DepartmentQuery) CountX

func (dq *DepartmentQuery) CountX(ctx context.Context) int

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

func (*DepartmentQuery) Exist

func (dq *DepartmentQuery) Exist(ctx context.Context) (bool, error)

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

func (*DepartmentQuery) ExistX

func (dq *DepartmentQuery) ExistX(ctx context.Context) bool

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

func (*DepartmentQuery) First

func (dq *DepartmentQuery) First(ctx context.Context) (*Department, error)

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

func (*DepartmentQuery) FirstID

func (dq *DepartmentQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*DepartmentQuery) FirstIDX

func (dq *DepartmentQuery) FirstIDX(ctx context.Context) int

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

func (*DepartmentQuery) FirstX

func (dq *DepartmentQuery) FirstX(ctx context.Context) *Department

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

func (*DepartmentQuery) GroupBy

func (dq *DepartmentQuery) GroupBy(field string, fields ...string) *DepartmentGroupBy

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.Department.Query().
	GroupBy(department.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*DepartmentQuery) IDs

func (dq *DepartmentQuery) IDs(ctx context.Context) ([]int, error)

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

func (*DepartmentQuery) IDsX

func (dq *DepartmentQuery) IDsX(ctx context.Context) []int

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

func (*DepartmentQuery) Limit

func (dq *DepartmentQuery) Limit(limit int) *DepartmentQuery

Limit adds a limit step to the query.

func (*DepartmentQuery) Offset

func (dq *DepartmentQuery) Offset(offset int) *DepartmentQuery

Offset adds an offset step to the query.

func (*DepartmentQuery) Only

func (dq *DepartmentQuery) Only(ctx context.Context) (*Department, error)

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

func (*DepartmentQuery) OnlyID

func (dq *DepartmentQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*DepartmentQuery) OnlyIDX

func (dq *DepartmentQuery) OnlyIDX(ctx context.Context) int

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

func (*DepartmentQuery) OnlyX

func (dq *DepartmentQuery) OnlyX(ctx context.Context) *Department

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

func (*DepartmentQuery) Order

func (dq *DepartmentQuery) Order(o ...OrderFunc) *DepartmentQuery

Order adds an order step to the query.

func (*DepartmentQuery) Paginate

func (d *DepartmentQuery) Paginate(
	ctx context.Context, after *Cursor, first *int,
	before *Cursor, last *int, opts ...DepartmentPaginateOption,
) (*DepartmentConnection, error)

Paginate executes the query and returns a relay based cursor connection to Department.

func (*DepartmentQuery) QueryJobs

func (dq *DepartmentQuery) QueryJobs() *JobQuery

QueryJobs chains the current query on the "jobs" edge.

func (*DepartmentQuery) QueryManager

func (dq *DepartmentQuery) QueryManager() *UserQuery

QueryManager chains the current query on the "manager" edge.

func (*DepartmentQuery) Select

func (dq *DepartmentQuery) Select(field string, fields ...string) *DepartmentSelect

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.Department.Query().
	Select(department.FieldName).
	Scan(ctx, &v)

func (*DepartmentQuery) Where

Where adds a new predicate for the DepartmentQuery builder.

func (*DepartmentQuery) WithJobs

func (dq *DepartmentQuery) WithJobs(opts ...func(*JobQuery)) *DepartmentQuery

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

func (*DepartmentQuery) WithManager

func (dq *DepartmentQuery) WithManager(opts ...func(*UserQuery)) *DepartmentQuery

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

type DepartmentSelect

type DepartmentSelect struct {
	*DepartmentQuery
	// contains filtered or unexported fields
}

DepartmentSelect is the builder for selecting fields of Department entities.

func (*DepartmentSelect) Bool

func (ds *DepartmentSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*DepartmentSelect) BoolX

func (ds *DepartmentSelect) BoolX(ctx context.Context) bool

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

func (*DepartmentSelect) Bools

func (ds *DepartmentSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*DepartmentSelect) BoolsX

func (ds *DepartmentSelect) BoolsX(ctx context.Context) []bool

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

func (*DepartmentSelect) Float64

func (ds *DepartmentSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*DepartmentSelect) Float64X

func (ds *DepartmentSelect) Float64X(ctx context.Context) float64

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

func (*DepartmentSelect) Float64s

func (ds *DepartmentSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*DepartmentSelect) Float64sX

func (ds *DepartmentSelect) Float64sX(ctx context.Context) []float64

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

func (*DepartmentSelect) Int

func (ds *DepartmentSelect) Int(ctx context.Context) (_ int, err error)

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

func (*DepartmentSelect) IntX

func (ds *DepartmentSelect) IntX(ctx context.Context) int

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

func (*DepartmentSelect) Ints

func (ds *DepartmentSelect) Ints(ctx context.Context) ([]int, error)

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

func (*DepartmentSelect) IntsX

func (ds *DepartmentSelect) IntsX(ctx context.Context) []int

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

func (*DepartmentSelect) Scan

func (ds *DepartmentSelect) Scan(ctx context.Context, v interface{}) error

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

func (*DepartmentSelect) ScanX

func (ds *DepartmentSelect) ScanX(ctx context.Context, v interface{})

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

func (*DepartmentSelect) String

func (ds *DepartmentSelect) String(ctx context.Context) (_ string, err error)

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

func (*DepartmentSelect) StringX

func (ds *DepartmentSelect) StringX(ctx context.Context) string

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

func (*DepartmentSelect) Strings

func (ds *DepartmentSelect) Strings(ctx context.Context) ([]string, error)

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

func (*DepartmentSelect) StringsX

func (ds *DepartmentSelect) StringsX(ctx context.Context) []string

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

type DepartmentUpdate

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

DepartmentUpdate is the builder for updating Department entities.

func (*DepartmentUpdate) AddJobIDs

func (du *DepartmentUpdate) AddJobIDs(ids ...int) *DepartmentUpdate

AddJobIDs adds the "jobs" edge to the Job entity by IDs.

func (*DepartmentUpdate) AddJobs

func (du *DepartmentUpdate) AddJobs(j ...*Job) *DepartmentUpdate

AddJobs adds the "jobs" edges to the Job entity.

func (*DepartmentUpdate) ClearJobs

func (du *DepartmentUpdate) ClearJobs() *DepartmentUpdate

ClearJobs clears all "jobs" edges to the Job entity.

func (*DepartmentUpdate) ClearManager

func (du *DepartmentUpdate) ClearManager() *DepartmentUpdate

ClearManager clears the "manager" edge to the User entity.

func (*DepartmentUpdate) Exec

func (du *DepartmentUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*DepartmentUpdate) ExecX

func (du *DepartmentUpdate) ExecX(ctx context.Context)

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

func (*DepartmentUpdate) Mutation

func (du *DepartmentUpdate) Mutation() *DepartmentMutation

Mutation returns the DepartmentMutation object of the builder.

func (*DepartmentUpdate) RemoveJobIDs

func (du *DepartmentUpdate) RemoveJobIDs(ids ...int) *DepartmentUpdate

RemoveJobIDs removes the "jobs" edge to Job entities by IDs.

func (*DepartmentUpdate) RemoveJobs

func (du *DepartmentUpdate) RemoveJobs(j ...*Job) *DepartmentUpdate

RemoveJobs removes "jobs" edges to Job entities.

func (*DepartmentUpdate) Save

func (du *DepartmentUpdate) Save(ctx context.Context) (int, error)

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

func (*DepartmentUpdate) SaveX

func (du *DepartmentUpdate) SaveX(ctx context.Context) int

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

func (*DepartmentUpdate) SetManager

func (du *DepartmentUpdate) SetManager(u *User) *DepartmentUpdate

SetManager sets the "manager" edge to the User entity.

func (*DepartmentUpdate) SetManagerID

func (du *DepartmentUpdate) SetManagerID(id int) *DepartmentUpdate

SetManagerID sets the "manager" edge to the User entity by ID.

func (*DepartmentUpdate) SetName

func (du *DepartmentUpdate) SetName(s string) *DepartmentUpdate

SetName sets the "name" field.

func (*DepartmentUpdate) SetNillableManagerID

func (du *DepartmentUpdate) SetNillableManagerID(id *int) *DepartmentUpdate

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

func (*DepartmentUpdate) Where

Where adds a new predicate for the DepartmentUpdate builder.

type DepartmentUpdateOne

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

DepartmentUpdateOne is the builder for updating a single Department entity.

func (*DepartmentUpdateOne) AddJobIDs

func (duo *DepartmentUpdateOne) AddJobIDs(ids ...int) *DepartmentUpdateOne

AddJobIDs adds the "jobs" edge to the Job entity by IDs.

func (*DepartmentUpdateOne) AddJobs

func (duo *DepartmentUpdateOne) AddJobs(j ...*Job) *DepartmentUpdateOne

AddJobs adds the "jobs" edges to the Job entity.

func (*DepartmentUpdateOne) ClearJobs

func (duo *DepartmentUpdateOne) ClearJobs() *DepartmentUpdateOne

ClearJobs clears all "jobs" edges to the Job entity.

func (*DepartmentUpdateOne) ClearManager

func (duo *DepartmentUpdateOne) ClearManager() *DepartmentUpdateOne

ClearManager clears the "manager" edge to the User entity.

func (*DepartmentUpdateOne) Exec

func (duo *DepartmentUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*DepartmentUpdateOne) ExecX

func (duo *DepartmentUpdateOne) ExecX(ctx context.Context)

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

func (*DepartmentUpdateOne) Mutation

func (duo *DepartmentUpdateOne) Mutation() *DepartmentMutation

Mutation returns the DepartmentMutation object of the builder.

func (*DepartmentUpdateOne) RemoveJobIDs

func (duo *DepartmentUpdateOne) RemoveJobIDs(ids ...int) *DepartmentUpdateOne

RemoveJobIDs removes the "jobs" edge to Job entities by IDs.

func (*DepartmentUpdateOne) RemoveJobs

func (duo *DepartmentUpdateOne) RemoveJobs(j ...*Job) *DepartmentUpdateOne

RemoveJobs removes "jobs" edges to Job entities.

func (*DepartmentUpdateOne) Save

func (duo *DepartmentUpdateOne) Save(ctx context.Context) (*Department, error)

Save executes the query and returns the updated Department entity.

func (*DepartmentUpdateOne) SaveX

func (duo *DepartmentUpdateOne) SaveX(ctx context.Context) *Department

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

func (*DepartmentUpdateOne) SetManager

func (duo *DepartmentUpdateOne) SetManager(u *User) *DepartmentUpdateOne

SetManager sets the "manager" edge to the User entity.

func (*DepartmentUpdateOne) SetManagerID

func (duo *DepartmentUpdateOne) SetManagerID(id int) *DepartmentUpdateOne

SetManagerID sets the "manager" edge to the User entity by ID.

func (*DepartmentUpdateOne) SetName

SetName sets the "name" field.

func (*DepartmentUpdateOne) SetNillableManagerID

func (duo *DepartmentUpdateOne) SetNillableManagerID(id *int) *DepartmentUpdateOne

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

type Departments

type Departments []*Department

Departments is a parsable slice of Department.

type Edge

type Edge struct {
	Type string `json:"type,omitempty"` // edge type.
	Name string `json:"name,omitempty"` // edge name.
	IDs  []int  `json:"ids,omitempty"`  // node ids (where this edge point to).
}

Edges between two nodes.

type Field

type Field struct {
	Type  string `json:"type,omitempty"`  // field type.
	Name  string `json:"name,omitempty"`  // field name (as in struct).
	Value string `json:"value,omitempty"` // stringified value.
}

Field of a node.

type Hook

type Hook = ent.Hook

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

type Job

type Job struct {

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

Job is the model entity for the Job schema.

func (*Job) Department

func (j *Job) Department(ctx context.Context) (*Department, error)

func (*Job) Node

func (j *Job) Node(ctx context.Context) (node *Node, err error)

func (*Job) QueryDepartment

func (j *Job) QueryDepartment() *DepartmentQuery

QueryDepartment queries the "department" edge of the Job entity.

func (*Job) String

func (j *Job) String() string

String implements the fmt.Stringer.

func (*Job) ToEdge

func (j *Job) ToEdge(order *JobOrder) *JobEdge

ToEdge converts Job into JobEdge.

func (*Job) Unwrap

func (j *Job) Unwrap() *Job

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

func (j *Job) Update() *JobUpdateOne

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

type JobClient

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

JobClient is a client for the Job schema.

func NewJobClient

func NewJobClient(c config) *JobClient

NewJobClient returns a client for the Job from the given config.

func (*JobClient) Create

func (c *JobClient) Create() *JobCreate

Create returns a create builder for Job.

func (*JobClient) CreateBulk

func (c *JobClient) CreateBulk(builders ...*JobCreate) *JobCreateBulk

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

func (*JobClient) Delete

func (c *JobClient) Delete() *JobDelete

Delete returns a delete builder for Job.

func (*JobClient) DeleteOne

func (c *JobClient) DeleteOne(j *Job) *JobDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*JobClient) DeleteOneID

func (c *JobClient) DeleteOneID(id int) *JobDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*JobClient) Get

func (c *JobClient) Get(ctx context.Context, id int) (*Job, error)

Get returns a Job entity by its id.

func (*JobClient) GetX

func (c *JobClient) GetX(ctx context.Context, id int) *Job

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

func (*JobClient) Hooks

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

Hooks returns the client hooks.

func (*JobClient) Query

func (c *JobClient) Query() *JobQuery

Query returns a query builder for Job.

func (*JobClient) QueryDepartment

func (c *JobClient) QueryDepartment(j *Job) *DepartmentQuery

QueryDepartment queries the department edge of a Job.

func (*JobClient) Update

func (c *JobClient) Update() *JobUpdate

Update returns an update builder for Job.

func (*JobClient) UpdateOne

func (c *JobClient) UpdateOne(j *Job) *JobUpdateOne

UpdateOne returns an update builder for the given entity.

func (*JobClient) UpdateOneID

func (c *JobClient) UpdateOneID(id int) *JobUpdateOne

UpdateOneID returns an update builder for the given id.

func (*JobClient) Use

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

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

type JobConnection

type JobConnection struct {
	Edges      []*JobEdge `json:"edges"`
	PageInfo   PageInfo   `json:"pageInfo"`
	TotalCount int        `json:"totalCount"`
}

JobConnection is the connection containing edges to Job.

type JobCreate

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

JobCreate is the builder for creating a Job entity.

func (*JobCreate) Mutation

func (jc *JobCreate) Mutation() *JobMutation

Mutation returns the JobMutation object of the builder.

func (*JobCreate) Save

func (jc *JobCreate) Save(ctx context.Context) (*Job, error)

Save creates the Job in the database.

func (*JobCreate) SaveX

func (jc *JobCreate) SaveX(ctx context.Context) *Job

SaveX calls Save and panics if Save returns an error.

func (*JobCreate) SetDepartment

func (jc *JobCreate) SetDepartment(d *Department) *JobCreate

SetDepartment sets the "department" edge to the Department entity.

func (*JobCreate) SetDepartmentID

func (jc *JobCreate) SetDepartmentID(id int) *JobCreate

SetDepartmentID sets the "department" edge to the Department entity by ID.

func (*JobCreate) SetDescription

func (jc *JobCreate) SetDescription(s string) *JobCreate

SetDescription sets the "description" field.

func (*JobCreate) SetName

func (jc *JobCreate) SetName(s string) *JobCreate

SetName sets the "name" field.

func (*JobCreate) SetNillableDepartmentID

func (jc *JobCreate) SetNillableDepartmentID(id *int) *JobCreate

SetNillableDepartmentID sets the "department" edge to the Department entity by ID if the given value is not nil.

type JobCreateBulk

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

JobCreateBulk is the builder for creating many Job entities in bulk.

func (*JobCreateBulk) Save

func (jcb *JobCreateBulk) Save(ctx context.Context) ([]*Job, error)

Save creates the Job entities in the database.

func (*JobCreateBulk) SaveX

func (jcb *JobCreateBulk) SaveX(ctx context.Context) []*Job

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

type JobDelete

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

JobDelete is the builder for deleting a Job entity.

func (*JobDelete) Exec

func (jd *JobDelete) Exec(ctx context.Context) (int, error)

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

func (*JobDelete) ExecX

func (jd *JobDelete) ExecX(ctx context.Context) int

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

func (*JobDelete) Where

func (jd *JobDelete) Where(ps ...predicate.Job) *JobDelete

Where adds a new predicate to the JobDelete builder.

type JobDeleteOne

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

JobDeleteOne is the builder for deleting a single Job entity.

func (*JobDeleteOne) Exec

func (jdo *JobDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*JobDeleteOne) ExecX

func (jdo *JobDeleteOne) ExecX(ctx context.Context)

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

type JobEdge

type JobEdge struct {
	Node   *Job   `json:"node"`
	Cursor Cursor `json:"cursor"`
}

JobEdge is the edge representation of Job.

type JobEdges

type JobEdges struct {
	// Department holds the value of the department edge.
	Department *Department `json:"department,omitempty"`
	// contains filtered or unexported fields
}

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

func (JobEdges) DepartmentOrErr

func (e JobEdges) DepartmentOrErr() (*Department, error)

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

type JobGroupBy

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

JobGroupBy is the group-by builder for Job entities.

func (*JobGroupBy) Aggregate

func (jgb *JobGroupBy) Aggregate(fns ...AggregateFunc) *JobGroupBy

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

func (*JobGroupBy) Bool

func (jgb *JobGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.

func (*JobGroupBy) BoolX

func (jgb *JobGroupBy) BoolX(ctx context.Context) bool

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

func (*JobGroupBy) Bools

func (jgb *JobGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*JobGroupBy) BoolsX

func (jgb *JobGroupBy) BoolsX(ctx context.Context) []bool

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

func (*JobGroupBy) Float64

func (jgb *JobGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.

func (*JobGroupBy) Float64X

func (jgb *JobGroupBy) Float64X(ctx context.Context) float64

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

func (*JobGroupBy) Float64s

func (jgb *JobGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*JobGroupBy) Float64sX

func (jgb *JobGroupBy) Float64sX(ctx context.Context) []float64

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

func (*JobGroupBy) Int

func (jgb *JobGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.

func (*JobGroupBy) IntX

func (jgb *JobGroupBy) IntX(ctx context.Context) int

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

func (*JobGroupBy) Ints

func (jgb *JobGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*JobGroupBy) IntsX

func (jgb *JobGroupBy) IntsX(ctx context.Context) []int

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

func (*JobGroupBy) Scan

func (jgb *JobGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*JobGroupBy) ScanX

func (jgb *JobGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*JobGroupBy) String

func (jgb *JobGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.

func (*JobGroupBy) StringX

func (jgb *JobGroupBy) StringX(ctx context.Context) string

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

func (*JobGroupBy) Strings

func (jgb *JobGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*JobGroupBy) StringsX

func (jgb *JobGroupBy) StringsX(ctx context.Context) []string

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

type JobMutation

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

JobMutation represents an operation that mutates the Job nodes in the graph.

func (*JobMutation) AddField

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

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

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

func (*JobMutation) AddedField

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

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

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

func (*JobMutation) AddedIDs

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

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

func (*JobMutation) ClearDepartment

func (m *JobMutation) ClearDepartment()

ClearDepartment clears the "department" edge to the Department entity.

func (*JobMutation) ClearEdge

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

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

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

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

func (*JobMutation) ClearedFields

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

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

func (JobMutation) Client

func (m JobMutation) 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 (*JobMutation) DepartmentCleared

func (m *JobMutation) DepartmentCleared() bool

DepartmentCleared returns if the "department" edge to the Department entity was cleared.

func (*JobMutation) DepartmentID

func (m *JobMutation) DepartmentID() (id int, exists bool)

DepartmentID returns the "department" edge ID in the mutation.

func (*JobMutation) DepartmentIDs

func (m *JobMutation) DepartmentIDs() (ids []int)

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

func (*JobMutation) Description

func (m *JobMutation) Description() (r string, exists bool)

Description returns the value of the "description" field in the mutation.

func (*JobMutation) EdgeCleared

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

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

func (*JobMutation) Field

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

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

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

func (*JobMutation) Fields

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

func (m *JobMutation) 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.

func (*JobMutation) Name

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

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

func (*JobMutation) OldDescription

func (m *JobMutation) OldDescription(ctx context.Context) (v string, err error)

OldDescription returns the old "description" field's value of the Job entity. If the Job 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 (*JobMutation) OldField

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

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

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

func (m *JobMutation) Op() Op

Op returns the operation name.

func (*JobMutation) RemovedEdges

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

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

func (*JobMutation) RemovedIDs

func (m *JobMutation) 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 (*JobMutation) ResetDepartment

func (m *JobMutation) ResetDepartment()

ResetDepartment resets all changes to the "department" edge.

func (*JobMutation) ResetDescription

func (m *JobMutation) ResetDescription()

ResetDescription resets all changes to the "description" field.

func (*JobMutation) ResetEdge

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

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

func (m *JobMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*JobMutation) SetDepartmentID

func (m *JobMutation) SetDepartmentID(id int)

SetDepartmentID sets the "department" edge to the Department entity by id.

func (*JobMutation) SetDescription

func (m *JobMutation) SetDescription(s string)

SetDescription sets the "description" field.

func (*JobMutation) SetField

func (m *JobMutation) 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 (*JobMutation) SetName

func (m *JobMutation) SetName(s string)

SetName sets the "name" field.

func (JobMutation) Tx

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

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

func (*JobMutation) Type

func (m *JobMutation) Type() string

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

type JobOrder

type JobOrder struct {
	Direction OrderDirection `json:"direction"`
	Field     *JobOrderField `json:"field"`
}

JobOrder defines the ordering of Job.

type JobOrderField

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

JobOrderField defines the ordering field of Job.

func (JobOrderField) MarshalGQL

func (f JobOrderField) MarshalGQL(w io.Writer)

MarshalGQL implements graphql.Marshaler interface.

func (JobOrderField) String

func (f JobOrderField) String() string

String implement fmt.Stringer interface.

func (*JobOrderField) UnmarshalGQL

func (f *JobOrderField) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements graphql.Unmarshaler interface.

type JobPaginateOption

type JobPaginateOption func(*jobPager) error

JobPaginateOption enables pagination customization.

func WithJobFilter

func WithJobFilter(filter func(*JobQuery) (*JobQuery, error)) JobPaginateOption

WithJobFilter configures pagination filter.

func WithJobOrder

func WithJobOrder(order *JobOrder) JobPaginateOption

WithJobOrder configures pagination ordering.

type JobQuery

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

JobQuery is the builder for querying Job entities.

func (*JobQuery) All

func (jq *JobQuery) All(ctx context.Context) ([]*Job, error)

All executes the query and returns a list of Jobs.

func (*JobQuery) AllX

func (jq *JobQuery) AllX(ctx context.Context) []*Job

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

func (*JobQuery) Clone

func (jq *JobQuery) Clone() *JobQuery

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

func (*JobQuery) CollectFields

func (j *JobQuery) CollectFields(ctx context.Context, satisfies ...string) *JobQuery

CollectFields tells the query-builder to eagerly load connected nodes by resolver context.

func (*JobQuery) Count

func (jq *JobQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*JobQuery) CountX

func (jq *JobQuery) CountX(ctx context.Context) int

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

func (*JobQuery) Exist

func (jq *JobQuery) Exist(ctx context.Context) (bool, error)

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

func (*JobQuery) ExistX

func (jq *JobQuery) ExistX(ctx context.Context) bool

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

func (*JobQuery) First

func (jq *JobQuery) First(ctx context.Context) (*Job, error)

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

func (*JobQuery) FirstID

func (jq *JobQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*JobQuery) FirstIDX

func (jq *JobQuery) FirstIDX(ctx context.Context) int

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

func (*JobQuery) FirstX

func (jq *JobQuery) FirstX(ctx context.Context) *Job

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

func (*JobQuery) GroupBy

func (jq *JobQuery) GroupBy(field string, fields ...string) *JobGroupBy

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.Job.Query().
	GroupBy(job.FieldName).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*JobQuery) IDs

func (jq *JobQuery) IDs(ctx context.Context) ([]int, error)

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

func (*JobQuery) IDsX

func (jq *JobQuery) IDsX(ctx context.Context) []int

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

func (*JobQuery) Limit

func (jq *JobQuery) Limit(limit int) *JobQuery

Limit adds a limit step to the query.

func (*JobQuery) Offset

func (jq *JobQuery) Offset(offset int) *JobQuery

Offset adds an offset step to the query.

func (*JobQuery) Only

func (jq *JobQuery) Only(ctx context.Context) (*Job, error)

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

func (*JobQuery) OnlyID

func (jq *JobQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*JobQuery) OnlyIDX

func (jq *JobQuery) OnlyIDX(ctx context.Context) int

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

func (*JobQuery) OnlyX

func (jq *JobQuery) OnlyX(ctx context.Context) *Job

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

func (*JobQuery) Order

func (jq *JobQuery) Order(o ...OrderFunc) *JobQuery

Order adds an order step to the query.

func (*JobQuery) Paginate

func (j *JobQuery) Paginate(
	ctx context.Context, after *Cursor, first *int,
	before *Cursor, last *int, opts ...JobPaginateOption,
) (*JobConnection, error)

Paginate executes the query and returns a relay based cursor connection to Job.

func (*JobQuery) QueryDepartment

func (jq *JobQuery) QueryDepartment() *DepartmentQuery

QueryDepartment chains the current query on the "department" edge.

func (*JobQuery) Select

func (jq *JobQuery) Select(field string, fields ...string) *JobSelect

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.Job.Query().
	Select(job.FieldName).
	Scan(ctx, &v)

func (*JobQuery) Where

func (jq *JobQuery) Where(ps ...predicate.Job) *JobQuery

Where adds a new predicate for the JobQuery builder.

func (*JobQuery) WithDepartment

func (jq *JobQuery) WithDepartment(opts ...func(*DepartmentQuery)) *JobQuery

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

type JobSelect

type JobSelect struct {
	*JobQuery
	// contains filtered or unexported fields
}

JobSelect is the builder for selecting fields of Job entities.

func (*JobSelect) Bool

func (js *JobSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*JobSelect) BoolX

func (js *JobSelect) BoolX(ctx context.Context) bool

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

func (*JobSelect) Bools

func (js *JobSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*JobSelect) BoolsX

func (js *JobSelect) BoolsX(ctx context.Context) []bool

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

func (*JobSelect) Float64

func (js *JobSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*JobSelect) Float64X

func (js *JobSelect) Float64X(ctx context.Context) float64

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

func (*JobSelect) Float64s

func (js *JobSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*JobSelect) Float64sX

func (js *JobSelect) Float64sX(ctx context.Context) []float64

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

func (*JobSelect) Int

func (js *JobSelect) Int(ctx context.Context) (_ int, err error)

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

func (*JobSelect) IntX

func (js *JobSelect) IntX(ctx context.Context) int

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

func (*JobSelect) Ints

func (js *JobSelect) Ints(ctx context.Context) ([]int, error)

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

func (*JobSelect) IntsX

func (js *JobSelect) IntsX(ctx context.Context) []int

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

func (*JobSelect) Scan

func (js *JobSelect) Scan(ctx context.Context, v interface{}) error

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

func (*JobSelect) ScanX

func (js *JobSelect) ScanX(ctx context.Context, v interface{})

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

func (*JobSelect) String

func (js *JobSelect) String(ctx context.Context) (_ string, err error)

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

func (*JobSelect) StringX

func (js *JobSelect) StringX(ctx context.Context) string

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

func (*JobSelect) Strings

func (js *JobSelect) Strings(ctx context.Context) ([]string, error)

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

func (*JobSelect) StringsX

func (js *JobSelect) StringsX(ctx context.Context) []string

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

type JobUpdate

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

JobUpdate is the builder for updating Job entities.

func (*JobUpdate) ClearDepartment

func (ju *JobUpdate) ClearDepartment() *JobUpdate

ClearDepartment clears the "department" edge to the Department entity.

func (*JobUpdate) Exec

func (ju *JobUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*JobUpdate) ExecX

func (ju *JobUpdate) ExecX(ctx context.Context)

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

func (*JobUpdate) Mutation

func (ju *JobUpdate) Mutation() *JobMutation

Mutation returns the JobMutation object of the builder.

func (*JobUpdate) Save

func (ju *JobUpdate) Save(ctx context.Context) (int, error)

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

func (*JobUpdate) SaveX

func (ju *JobUpdate) SaveX(ctx context.Context) int

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

func (*JobUpdate) SetDepartment

func (ju *JobUpdate) SetDepartment(d *Department) *JobUpdate

SetDepartment sets the "department" edge to the Department entity.

func (*JobUpdate) SetDepartmentID

func (ju *JobUpdate) SetDepartmentID(id int) *JobUpdate

SetDepartmentID sets the "department" edge to the Department entity by ID.

func (*JobUpdate) SetDescription

func (ju *JobUpdate) SetDescription(s string) *JobUpdate

SetDescription sets the "description" field.

func (*JobUpdate) SetName

func (ju *JobUpdate) SetName(s string) *JobUpdate

SetName sets the "name" field.

func (*JobUpdate) SetNillableDepartmentID

func (ju *JobUpdate) SetNillableDepartmentID(id *int) *JobUpdate

SetNillableDepartmentID sets the "department" edge to the Department entity by ID if the given value is not nil.

func (*JobUpdate) Where

func (ju *JobUpdate) Where(ps ...predicate.Job) *JobUpdate

Where adds a new predicate for the JobUpdate builder.

type JobUpdateOne

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

JobUpdateOne is the builder for updating a single Job entity.

func (*JobUpdateOne) ClearDepartment

func (juo *JobUpdateOne) ClearDepartment() *JobUpdateOne

ClearDepartment clears the "department" edge to the Department entity.

func (*JobUpdateOne) Exec

func (juo *JobUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*JobUpdateOne) ExecX

func (juo *JobUpdateOne) ExecX(ctx context.Context)

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

func (*JobUpdateOne) Mutation

func (juo *JobUpdateOne) Mutation() *JobMutation

Mutation returns the JobMutation object of the builder.

func (*JobUpdateOne) Save

func (juo *JobUpdateOne) Save(ctx context.Context) (*Job, error)

Save executes the query and returns the updated Job entity.

func (*JobUpdateOne) SaveX

func (juo *JobUpdateOne) SaveX(ctx context.Context) *Job

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

func (*JobUpdateOne) SetDepartment

func (juo *JobUpdateOne) SetDepartment(d *Department) *JobUpdateOne

SetDepartment sets the "department" edge to the Department entity.

func (*JobUpdateOne) SetDepartmentID

func (juo *JobUpdateOne) SetDepartmentID(id int) *JobUpdateOne

SetDepartmentID sets the "department" edge to the Department entity by ID.

func (*JobUpdateOne) SetDescription

func (juo *JobUpdateOne) SetDescription(s string) *JobUpdateOne

SetDescription sets the "description" field.

func (*JobUpdateOne) SetName

func (juo *JobUpdateOne) SetName(s string) *JobUpdateOne

SetName sets the "name" field.

func (*JobUpdateOne) SetNillableDepartmentID

func (juo *JobUpdateOne) SetNillableDepartmentID(id *int) *JobUpdateOne

SetNillableDepartmentID sets the "department" edge to the Department entity by ID if the given value is not nil.

type Jobs

type Jobs []*Job

Jobs is a parsable slice of Job.

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 Node

type Node struct {
	ID     int      `json:"id,omitempty"`     // node id.
	Type   string   `json:"type,omitempty"`   // node type.
	Fields []*Field `json:"fields,omitempty"` // node fields.
	Edges  []*Edge  `json:"edges,omitempty"`  // node edges.
}

Node in the graph.

type NodeOption

type NodeOption func(*nodeOptions)

NodeOption allows configuring the Noder execution using functional options.

func WithFixedNodeType

func WithFixedNodeType(t string) NodeOption

WithFixedNodeType sets the Type of the node to a fixed value.

func WithNodeType

func WithNodeType(f func(context.Context, int) (string, error)) NodeOption

WithNodeType sets the node Type resolver function (i.e. the table to query). If was not provided, the table will be derived from the universal-id configuration as described in: https://entgo.io/docs/migrate/#universal-ids.

type Noder

type Noder interface {
	Node(context.Context) (*Node, error)
}

Noder wraps the basic Node method.

type NotFoundError

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

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

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

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

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

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

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

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

Log sets the logging function for debug mode.

type OrderDirection

type OrderDirection string

OrderDirection defines the directions in which to order a list of items.

const (
	// OrderDirectionAsc specifies an ascending order.
	OrderDirectionAsc OrderDirection = "ASC"
	// OrderDirectionDesc specifies a descending order.
	OrderDirectionDesc OrderDirection = "DESC"
)

func (OrderDirection) MarshalGQL

func (o OrderDirection) MarshalGQL(w io.Writer)

MarshalGQL implements graphql.Marshaler interface.

func (OrderDirection) String

func (o OrderDirection) String() string

String implements fmt.Stringer interface.

func (*OrderDirection) UnmarshalGQL

func (o *OrderDirection) UnmarshalGQL(val interface{}) error

UnmarshalGQL implements graphql.Unmarshaler interface.

func (OrderDirection) Validate

func (o OrderDirection) Validate() error

Validate the order direction value.

type OrderFunc

type OrderFunc func(*sql.Selector, func(string) bool)

OrderFunc applies an ordering on the sql selector.

func Asc

func Asc(fields ...string) OrderFunc

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) OrderFunc

Desc applies the given fields in DESC order.

type PageInfo

type PageInfo struct {
	HasNextPage     bool    `json:"hasNextPage"`
	HasPreviousPage bool    `json:"hasPreviousPage"`
	StartCursor     *Cursor `json:"startCursor"`
	EndCursor       *Cursor `json:"endCursor"`
}

PageInfo of a connection type.

type Policy

type Policy = ent.Policy

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

type Query

type Query = ent.Query

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

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

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

type Rollbacker

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

Rollbacker is the interface that wraps the Rollbacker method.

type Tx

type Tx struct {

	// Department is the client for interacting with the Department builders.
	Department *DepartmentClient
	// Job is the client for interacting with the Job builders.
	Job *JobClient
	// 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"`
	// CreateTime holds the value of the "create_time" field.
	CreateTime time.Time `json:"create_time,omitempty"`
	// UpdateTime holds the value of the "update_time" field.
	UpdateTime time.Time `json:"update_time,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Email holds the value of the "email" field.
	Email string `json:"email,omitempty"`
	// Password holds the value of the "password" field.
	Password string `json:"password,omitempty"`
	// Role holds the value of the "role" field.
	Role user.Role `json:"role,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) Departments

func (u *User) Departments(ctx context.Context) ([]*Department, error)

func (*User) Node

func (u *User) Node(ctx context.Context) (node *Node, err error)

func (*User) QueryDepartments

func (u *User) QueryDepartments() *DepartmentQuery

QueryDepartments queries the "departments" edge of the User entity.

func (*User) String

func (u *User) String() string

String implements the fmt.Stringer.

func (*User) ToEdge

func (u *User) ToEdge(order *UserOrder) *UserEdge

ToEdge converts User into UserEdge.

func (*User) Unwrap

func (u *User) Unwrap() *User

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

func (*User) Update

func (u *User) Update() *UserUpdateOne

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

type UserClient

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

UserClient is a client for the User schema.

func NewUserClient

func NewUserClient(c config) *UserClient

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

func (*UserClient) Create

func (c *UserClient) Create() *UserCreate

Create returns a create builder for User.

func (*UserClient) CreateBulk

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

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

func (*UserClient) Delete

func (c *UserClient) Delete() *UserDelete

Delete returns a delete builder for User.

func (*UserClient) DeleteOne

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

DeleteOne returns a delete builder for the given entity.

func (*UserClient) DeleteOneID

func (c *UserClient) DeleteOneID(id int) *UserDeleteOne

DeleteOneID returns a delete builder for the given 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) QueryDepartments

func (c *UserClient) QueryDepartments(u *User) *DepartmentQuery

QueryDepartments queries the departments 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 UserConnection

type UserConnection struct {
	Edges      []*UserEdge `json:"edges"`
	PageInfo   PageInfo    `json:"pageInfo"`
	TotalCount int         `json:"totalCount"`
}

UserConnection is the connection containing edges to User.

type UserCreate

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

UserCreate is the builder for creating a User entity.

func (*UserCreate) AddDepartmentIDs

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

AddDepartmentIDs adds the "departments" edge to the Department entity by IDs.

func (*UserCreate) AddDepartments

func (uc *UserCreate) AddDepartments(d ...*Department) *UserCreate

AddDepartments adds the "departments" edges to the Department entity.

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

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

SetCreateTime sets the "create_time" field.

func (*UserCreate) SetEmail

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

SetEmail sets the "email" field.

func (*UserCreate) SetName

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

SetName sets the "name" field.

func (*UserCreate) SetNillableCreateTime

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

SetNillableCreateTime sets the "create_time" field if the given value is not nil.

func (*UserCreate) SetNillableUpdateTime

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

SetNillableUpdateTime sets the "update_time" field if the given value is not nil.

func (*UserCreate) SetPassword

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

SetPassword sets the "password" field.

func (*UserCreate) SetRole

func (uc *UserCreate) SetRole(u user.Role) *UserCreate

SetRole sets the "role" field.

func (*UserCreate) SetUpdateTime

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

SetUpdateTime sets the "update_time" field.

type UserCreateBulk

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

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

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

type UserEdge struct {
	Node   *User  `json:"node"`
	Cursor Cursor `json:"cursor"`
}

UserEdge is the edge representation of User.

type UserEdges

type UserEdges struct {
	// Departments holds the value of the departments edge.
	Departments []*Department `json:"departments,omitempty"`
	// contains filtered or unexported fields
}

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

func (UserEdges) DepartmentsOrErr

func (e UserEdges) DepartmentsOrErr() ([]*Department, error)

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

type UserGroupBy

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

UserGroupBy is the group-by builder for User entities.

func (*UserGroupBy) Aggregate

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

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

func (*UserGroupBy) Bool

func (ugb *UserGroupBy) Bool(ctx context.Context) (_ bool, err error)

Bool returns a single bool from a group-by query. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) BoolX

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

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

func (*UserGroupBy) Bools

func (ugb *UserGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*UserGroupBy) BoolsX

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

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

func (*UserGroupBy) Float64

func (ugb *UserGroupBy) Float64(ctx context.Context) (_ float64, err error)

Float64 returns a single float64 from a group-by query. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) Float64X

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

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

func (*UserGroupBy) Float64s

func (ugb *UserGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*UserGroupBy) Float64sX

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

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

func (*UserGroupBy) Int

func (ugb *UserGroupBy) Int(ctx context.Context) (_ int, err error)

Int returns a single int from a group-by query. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) IntX

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

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

func (*UserGroupBy) Ints

func (ugb *UserGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*UserGroupBy) IntsX

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

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

func (*UserGroupBy) Scan

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

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

func (*UserGroupBy) ScanX

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

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

func (*UserGroupBy) String

func (ugb *UserGroupBy) String(ctx context.Context) (_ string, err error)

String returns a single string from a group-by query. It is only allowed when executing a group-by query with one field.

func (*UserGroupBy) StringX

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

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

func (*UserGroupBy) Strings

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

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

func (*UserGroupBy) StringsX

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

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

type UserMutation

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

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

func (*UserMutation) AddDepartmentIDs

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

AddDepartmentIDs adds the "departments" edge to the Department entity by ids.

func (*UserMutation) AddField

func (m *UserMutation) AddField(name string, value ent.Value) error

AddField adds the value to the field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

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

func (m *UserMutation) ClearDepartments()

ClearDepartments clears the "departments" edge to the Department entity.

func (*UserMutation) ClearEdge

func (m *UserMutation) ClearEdge(name string) error

ClearEdge clears the value of the edge with the given name. It returns an error if that edge is not defined in the schema.

func (*UserMutation) ClearField

func (m *UserMutation) ClearField(name string) error

ClearField clears the value of the field with the given name. It returns an error if the field is not defined in the schema.

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

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

CreateTime returns the value of the "create_time" field in the mutation.

func (*UserMutation) DepartmentsCleared

func (m *UserMutation) DepartmentsCleared() bool

DepartmentsCleared returns if the "departments" edge to the Department entity was cleared.

func (*UserMutation) DepartmentsIDs

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

DepartmentsIDs returns the "departments" edge IDs in the mutation.

func (*UserMutation) EdgeCleared

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

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

func (*UserMutation) Email

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

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

func (*UserMutation) Field

func (m *UserMutation) Field(name string) (ent.Value, bool)

Field returns the value of a field with the given name. The second boolean return value indicates that this field was not set, or was not defined in the schema.

func (*UserMutation) FieldCleared

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

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

func (*UserMutation) Fields

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

Fields returns all fields that were changed during this mutation. Note that in order to get all numeric fields that were incremented/decremented, call AddedFields().

func (*UserMutation) ID

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

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

func (*UserMutation) Name

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

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

func (*UserMutation) OldCreateTime

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

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

func (*UserMutation) OldEmail

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

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

func (*UserMutation) OldField

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

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

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

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

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

func (*UserMutation) OldRole

func (m *UserMutation) OldRole(ctx context.Context) (v user.Role, err error)

OldRole returns the old "role" 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) OldUpdateTime

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

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

func (*UserMutation) Op

func (m *UserMutation) Op() Op

Op returns the operation name.

func (*UserMutation) Password

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

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

func (*UserMutation) RemoveDepartmentIDs

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

RemoveDepartmentIDs removes the "departments" edge to the Department entity by IDs.

func (*UserMutation) RemovedDepartmentsIDs

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

RemovedDepartments returns the removed IDs of the "departments" edge to the Department entity.

func (*UserMutation) RemovedEdges

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

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

func (*UserMutation) RemovedIDs

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

RemovedIDs returns all IDs (to other nodes) that were removed for the edge with the given name in this mutation.

func (*UserMutation) ResetCreateTime

func (m *UserMutation) ResetCreateTime()

ResetCreateTime resets all changes to the "create_time" field.

func (*UserMutation) ResetDepartments

func (m *UserMutation) ResetDepartments()

ResetDepartments resets all changes to the "departments" edge.

func (*UserMutation) ResetEdge

func (m *UserMutation) ResetEdge(name string) error

ResetEdge resets all changes to the edge with the given name in this mutation. It returns an error if the edge is not defined in the schema.

func (*UserMutation) ResetEmail

func (m *UserMutation) ResetEmail()

ResetEmail resets all changes to the "email" field.

func (*UserMutation) ResetField

func (m *UserMutation) ResetField(name string) error

ResetField resets all changes in the mutation for the field with the given name. It returns an error if the field is not defined in the schema.

func (*UserMutation) ResetName

func (m *UserMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*UserMutation) ResetPassword

func (m *UserMutation) ResetPassword()

ResetPassword resets all changes to the "password" field.

func (*UserMutation) ResetRole

func (m *UserMutation) ResetRole()

ResetRole resets all changes to the "role" field.

func (*UserMutation) ResetUpdateTime

func (m *UserMutation) ResetUpdateTime()

ResetUpdateTime resets all changes to the "update_time" field.

func (*UserMutation) Role

func (m *UserMutation) Role() (r user.Role, exists bool)

Role returns the value of the "role" field in the mutation.

func (*UserMutation) SetCreateTime

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

SetCreateTime sets the "create_time" field.

func (*UserMutation) SetEmail

func (m *UserMutation) SetEmail(s string)

SetEmail sets the "email" field.

func (*UserMutation) SetField

func (m *UserMutation) SetField(name string, value ent.Value) error

SetField sets the value of a field with the given name. It returns an error if the field is not defined in the schema, or if the type mismatched the field type.

func (*UserMutation) SetName

func (m *UserMutation) SetName(s string)

SetName sets the "name" field.

func (*UserMutation) SetPassword

func (m *UserMutation) SetPassword(s string)

SetPassword sets the "password" field.

func (*UserMutation) SetRole

func (m *UserMutation) SetRole(u user.Role)

SetRole sets the "role" field.

func (*UserMutation) SetUpdateTime

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

SetUpdateTime sets the "update_time" 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) UpdateTime

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

UpdateTime returns the value of the "update_time" field in the mutation.

type UserOrder

type UserOrder struct {
	Direction OrderDirection  `json:"direction"`
	Field     *UserOrderField `json:"field"`
}

UserOrder defines the ordering of User.

type UserOrderField

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

UserOrderField defines the ordering field of User.

func (UserOrderField) MarshalGQL

func (f UserOrderField) MarshalGQL(w io.Writer)

MarshalGQL implements graphql.Marshaler interface.

func (UserOrderField) String

func (f UserOrderField) String() string

String implement fmt.Stringer interface.

func (*UserOrderField) UnmarshalGQL

func (f *UserOrderField) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements graphql.Unmarshaler interface.

type UserPaginateOption

type UserPaginateOption func(*userPager) error

UserPaginateOption enables pagination customization.

func WithUserFilter

func WithUserFilter(filter func(*UserQuery) (*UserQuery, error)) UserPaginateOption

WithUserFilter configures pagination filter.

func WithUserOrder

func WithUserOrder(order *UserOrder) UserPaginateOption

WithUserOrder configures pagination ordering.

type UserQuery

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

UserQuery is the builder for querying User entities.

func (*UserQuery) All

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

All executes the query and returns a list of Users.

func (*UserQuery) AllX

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

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

func (*UserQuery) Clone

func (uq *UserQuery) Clone() *UserQuery

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

func (*UserQuery) CollectFields

func (u *UserQuery) CollectFields(ctx context.Context, satisfies ...string) *UserQuery

CollectFields tells the query-builder to eagerly load connected nodes by resolver context.

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

client.User.Query().
	GroupBy(user.FieldCreateTime).
	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 exactly one User entity is not 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 exactly one User ID is not 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) Paginate

func (u *UserQuery) Paginate(
	ctx context.Context, after *Cursor, first *int,
	before *Cursor, last *int, opts ...UserPaginateOption,
) (*UserConnection, error)

Paginate executes the query and returns a relay based cursor connection to User.

func (*UserQuery) QueryDepartments

func (uq *UserQuery) QueryDepartments() *DepartmentQuery

QueryDepartments chains the current query on the "departments" edge.

func (*UserQuery) Select

func (uq *UserQuery) Select(field string, 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 {
	CreateTime time.Time `json:"create_time,omitempty"`
}

client.User.Query().
	Select(user.FieldCreateTime).
	Scan(ctx, &v)

func (*UserQuery) Where

func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery

Where adds a new predicate for the UserQuery builder.

func (*UserQuery) WithDepartments

func (uq *UserQuery) WithDepartments(opts ...func(*DepartmentQuery)) *UserQuery

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

type UserSelect

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

UserSelect is the builder for selecting fields of User entities.

func (*UserSelect) Bool

func (us *UserSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*UserSelect) BoolX

func (us *UserSelect) BoolX(ctx context.Context) bool

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

func (*UserSelect) Bools

func (us *UserSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*UserSelect) BoolsX

func (us *UserSelect) BoolsX(ctx context.Context) []bool

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

func (*UserSelect) Float64

func (us *UserSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*UserSelect) Float64X

func (us *UserSelect) Float64X(ctx context.Context) float64

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

func (*UserSelect) Float64s

func (us *UserSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*UserSelect) Float64sX

func (us *UserSelect) Float64sX(ctx context.Context) []float64

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

func (*UserSelect) Int

func (us *UserSelect) Int(ctx context.Context) (_ int, err error)

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

func (*UserSelect) IntX

func (us *UserSelect) IntX(ctx context.Context) int

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

func (*UserSelect) Ints

func (us *UserSelect) Ints(ctx context.Context) ([]int, error)

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

func (*UserSelect) IntsX

func (us *UserSelect) IntsX(ctx context.Context) []int

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

func (*UserSelect) Scan

func (us *UserSelect) Scan(ctx context.Context, v interface{}) error

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

func (*UserSelect) ScanX

func (us *UserSelect) ScanX(ctx context.Context, v interface{})

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

func (*UserSelect) String

func (us *UserSelect) String(ctx context.Context) (_ string, err error)

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

func (*UserSelect) StringX

func (us *UserSelect) StringX(ctx context.Context) string

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

func (*UserSelect) Strings

func (us *UserSelect) Strings(ctx context.Context) ([]string, error)

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

func (*UserSelect) StringsX

func (us *UserSelect) StringsX(ctx context.Context) []string

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

type UserUpdate

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

UserUpdate is the builder for updating User entities.

func (*UserUpdate) AddDepartmentIDs

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

AddDepartmentIDs adds the "departments" edge to the Department entity by IDs.

func (*UserUpdate) AddDepartments

func (uu *UserUpdate) AddDepartments(d ...*Department) *UserUpdate

AddDepartments adds the "departments" edges to the Department entity.

func (*UserUpdate) ClearDepartments

func (uu *UserUpdate) ClearDepartments() *UserUpdate

ClearDepartments clears all "departments" edges to the Department 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) RemoveDepartmentIDs

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

RemoveDepartmentIDs removes the "departments" edge to Department entities by IDs.

func (*UserUpdate) RemoveDepartments

func (uu *UserUpdate) RemoveDepartments(d ...*Department) *UserUpdate

RemoveDepartments removes "departments" edges to Department entities.

func (*UserUpdate) Save

func (uu *UserUpdate) Save(ctx context.Context) (int, error)

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

func (*UserUpdate) SaveX

func (uu *UserUpdate) SaveX(ctx context.Context) int

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

func (*UserUpdate) SetEmail

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

SetEmail sets the "email" field.

func (*UserUpdate) SetName

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

SetName sets the "name" field.

func (*UserUpdate) SetPassword

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

SetPassword sets the "password" field.

func (*UserUpdate) SetRole

func (uu *UserUpdate) SetRole(u user.Role) *UserUpdate

SetRole sets the "role" field.

func (*UserUpdate) Where

func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate

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

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

AddDepartmentIDs adds the "departments" edge to the Department entity by IDs.

func (*UserUpdateOne) AddDepartments

func (uuo *UserUpdateOne) AddDepartments(d ...*Department) *UserUpdateOne

AddDepartments adds the "departments" edges to the Department entity.

func (*UserUpdateOne) ClearDepartments

func (uuo *UserUpdateOne) ClearDepartments() *UserUpdateOne

ClearDepartments clears all "departments" edges to the Department 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) RemoveDepartmentIDs

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

RemoveDepartmentIDs removes the "departments" edge to Department entities by IDs.

func (*UserUpdateOne) RemoveDepartments

func (uuo *UserUpdateOne) RemoveDepartments(d ...*Department) *UserUpdateOne

RemoveDepartments removes "departments" edges to Department 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) SetEmail

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

SetEmail sets the "email" field.

func (*UserUpdateOne) SetName

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

SetName sets the "name" field.

func (*UserUpdateOne) SetPassword

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

SetPassword sets the "password" field.

func (*UserUpdateOne) SetRole

func (uuo *UserUpdateOne) SetRole(u user.Role) *UserUpdateOne

SetRole sets the "role" field.

type Users

type Users []*User

Users is a parsable slice of User.

type ValidationError

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

ValidationError returns when validating a field 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