ent

package
v0.0.0-...-daab22b Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks nor found error.

func NewContext

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

NewContext returns a new context with the given Client attached.

Types

type Aggregate

type Aggregate func(*sql.Selector) string

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

func As

func As(fn Aggregate, end string) Aggregate

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() Aggregate

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

func Max

func Max(field string) Aggregate

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

func Mean

func Mean(field string) Aggregate

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

func Min

func Min(field string) Aggregate

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

func Sum

func Sum(field string) Aggregate

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

type Argument

type Argument 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"`
	// TypeKind holds the value of the "type_kind" field.
	TypeKind string `json:"type_kind,omitempty"`
	// TypeName holds the value of the "type_name" field.
	TypeName string `json:"type_name,omitempty"`
	// contains filtered or unexported fields
}

Argument is the model entity for the Argument schema.

Example
if dsn == "" {
	return
}
ctx := context.Background()
drv, err := sql.Open("mysql", dsn)
if err != nil {
	log.Fatalf("failed creating database client: %v", err)
}
defer drv.Close()
client := NewClient(Driver(drv))
// creating vertices for the argument's edges.

// create argument vertex with its edges.
a := client.Argument.
	Create().
	SetName("string").
	SetDescription("string").
	SetTypeKind("string").
	SetTypeName("string").
	SaveX(ctx)
log.Println("argument created:", a)

// query edges.
Output:

func (*Argument) String

func (a *Argument) String() string

String implements the fmt.Stringer.

func (*Argument) Unwrap

func (a *Argument) Unwrap() *Argument

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

func (*Argument) Update

func (a *Argument) Update() *ArgumentUpdateOne

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

type ArgumentClient

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

ArgumentClient is a client for the Argument schema.

func NewArgumentClient

func NewArgumentClient(c config) *ArgumentClient

NewArgumentClient returns a client for the Argument from the given config.

func (*ArgumentClient) Create

func (c *ArgumentClient) Create() *ArgumentCreate

Create returns a create builder for Argument.

func (*ArgumentClient) Delete

func (c *ArgumentClient) Delete() *ArgumentDelete

Delete returns a delete builder for Argument.

func (*ArgumentClient) DeleteOne

func (c *ArgumentClient) DeleteOne(a *Argument) *ArgumentDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*ArgumentClient) DeleteOneID

func (c *ArgumentClient) DeleteOneID(id int) *ArgumentDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*ArgumentClient) Get

func (c *ArgumentClient) Get(ctx context.Context, id int) (*Argument, error)

Get returns a Argument entity by its id.

func (*ArgumentClient) GetX

func (c *ArgumentClient) GetX(ctx context.Context, id int) *Argument

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

func (*ArgumentClient) Query

func (c *ArgumentClient) Query() *ArgumentQuery

Create returns a query builder for Argument.

func (*ArgumentClient) Update

func (c *ArgumentClient) Update() *ArgumentUpdate

Update returns an update builder for Argument.

func (*ArgumentClient) UpdateOne

func (c *ArgumentClient) UpdateOne(a *Argument) *ArgumentUpdateOne

UpdateOne returns an update builder for the given entity.

func (*ArgumentClient) UpdateOneID

func (c *ArgumentClient) UpdateOneID(id int) *ArgumentUpdateOne

UpdateOneID returns an update builder for the given id.

type ArgumentCreate

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

ArgumentCreate is the builder for creating a Argument entity.

func (*ArgumentCreate) Save

func (ac *ArgumentCreate) Save(ctx context.Context) (*Argument, error)

Save creates the Argument in the database.

func (*ArgumentCreate) SaveX

func (ac *ArgumentCreate) SaveX(ctx context.Context) *Argument

SaveX calls Save and panics if Save returns an error.

func (*ArgumentCreate) SetDescription

func (ac *ArgumentCreate) SetDescription(s string) *ArgumentCreate

SetDescription sets the description field.

func (*ArgumentCreate) SetName

func (ac *ArgumentCreate) SetName(s string) *ArgumentCreate

SetName sets the name field.

func (*ArgumentCreate) SetTypeKind

func (ac *ArgumentCreate) SetTypeKind(s string) *ArgumentCreate

SetTypeKind sets the type_kind field.

func (*ArgumentCreate) SetTypeName

func (ac *ArgumentCreate) SetTypeName(s string) *ArgumentCreate

SetTypeName sets the type_name field.

type ArgumentDelete

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

ArgumentDelete is the builder for deleting a Argument entity.

func (*ArgumentDelete) Exec

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

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

func (*ArgumentDelete) ExecX

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

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

func (*ArgumentDelete) Where

func (ad *ArgumentDelete) Where(ps ...predicate.Argument) *ArgumentDelete

Where adds a new predicate to the delete builder.

type ArgumentDeleteOne

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

ArgumentDeleteOne is the builder for deleting a single Argument entity.

func (*ArgumentDeleteOne) Exec

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

Exec executes the deletion query.

func (*ArgumentDeleteOne) ExecX

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

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

type ArgumentGroupBy

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

ArgumentGroupBy is the builder for group-by Argument entities.

func (*ArgumentGroupBy) Aggregate

func (agb *ArgumentGroupBy) Aggregate(fns ...Aggregate) *ArgumentGroupBy

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

func (*ArgumentGroupBy) Bools

func (agb *ArgumentGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*ArgumentGroupBy) BoolsX

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

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

func (*ArgumentGroupBy) Float64s

func (agb *ArgumentGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*ArgumentGroupBy) Float64sX

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

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

func (*ArgumentGroupBy) Ints

func (agb *ArgumentGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*ArgumentGroupBy) IntsX

func (agb *ArgumentGroupBy) IntsX(ctx context.Context) []int

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

func (*ArgumentGroupBy) Scan

func (agb *ArgumentGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*ArgumentGroupBy) ScanX

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

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

func (*ArgumentGroupBy) Strings

func (agb *ArgumentGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*ArgumentGroupBy) StringsX

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

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

type ArgumentQuery

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

ArgumentQuery is the builder for querying Argument entities.

func (*ArgumentQuery) All

func (aq *ArgumentQuery) All(ctx context.Context) ([]*Argument, error)

All executes the query and returns a list of Arguments.

func (*ArgumentQuery) AllX

func (aq *ArgumentQuery) AllX(ctx context.Context) []*Argument

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

func (*ArgumentQuery) Clone

func (aq *ArgumentQuery) Clone() *ArgumentQuery

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

func (*ArgumentQuery) Count

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

Count returns the count of the given query.

func (*ArgumentQuery) CountX

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

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

func (*ArgumentQuery) Exist

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

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

func (*ArgumentQuery) ExistX

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

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

func (*ArgumentQuery) First

func (aq *ArgumentQuery) First(ctx context.Context) (*Argument, error)

First returns the first Argument entity in the query. Returns *NotFoundError when no argument was found.

func (*ArgumentQuery) FirstID

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

FirstID returns the first Argument id in the query. Returns *NotFoundError when no id was found.

func (*ArgumentQuery) FirstX

func (aq *ArgumentQuery) FirstX(ctx context.Context) *Argument

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

func (*ArgumentQuery) FirstXID

func (aq *ArgumentQuery) FirstXID(ctx context.Context) int

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

func (*ArgumentQuery) GroupBy

func (aq *ArgumentQuery) GroupBy(field string, fields ...string) *ArgumentGroupBy

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

func (*ArgumentQuery) IDs

func (aq *ArgumentQuery) IDs(ctx context.Context) ([]int, error)

IDs executes the query and returns a list of Argument ids.

func (*ArgumentQuery) IDsX

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

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

func (*ArgumentQuery) Limit

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

Limit adds a limit step to the query.

func (*ArgumentQuery) Offset

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

Offset adds an offset step to the query.

func (*ArgumentQuery) Only

func (aq *ArgumentQuery) Only(ctx context.Context) (*Argument, error)

Only returns the only Argument entity in the query, returns an error if not exactly one entity was returned.

func (*ArgumentQuery) OnlyID

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

OnlyID returns the only Argument id in the query, returns an error if not exactly one id was returned.

func (*ArgumentQuery) OnlyX

func (aq *ArgumentQuery) OnlyX(ctx context.Context) *Argument

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

func (*ArgumentQuery) OnlyXID

func (aq *ArgumentQuery) OnlyXID(ctx context.Context) int

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

func (*ArgumentQuery) Order

func (aq *ArgumentQuery) Order(o ...Order) *ArgumentQuery

Order adds an order step to the query.

func (*ArgumentQuery) Select

func (aq *ArgumentQuery) Select(field string, fields ...string) *ArgumentSelect

Select one or more fields from the given query.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
}

client.Argument.Query().
	Select(argument.FieldName).
	Scan(ctx, &v)

func (*ArgumentQuery) Where

func (aq *ArgumentQuery) Where(ps ...predicate.Argument) *ArgumentQuery

Where adds a new predicate for the builder.

type ArgumentSelect

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

ArgumentSelect is the builder for select fields of Argument entities.

func (*ArgumentSelect) Bools

func (as *ArgumentSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*ArgumentSelect) BoolsX

func (as *ArgumentSelect) BoolsX(ctx context.Context) []bool

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

func (*ArgumentSelect) Float64s

func (as *ArgumentSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*ArgumentSelect) Float64sX

func (as *ArgumentSelect) Float64sX(ctx context.Context) []float64

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

func (*ArgumentSelect) Ints

func (as *ArgumentSelect) Ints(ctx context.Context) ([]int, error)

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

func (*ArgumentSelect) IntsX

func (as *ArgumentSelect) IntsX(ctx context.Context) []int

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

func (*ArgumentSelect) Scan

func (as *ArgumentSelect) Scan(ctx context.Context, v interface{}) error

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

func (*ArgumentSelect) ScanX

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

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

func (*ArgumentSelect) Strings

func (as *ArgumentSelect) Strings(ctx context.Context) ([]string, error)

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

func (*ArgumentSelect) StringsX

func (as *ArgumentSelect) StringsX(ctx context.Context) []string

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

type ArgumentUpdate

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

ArgumentUpdate is the builder for updating Argument entities.

func (*ArgumentUpdate) Exec

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

Exec executes the query.

func (*ArgumentUpdate) ExecX

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

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

func (*ArgumentUpdate) Save

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

Save executes the query and returns the number of rows/vertices matched by this operation.

func (*ArgumentUpdate) SaveX

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

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

func (*ArgumentUpdate) SetDescription

func (au *ArgumentUpdate) SetDescription(s string) *ArgumentUpdate

SetDescription sets the description field.

func (*ArgumentUpdate) SetName

func (au *ArgumentUpdate) SetName(s string) *ArgumentUpdate

SetName sets the name field.

func (*ArgumentUpdate) SetTypeKind

func (au *ArgumentUpdate) SetTypeKind(s string) *ArgumentUpdate

SetTypeKind sets the type_kind field.

func (*ArgumentUpdate) SetTypeName

func (au *ArgumentUpdate) SetTypeName(s string) *ArgumentUpdate

SetTypeName sets the type_name field.

func (*ArgumentUpdate) Where

func (au *ArgumentUpdate) Where(ps ...predicate.Argument) *ArgumentUpdate

Where adds a new predicate for the builder.

type ArgumentUpdateOne

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

ArgumentUpdateOne is the builder for updating a single Argument entity.

func (*ArgumentUpdateOne) Exec

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

Exec executes the query on the entity.

func (*ArgumentUpdateOne) ExecX

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

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

func (*ArgumentUpdateOne) Save

func (auo *ArgumentUpdateOne) Save(ctx context.Context) (*Argument, error)

Save executes the query and returns the updated entity.

func (*ArgumentUpdateOne) SaveX

func (auo *ArgumentUpdateOne) SaveX(ctx context.Context) *Argument

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

func (*ArgumentUpdateOne) SetDescription

func (auo *ArgumentUpdateOne) SetDescription(s string) *ArgumentUpdateOne

SetDescription sets the description field.

func (*ArgumentUpdateOne) SetName

func (auo *ArgumentUpdateOne) SetName(s string) *ArgumentUpdateOne

SetName sets the name field.

func (*ArgumentUpdateOne) SetTypeKind

func (auo *ArgumentUpdateOne) SetTypeKind(s string) *ArgumentUpdateOne

SetTypeKind sets the type_kind field.

func (*ArgumentUpdateOne) SetTypeName

func (auo *ArgumentUpdateOne) SetTypeName(s string) *ArgumentUpdateOne

SetTypeName sets the type_name field.

type Arguments

type Arguments []*Argument

Arguments is a parsable slice of Argument.

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Argument is the client for interacting with the Argument builders.
	Argument *ArgumentClient
	// FieldType is the client for interacting with the FieldType builders.
	FieldType *FieldTypeClient
	// ObjectType is the client for interacting with the ObjectType builders.
	ObjectType *ObjectTypeClient
	// contains filtered or unexported fields
}

Client is the client that holds all ent builders.

func FromContext

func FromContext(ctx context.Context) *Client

FromContext returns the Client stored in 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 connection to the database specified by the driver name and a driver-specific data source name, and returns a new client attached to it. Optional parameters can be added for configuring the client.

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

func (*Client) Tx

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

Tx returns a new transactional client.

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 FieldType

type FieldType 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"`
	// DeprecatedReason holds the value of the "deprecated_reason" field.
	DeprecatedReason string `json:"deprecated_reason,omitempty"`
	// TypeKind holds the value of the "type_kind" field.
	TypeKind string `json:"type_kind,omitempty"`
	// TypeName holds the value of the "type_name" field.
	TypeName string `json:"type_name,omitempty"`
	// Edges holds the relations/edges for other nodes in the graph.
	// The values are being populated by the FieldTypeQuery when eager-loading is set.
	Edges FieldTypeEdges `json:"edges"`
	// contains filtered or unexported fields
}

FieldType is the model entity for the FieldType schema.

Example
if dsn == "" {
	return
}
ctx := context.Background()
drv, err := sql.Open("mysql", dsn)
if err != nil {
	log.Fatalf("failed creating database client: %v", err)
}
defer drv.Close()
client := NewClient(Driver(drv))
// creating vertices for the fieldtype's edges.
a0 := client.Argument.
	Create().
	SetName("string").
	SetDescription("string").
	SetTypeKind("string").
	SetTypeName("string").
	SaveX(ctx)
log.Println("argument created:", a0)

// create fieldtype vertex with its edges.
ft := client.FieldType.
	Create().
	SetName("string").
	SetDescription("string").
	SetDeprecatedReason("string").
	SetTypeKind("string").
	SetTypeName("string").
	AddArguments(a0).
	SaveX(ctx)
log.Println("fieldtype created:", ft)

// query edges.
a0, err = ft.QueryArguments().First(ctx)
if err != nil {
	log.Fatalf("failed querying arguments: %v", err)
}
log.Println("arguments found:", a0)
Output:

func (*FieldType) QueryArguments

func (ft *FieldType) QueryArguments() *ArgumentQuery

QueryArguments queries the arguments edge of the FieldType.

func (*FieldType) String

func (ft *FieldType) String() string

String implements the fmt.Stringer.

func (*FieldType) Unwrap

func (ft *FieldType) Unwrap() *FieldType

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

func (*FieldType) Update

func (ft *FieldType) Update() *FieldTypeUpdateOne

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

type FieldTypeClient

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

FieldTypeClient is a client for the FieldType schema.

func NewFieldTypeClient

func NewFieldTypeClient(c config) *FieldTypeClient

NewFieldTypeClient returns a client for the FieldType from the given config.

func (*FieldTypeClient) Create

func (c *FieldTypeClient) Create() *FieldTypeCreate

Create returns a create builder for FieldType.

func (*FieldTypeClient) Delete

func (c *FieldTypeClient) Delete() *FieldTypeDelete

Delete returns a delete builder for FieldType.

func (*FieldTypeClient) DeleteOne

func (c *FieldTypeClient) DeleteOne(ft *FieldType) *FieldTypeDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*FieldTypeClient) DeleteOneID

func (c *FieldTypeClient) DeleteOneID(id int) *FieldTypeDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*FieldTypeClient) Get

func (c *FieldTypeClient) Get(ctx context.Context, id int) (*FieldType, error)

Get returns a FieldType entity by its id.

func (*FieldTypeClient) GetX

func (c *FieldTypeClient) GetX(ctx context.Context, id int) *FieldType

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

func (*FieldTypeClient) Query

func (c *FieldTypeClient) Query() *FieldTypeQuery

Create returns a query builder for FieldType.

func (*FieldTypeClient) QueryArguments

func (c *FieldTypeClient) QueryArguments(ft *FieldType) *ArgumentQuery

QueryArguments queries the arguments edge of a FieldType.

func (*FieldTypeClient) Update

func (c *FieldTypeClient) Update() *FieldTypeUpdate

Update returns an update builder for FieldType.

func (*FieldTypeClient) UpdateOne

func (c *FieldTypeClient) UpdateOne(ft *FieldType) *FieldTypeUpdateOne

UpdateOne returns an update builder for the given entity.

func (*FieldTypeClient) UpdateOneID

func (c *FieldTypeClient) UpdateOneID(id int) *FieldTypeUpdateOne

UpdateOneID returns an update builder for the given id.

type FieldTypeCreate

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

FieldTypeCreate is the builder for creating a FieldType entity.

func (*FieldTypeCreate) AddArgumentIDs

func (ftc *FieldTypeCreate) AddArgumentIDs(ids ...int) *FieldTypeCreate

AddArgumentIDs adds the arguments edge to Argument by ids.

func (*FieldTypeCreate) AddArguments

func (ftc *FieldTypeCreate) AddArguments(a ...*Argument) *FieldTypeCreate

AddArguments adds the arguments edges to Argument.

func (*FieldTypeCreate) Save

func (ftc *FieldTypeCreate) Save(ctx context.Context) (*FieldType, error)

Save creates the FieldType in the database.

func (*FieldTypeCreate) SaveX

func (ftc *FieldTypeCreate) SaveX(ctx context.Context) *FieldType

SaveX calls Save and panics if Save returns an error.

func (*FieldTypeCreate) SetDeprecatedReason

func (ftc *FieldTypeCreate) SetDeprecatedReason(s string) *FieldTypeCreate

SetDeprecatedReason sets the deprecated_reason field.

func (*FieldTypeCreate) SetDescription

func (ftc *FieldTypeCreate) SetDescription(s string) *FieldTypeCreate

SetDescription sets the description field.

func (*FieldTypeCreate) SetName

func (ftc *FieldTypeCreate) SetName(s string) *FieldTypeCreate

SetName sets the name field.

func (*FieldTypeCreate) SetTypeKind

func (ftc *FieldTypeCreate) SetTypeKind(s string) *FieldTypeCreate

SetTypeKind sets the type_kind field.

func (*FieldTypeCreate) SetTypeName

func (ftc *FieldTypeCreate) SetTypeName(s string) *FieldTypeCreate

SetTypeName sets the type_name field.

type FieldTypeDelete

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

FieldTypeDelete is the builder for deleting a FieldType entity.

func (*FieldTypeDelete) Exec

func (ftd *FieldTypeDelete) Exec(ctx context.Context) (int, error)

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

func (*FieldTypeDelete) ExecX

func (ftd *FieldTypeDelete) ExecX(ctx context.Context) int

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

func (*FieldTypeDelete) Where

Where adds a new predicate to the delete builder.

type FieldTypeDeleteOne

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

FieldTypeDeleteOne is the builder for deleting a single FieldType entity.

func (*FieldTypeDeleteOne) Exec

func (ftdo *FieldTypeDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*FieldTypeDeleteOne) ExecX

func (ftdo *FieldTypeDeleteOne) ExecX(ctx context.Context)

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

type FieldTypeEdges

type FieldTypeEdges struct {
	// Arguments holds the value of the arguments edge.
	Arguments []*Argument
	// contains filtered or unexported fields
}

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

func (FieldTypeEdges) ArgumentsOrErr

func (e FieldTypeEdges) ArgumentsOrErr() ([]*Argument, error)

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

type FieldTypeGroupBy

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

FieldTypeGroupBy is the builder for group-by FieldType entities.

func (*FieldTypeGroupBy) Aggregate

func (ftgb *FieldTypeGroupBy) Aggregate(fns ...Aggregate) *FieldTypeGroupBy

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

func (*FieldTypeGroupBy) Bools

func (ftgb *FieldTypeGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*FieldTypeGroupBy) BoolsX

func (ftgb *FieldTypeGroupBy) BoolsX(ctx context.Context) []bool

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

func (*FieldTypeGroupBy) Float64s

func (ftgb *FieldTypeGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*FieldTypeGroupBy) Float64sX

func (ftgb *FieldTypeGroupBy) Float64sX(ctx context.Context) []float64

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

func (*FieldTypeGroupBy) Ints

func (ftgb *FieldTypeGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*FieldTypeGroupBy) IntsX

func (ftgb *FieldTypeGroupBy) IntsX(ctx context.Context) []int

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

func (*FieldTypeGroupBy) Scan

func (ftgb *FieldTypeGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*FieldTypeGroupBy) ScanX

func (ftgb *FieldTypeGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*FieldTypeGroupBy) Strings

func (ftgb *FieldTypeGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*FieldTypeGroupBy) StringsX

func (ftgb *FieldTypeGroupBy) StringsX(ctx context.Context) []string

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

type FieldTypeQuery

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

FieldTypeQuery is the builder for querying FieldType entities.

func (*FieldTypeQuery) All

func (ftq *FieldTypeQuery) All(ctx context.Context) ([]*FieldType, error)

All executes the query and returns a list of FieldTypes.

func (*FieldTypeQuery) AllX

func (ftq *FieldTypeQuery) AllX(ctx context.Context) []*FieldType

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

func (*FieldTypeQuery) Clone

func (ftq *FieldTypeQuery) Clone() *FieldTypeQuery

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

func (*FieldTypeQuery) Count

func (ftq *FieldTypeQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*FieldTypeQuery) CountX

func (ftq *FieldTypeQuery) CountX(ctx context.Context) int

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

func (*FieldTypeQuery) Exist

func (ftq *FieldTypeQuery) Exist(ctx context.Context) (bool, error)

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

func (*FieldTypeQuery) ExistX

func (ftq *FieldTypeQuery) ExistX(ctx context.Context) bool

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

func (*FieldTypeQuery) First

func (ftq *FieldTypeQuery) First(ctx context.Context) (*FieldType, error)

First returns the first FieldType entity in the query. Returns *NotFoundError when no fieldtype was found.

func (*FieldTypeQuery) FirstID

func (ftq *FieldTypeQuery) FirstID(ctx context.Context) (id int, err error)

FirstID returns the first FieldType id in the query. Returns *NotFoundError when no id was found.

func (*FieldTypeQuery) FirstX

func (ftq *FieldTypeQuery) FirstX(ctx context.Context) *FieldType

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

func (*FieldTypeQuery) FirstXID

func (ftq *FieldTypeQuery) FirstXID(ctx context.Context) int

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

func (*FieldTypeQuery) GroupBy

func (ftq *FieldTypeQuery) GroupBy(field string, fields ...string) *FieldTypeGroupBy

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

func (*FieldTypeQuery) IDs

func (ftq *FieldTypeQuery) IDs(ctx context.Context) ([]int, error)

IDs executes the query and returns a list of FieldType ids.

func (*FieldTypeQuery) IDsX

func (ftq *FieldTypeQuery) IDsX(ctx context.Context) []int

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

func (*FieldTypeQuery) Limit

func (ftq *FieldTypeQuery) Limit(limit int) *FieldTypeQuery

Limit adds a limit step to the query.

func (*FieldTypeQuery) Offset

func (ftq *FieldTypeQuery) Offset(offset int) *FieldTypeQuery

Offset adds an offset step to the query.

func (*FieldTypeQuery) Only

func (ftq *FieldTypeQuery) Only(ctx context.Context) (*FieldType, error)

Only returns the only FieldType entity in the query, returns an error if not exactly one entity was returned.

func (*FieldTypeQuery) OnlyID

func (ftq *FieldTypeQuery) OnlyID(ctx context.Context) (id int, err error)

OnlyID returns the only FieldType id in the query, returns an error if not exactly one id was returned.

func (*FieldTypeQuery) OnlyX

func (ftq *FieldTypeQuery) OnlyX(ctx context.Context) *FieldType

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

func (*FieldTypeQuery) OnlyXID

func (ftq *FieldTypeQuery) OnlyXID(ctx context.Context) int

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

func (*FieldTypeQuery) Order

func (ftq *FieldTypeQuery) Order(o ...Order) *FieldTypeQuery

Order adds an order step to the query.

func (*FieldTypeQuery) QueryArguments

func (ftq *FieldTypeQuery) QueryArguments() *ArgumentQuery

QueryArguments chains the current query on the arguments edge.

func (*FieldTypeQuery) Select

func (ftq *FieldTypeQuery) Select(field string, fields ...string) *FieldTypeSelect

Select one or more fields from the given query.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
}

client.FieldType.Query().
	Select(fieldtype.FieldName).
	Scan(ctx, &v)

func (*FieldTypeQuery) Where

func (ftq *FieldTypeQuery) Where(ps ...predicate.FieldType) *FieldTypeQuery

Where adds a new predicate for the builder.

func (*FieldTypeQuery) WithArguments

func (ftq *FieldTypeQuery) WithArguments(opts ...func(*ArgumentQuery)) *FieldTypeQuery
WithArguments tells the query-builder to eager-loads the nodes that are connected to

the "arguments" edge. The optional arguments used to configure the query builder of the edge.

type FieldTypeSelect

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

FieldTypeSelect is the builder for select fields of FieldType entities.

func (*FieldTypeSelect) Bools

func (fts *FieldTypeSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*FieldTypeSelect) BoolsX

func (fts *FieldTypeSelect) BoolsX(ctx context.Context) []bool

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

func (*FieldTypeSelect) Float64s

func (fts *FieldTypeSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*FieldTypeSelect) Float64sX

func (fts *FieldTypeSelect) Float64sX(ctx context.Context) []float64

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

func (*FieldTypeSelect) Ints

func (fts *FieldTypeSelect) Ints(ctx context.Context) ([]int, error)

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

func (*FieldTypeSelect) IntsX

func (fts *FieldTypeSelect) IntsX(ctx context.Context) []int

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

func (*FieldTypeSelect) Scan

func (fts *FieldTypeSelect) Scan(ctx context.Context, v interface{}) error

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

func (*FieldTypeSelect) ScanX

func (fts *FieldTypeSelect) ScanX(ctx context.Context, v interface{})

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

func (*FieldTypeSelect) Strings

func (fts *FieldTypeSelect) Strings(ctx context.Context) ([]string, error)

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

func (*FieldTypeSelect) StringsX

func (fts *FieldTypeSelect) StringsX(ctx context.Context) []string

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

type FieldTypeUpdate

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

FieldTypeUpdate is the builder for updating FieldType entities.

func (*FieldTypeUpdate) AddArgumentIDs

func (ftu *FieldTypeUpdate) AddArgumentIDs(ids ...int) *FieldTypeUpdate

AddArgumentIDs adds the arguments edge to Argument by ids.

func (*FieldTypeUpdate) AddArguments

func (ftu *FieldTypeUpdate) AddArguments(a ...*Argument) *FieldTypeUpdate

AddArguments adds the arguments edges to Argument.

func (*FieldTypeUpdate) Exec

func (ftu *FieldTypeUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*FieldTypeUpdate) ExecX

func (ftu *FieldTypeUpdate) ExecX(ctx context.Context)

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

func (*FieldTypeUpdate) RemoveArgumentIDs

func (ftu *FieldTypeUpdate) RemoveArgumentIDs(ids ...int) *FieldTypeUpdate

RemoveArgumentIDs removes the arguments edge to Argument by ids.

func (*FieldTypeUpdate) RemoveArguments

func (ftu *FieldTypeUpdate) RemoveArguments(a ...*Argument) *FieldTypeUpdate

RemoveArguments removes arguments edges to Argument.

func (*FieldTypeUpdate) Save

func (ftu *FieldTypeUpdate) Save(ctx context.Context) (int, error)

Save executes the query and returns the number of rows/vertices matched by this operation.

func (*FieldTypeUpdate) SaveX

func (ftu *FieldTypeUpdate) SaveX(ctx context.Context) int

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

func (*FieldTypeUpdate) SetDeprecatedReason

func (ftu *FieldTypeUpdate) SetDeprecatedReason(s string) *FieldTypeUpdate

SetDeprecatedReason sets the deprecated_reason field.

func (*FieldTypeUpdate) SetDescription

func (ftu *FieldTypeUpdate) SetDescription(s string) *FieldTypeUpdate

SetDescription sets the description field.

func (*FieldTypeUpdate) SetName

func (ftu *FieldTypeUpdate) SetName(s string) *FieldTypeUpdate

SetName sets the name field.

func (*FieldTypeUpdate) SetTypeKind

func (ftu *FieldTypeUpdate) SetTypeKind(s string) *FieldTypeUpdate

SetTypeKind sets the type_kind field.

func (*FieldTypeUpdate) SetTypeName

func (ftu *FieldTypeUpdate) SetTypeName(s string) *FieldTypeUpdate

SetTypeName sets the type_name field.

func (*FieldTypeUpdate) Where

Where adds a new predicate for the builder.

type FieldTypeUpdateOne

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

FieldTypeUpdateOne is the builder for updating a single FieldType entity.

func (*FieldTypeUpdateOne) AddArgumentIDs

func (ftuo *FieldTypeUpdateOne) AddArgumentIDs(ids ...int) *FieldTypeUpdateOne

AddArgumentIDs adds the arguments edge to Argument by ids.

func (*FieldTypeUpdateOne) AddArguments

func (ftuo *FieldTypeUpdateOne) AddArguments(a ...*Argument) *FieldTypeUpdateOne

AddArguments adds the arguments edges to Argument.

func (*FieldTypeUpdateOne) Exec

func (ftuo *FieldTypeUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*FieldTypeUpdateOne) ExecX

func (ftuo *FieldTypeUpdateOne) ExecX(ctx context.Context)

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

func (*FieldTypeUpdateOne) RemoveArgumentIDs

func (ftuo *FieldTypeUpdateOne) RemoveArgumentIDs(ids ...int) *FieldTypeUpdateOne

RemoveArgumentIDs removes the arguments edge to Argument by ids.

func (*FieldTypeUpdateOne) RemoveArguments

func (ftuo *FieldTypeUpdateOne) RemoveArguments(a ...*Argument) *FieldTypeUpdateOne

RemoveArguments removes arguments edges to Argument.

func (*FieldTypeUpdateOne) Save

func (ftuo *FieldTypeUpdateOne) Save(ctx context.Context) (*FieldType, error)

Save executes the query and returns the updated entity.

func (*FieldTypeUpdateOne) SaveX

func (ftuo *FieldTypeUpdateOne) SaveX(ctx context.Context) *FieldType

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

func (*FieldTypeUpdateOne) SetDeprecatedReason

func (ftuo *FieldTypeUpdateOne) SetDeprecatedReason(s string) *FieldTypeUpdateOne

SetDeprecatedReason sets the deprecated_reason field.

func (*FieldTypeUpdateOne) SetDescription

func (ftuo *FieldTypeUpdateOne) SetDescription(s string) *FieldTypeUpdateOne

SetDescription sets the description field.

func (*FieldTypeUpdateOne) SetName

func (ftuo *FieldTypeUpdateOne) SetName(s string) *FieldTypeUpdateOne

SetName sets the name field.

func (*FieldTypeUpdateOne) SetTypeKind

func (ftuo *FieldTypeUpdateOne) SetTypeKind(s string) *FieldTypeUpdateOne

SetTypeKind sets the type_kind field.

func (*FieldTypeUpdateOne) SetTypeName

func (ftuo *FieldTypeUpdateOne) SetTypeName(s string) *FieldTypeUpdateOne

SetTypeName sets the type_name field.

type FieldTypes

type FieldTypes []*FieldType

FieldTypes is a parsable slice of FieldType.

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 ObjectType

type ObjectType struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// Kind holds the value of the "kind" field.
	Kind string `json:"kind,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 ObjectTypeQuery when eager-loading is set.
	Edges ObjectTypeEdges `json:"edges"`
	// contains filtered or unexported fields
}

ObjectType is the model entity for the ObjectType schema.

Example
if dsn == "" {
	return
}
ctx := context.Background()
drv, err := sql.Open("mysql", dsn)
if err != nil {
	log.Fatalf("failed creating database client: %v", err)
}
defer drv.Close()
client := NewClient(Driver(drv))
// creating vertices for the objecttype's edges.
ft0 := client.FieldType.
	Create().
	SetName("string").
	SetDescription("string").
	SetDeprecatedReason("string").
	SetTypeKind("string").
	SetTypeName("string").
	SaveX(ctx)
log.Println("fieldtype created:", ft0)

// create objecttype vertex with its edges.
ot := client.ObjectType.
	Create().
	SetName("string").
	SetKind("string").
	SetDescription("string").
	AddFields(ft0).
	SaveX(ctx)
log.Println("objecttype created:", ot)

// query edges.
ft0, err = ot.QueryFields().First(ctx)
if err != nil {
	log.Fatalf("failed querying fields: %v", err)
}
log.Println("fields found:", ft0)
Output:

func (*ObjectType) QueryFields

func (ot *ObjectType) QueryFields() *FieldTypeQuery

QueryFields queries the fields edge of the ObjectType.

func (*ObjectType) String

func (ot *ObjectType) String() string

String implements the fmt.Stringer.

func (*ObjectType) Unwrap

func (ot *ObjectType) Unwrap() *ObjectType

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

func (*ObjectType) Update

func (ot *ObjectType) Update() *ObjectTypeUpdateOne

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

type ObjectTypeClient

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

ObjectTypeClient is a client for the ObjectType schema.

func NewObjectTypeClient

func NewObjectTypeClient(c config) *ObjectTypeClient

NewObjectTypeClient returns a client for the ObjectType from the given config.

func (*ObjectTypeClient) Create

func (c *ObjectTypeClient) Create() *ObjectTypeCreate

Create returns a create builder for ObjectType.

func (*ObjectTypeClient) Delete

func (c *ObjectTypeClient) Delete() *ObjectTypeDelete

Delete returns a delete builder for ObjectType.

func (*ObjectTypeClient) DeleteOne

func (c *ObjectTypeClient) DeleteOne(ot *ObjectType) *ObjectTypeDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*ObjectTypeClient) DeleteOneID

func (c *ObjectTypeClient) DeleteOneID(id int) *ObjectTypeDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*ObjectTypeClient) Get

func (c *ObjectTypeClient) Get(ctx context.Context, id int) (*ObjectType, error)

Get returns a ObjectType entity by its id.

func (*ObjectTypeClient) GetX

func (c *ObjectTypeClient) GetX(ctx context.Context, id int) *ObjectType

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

func (*ObjectTypeClient) Query

func (c *ObjectTypeClient) Query() *ObjectTypeQuery

Create returns a query builder for ObjectType.

func (*ObjectTypeClient) QueryFields

func (c *ObjectTypeClient) QueryFields(ot *ObjectType) *FieldTypeQuery

QueryFields queries the fields edge of a ObjectType.

func (*ObjectTypeClient) Update

func (c *ObjectTypeClient) Update() *ObjectTypeUpdate

Update returns an update builder for ObjectType.

func (*ObjectTypeClient) UpdateOne

func (c *ObjectTypeClient) UpdateOne(ot *ObjectType) *ObjectTypeUpdateOne

UpdateOne returns an update builder for the given entity.

func (*ObjectTypeClient) UpdateOneID

func (c *ObjectTypeClient) UpdateOneID(id int) *ObjectTypeUpdateOne

UpdateOneID returns an update builder for the given id.

type ObjectTypeCreate

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

ObjectTypeCreate is the builder for creating a ObjectType entity.

func (*ObjectTypeCreate) AddFieldIDs

func (otc *ObjectTypeCreate) AddFieldIDs(ids ...int) *ObjectTypeCreate

AddFieldIDs adds the fields edge to FieldType by ids.

func (*ObjectTypeCreate) AddFields

func (otc *ObjectTypeCreate) AddFields(f ...*FieldType) *ObjectTypeCreate

AddFields adds the fields edges to FieldType.

func (*ObjectTypeCreate) Save

func (otc *ObjectTypeCreate) Save(ctx context.Context) (*ObjectType, error)

Save creates the ObjectType in the database.

func (*ObjectTypeCreate) SaveX

func (otc *ObjectTypeCreate) SaveX(ctx context.Context) *ObjectType

SaveX calls Save and panics if Save returns an error.

func (*ObjectTypeCreate) SetDescription

func (otc *ObjectTypeCreate) SetDescription(s string) *ObjectTypeCreate

SetDescription sets the description field.

func (*ObjectTypeCreate) SetKind

func (otc *ObjectTypeCreate) SetKind(s string) *ObjectTypeCreate

SetKind sets the kind field.

func (*ObjectTypeCreate) SetName

func (otc *ObjectTypeCreate) SetName(s string) *ObjectTypeCreate

SetName sets the name field.

type ObjectTypeDelete

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

ObjectTypeDelete is the builder for deleting a ObjectType entity.

func (*ObjectTypeDelete) Exec

func (otd *ObjectTypeDelete) Exec(ctx context.Context) (int, error)

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

func (*ObjectTypeDelete) ExecX

func (otd *ObjectTypeDelete) ExecX(ctx context.Context) int

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

func (*ObjectTypeDelete) Where

Where adds a new predicate to the delete builder.

type ObjectTypeDeleteOne

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

ObjectTypeDeleteOne is the builder for deleting a single ObjectType entity.

func (*ObjectTypeDeleteOne) Exec

func (otdo *ObjectTypeDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*ObjectTypeDeleteOne) ExecX

func (otdo *ObjectTypeDeleteOne) ExecX(ctx context.Context)

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

type ObjectTypeEdges

type ObjectTypeEdges struct {
	// Fields holds the value of the fields edge.
	Fields []*FieldType
	// contains filtered or unexported fields
}

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

func (ObjectTypeEdges) FieldsOrErr

func (e ObjectTypeEdges) FieldsOrErr() ([]*FieldType, error)

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

type ObjectTypeGroupBy

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

ObjectTypeGroupBy is the builder for group-by ObjectType entities.

func (*ObjectTypeGroupBy) Aggregate

func (otgb *ObjectTypeGroupBy) Aggregate(fns ...Aggregate) *ObjectTypeGroupBy

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

func (*ObjectTypeGroupBy) Bools

func (otgb *ObjectTypeGroupBy) Bools(ctx context.Context) ([]bool, error)

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

func (*ObjectTypeGroupBy) BoolsX

func (otgb *ObjectTypeGroupBy) BoolsX(ctx context.Context) []bool

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

func (*ObjectTypeGroupBy) Float64s

func (otgb *ObjectTypeGroupBy) Float64s(ctx context.Context) ([]float64, error)

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

func (*ObjectTypeGroupBy) Float64sX

func (otgb *ObjectTypeGroupBy) Float64sX(ctx context.Context) []float64

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

func (*ObjectTypeGroupBy) Ints

func (otgb *ObjectTypeGroupBy) Ints(ctx context.Context) ([]int, error)

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

func (*ObjectTypeGroupBy) IntsX

func (otgb *ObjectTypeGroupBy) IntsX(ctx context.Context) []int

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

func (*ObjectTypeGroupBy) Scan

func (otgb *ObjectTypeGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*ObjectTypeGroupBy) ScanX

func (otgb *ObjectTypeGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*ObjectTypeGroupBy) Strings

func (otgb *ObjectTypeGroupBy) Strings(ctx context.Context) ([]string, error)

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

func (*ObjectTypeGroupBy) StringsX

func (otgb *ObjectTypeGroupBy) StringsX(ctx context.Context) []string

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

type ObjectTypeQuery

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

ObjectTypeQuery is the builder for querying ObjectType entities.

func (*ObjectTypeQuery) All

func (otq *ObjectTypeQuery) All(ctx context.Context) ([]*ObjectType, error)

All executes the query and returns a list of ObjectTypes.

func (*ObjectTypeQuery) AllX

func (otq *ObjectTypeQuery) AllX(ctx context.Context) []*ObjectType

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

func (*ObjectTypeQuery) Clone

func (otq *ObjectTypeQuery) Clone() *ObjectTypeQuery

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

func (*ObjectTypeQuery) Count

func (otq *ObjectTypeQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*ObjectTypeQuery) CountX

func (otq *ObjectTypeQuery) CountX(ctx context.Context) int

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

func (*ObjectTypeQuery) Exist

func (otq *ObjectTypeQuery) Exist(ctx context.Context) (bool, error)

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

func (*ObjectTypeQuery) ExistX

func (otq *ObjectTypeQuery) ExistX(ctx context.Context) bool

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

func (*ObjectTypeQuery) First

func (otq *ObjectTypeQuery) First(ctx context.Context) (*ObjectType, error)

First returns the first ObjectType entity in the query. Returns *NotFoundError when no objecttype was found.

func (*ObjectTypeQuery) FirstID

func (otq *ObjectTypeQuery) FirstID(ctx context.Context) (id int, err error)

FirstID returns the first ObjectType id in the query. Returns *NotFoundError when no id was found.

func (*ObjectTypeQuery) FirstX

func (otq *ObjectTypeQuery) FirstX(ctx context.Context) *ObjectType

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

func (*ObjectTypeQuery) FirstXID

func (otq *ObjectTypeQuery) FirstXID(ctx context.Context) int

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

func (*ObjectTypeQuery) GroupBy

func (otq *ObjectTypeQuery) GroupBy(field string, fields ...string) *ObjectTypeGroupBy

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

func (*ObjectTypeQuery) IDs

func (otq *ObjectTypeQuery) IDs(ctx context.Context) ([]int, error)

IDs executes the query and returns a list of ObjectType ids.

func (*ObjectTypeQuery) IDsX

func (otq *ObjectTypeQuery) IDsX(ctx context.Context) []int

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

func (*ObjectTypeQuery) Limit

func (otq *ObjectTypeQuery) Limit(limit int) *ObjectTypeQuery

Limit adds a limit step to the query.

func (*ObjectTypeQuery) Offset

func (otq *ObjectTypeQuery) Offset(offset int) *ObjectTypeQuery

Offset adds an offset step to the query.

func (*ObjectTypeQuery) Only

func (otq *ObjectTypeQuery) Only(ctx context.Context) (*ObjectType, error)

Only returns the only ObjectType entity in the query, returns an error if not exactly one entity was returned.

func (*ObjectTypeQuery) OnlyID

func (otq *ObjectTypeQuery) OnlyID(ctx context.Context) (id int, err error)

OnlyID returns the only ObjectType id in the query, returns an error if not exactly one id was returned.

func (*ObjectTypeQuery) OnlyX

func (otq *ObjectTypeQuery) OnlyX(ctx context.Context) *ObjectType

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

func (*ObjectTypeQuery) OnlyXID

func (otq *ObjectTypeQuery) OnlyXID(ctx context.Context) int

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

func (*ObjectTypeQuery) Order

func (otq *ObjectTypeQuery) Order(o ...Order) *ObjectTypeQuery

Order adds an order step to the query.

func (*ObjectTypeQuery) QueryFields

func (otq *ObjectTypeQuery) QueryFields() *FieldTypeQuery

QueryFields chains the current query on the fields edge.

func (*ObjectTypeQuery) Select

func (otq *ObjectTypeQuery) Select(field string, fields ...string) *ObjectTypeSelect

Select one or more fields from the given query.

Example:

var v []struct {
	Name string `json:"name,omitempty"`
}

client.ObjectType.Query().
	Select(objecttype.FieldName).
	Scan(ctx, &v)

func (*ObjectTypeQuery) Where

Where adds a new predicate for the builder.

func (*ObjectTypeQuery) WithFields

func (otq *ObjectTypeQuery) WithFields(opts ...func(*FieldTypeQuery)) *ObjectTypeQuery
WithFields tells the query-builder to eager-loads the nodes that are connected to

the "fields" edge. The optional arguments used to configure the query builder of the edge.

type ObjectTypeSelect

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

ObjectTypeSelect is the builder for select fields of ObjectType entities.

func (*ObjectTypeSelect) Bools

func (ots *ObjectTypeSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*ObjectTypeSelect) BoolsX

func (ots *ObjectTypeSelect) BoolsX(ctx context.Context) []bool

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

func (*ObjectTypeSelect) Float64s

func (ots *ObjectTypeSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*ObjectTypeSelect) Float64sX

func (ots *ObjectTypeSelect) Float64sX(ctx context.Context) []float64

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

func (*ObjectTypeSelect) Ints

func (ots *ObjectTypeSelect) Ints(ctx context.Context) ([]int, error)

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

func (*ObjectTypeSelect) IntsX

func (ots *ObjectTypeSelect) IntsX(ctx context.Context) []int

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

func (*ObjectTypeSelect) Scan

func (ots *ObjectTypeSelect) Scan(ctx context.Context, v interface{}) error

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

func (*ObjectTypeSelect) ScanX

func (ots *ObjectTypeSelect) ScanX(ctx context.Context, v interface{})

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

func (*ObjectTypeSelect) Strings

func (ots *ObjectTypeSelect) Strings(ctx context.Context) ([]string, error)

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

func (*ObjectTypeSelect) StringsX

func (ots *ObjectTypeSelect) StringsX(ctx context.Context) []string

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

type ObjectTypeUpdate

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

ObjectTypeUpdate is the builder for updating ObjectType entities.

func (*ObjectTypeUpdate) AddFieldIDs

func (otu *ObjectTypeUpdate) AddFieldIDs(ids ...int) *ObjectTypeUpdate

AddFieldIDs adds the fields edge to FieldType by ids.

func (*ObjectTypeUpdate) AddFields

func (otu *ObjectTypeUpdate) AddFields(f ...*FieldType) *ObjectTypeUpdate

AddFields adds the fields edges to FieldType.

func (*ObjectTypeUpdate) Exec

func (otu *ObjectTypeUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*ObjectTypeUpdate) ExecX

func (otu *ObjectTypeUpdate) ExecX(ctx context.Context)

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

func (*ObjectTypeUpdate) RemoveFieldIDs

func (otu *ObjectTypeUpdate) RemoveFieldIDs(ids ...int) *ObjectTypeUpdate

RemoveFieldIDs removes the fields edge to FieldType by ids.

func (*ObjectTypeUpdate) RemoveFields

func (otu *ObjectTypeUpdate) RemoveFields(f ...*FieldType) *ObjectTypeUpdate

RemoveFields removes fields edges to FieldType.

func (*ObjectTypeUpdate) Save

func (otu *ObjectTypeUpdate) Save(ctx context.Context) (int, error)

Save executes the query and returns the number of rows/vertices matched by this operation.

func (*ObjectTypeUpdate) SaveX

func (otu *ObjectTypeUpdate) SaveX(ctx context.Context) int

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

func (*ObjectTypeUpdate) SetDescription

func (otu *ObjectTypeUpdate) SetDescription(s string) *ObjectTypeUpdate

SetDescription sets the description field.

func (*ObjectTypeUpdate) SetKind

func (otu *ObjectTypeUpdate) SetKind(s string) *ObjectTypeUpdate

SetKind sets the kind field.

func (*ObjectTypeUpdate) SetName

func (otu *ObjectTypeUpdate) SetName(s string) *ObjectTypeUpdate

SetName sets the name field.

func (*ObjectTypeUpdate) Where

Where adds a new predicate for the builder.

type ObjectTypeUpdateOne

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

ObjectTypeUpdateOne is the builder for updating a single ObjectType entity.

func (*ObjectTypeUpdateOne) AddFieldIDs

func (otuo *ObjectTypeUpdateOne) AddFieldIDs(ids ...int) *ObjectTypeUpdateOne

AddFieldIDs adds the fields edge to FieldType by ids.

func (*ObjectTypeUpdateOne) AddFields

func (otuo *ObjectTypeUpdateOne) AddFields(f ...*FieldType) *ObjectTypeUpdateOne

AddFields adds the fields edges to FieldType.

func (*ObjectTypeUpdateOne) Exec

func (otuo *ObjectTypeUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*ObjectTypeUpdateOne) ExecX

func (otuo *ObjectTypeUpdateOne) ExecX(ctx context.Context)

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

func (*ObjectTypeUpdateOne) RemoveFieldIDs

func (otuo *ObjectTypeUpdateOne) RemoveFieldIDs(ids ...int) *ObjectTypeUpdateOne

RemoveFieldIDs removes the fields edge to FieldType by ids.

func (*ObjectTypeUpdateOne) RemoveFields

func (otuo *ObjectTypeUpdateOne) RemoveFields(f ...*FieldType) *ObjectTypeUpdateOne

RemoveFields removes fields edges to FieldType.

func (*ObjectTypeUpdateOne) Save

func (otuo *ObjectTypeUpdateOne) Save(ctx context.Context) (*ObjectType, error)

Save executes the query and returns the updated entity.

func (*ObjectTypeUpdateOne) SaveX

func (otuo *ObjectTypeUpdateOne) SaveX(ctx context.Context) *ObjectType

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

func (*ObjectTypeUpdateOne) SetDescription

func (otuo *ObjectTypeUpdateOne) SetDescription(s string) *ObjectTypeUpdateOne

SetDescription sets the description field.

func (*ObjectTypeUpdateOne) SetKind

SetKind sets the kind field.

func (*ObjectTypeUpdateOne) SetName

SetName sets the name field.

type ObjectTypes

type ObjectTypes []*ObjectType

ObjectTypes is a parsable slice of ObjectType.

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 Order

type Order func(*sql.Selector)

Order applies an ordering on either graph traversal or sql selector.

func Asc

func Asc(fields ...string) Order

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) Order

Desc applies the given fields in DESC order.

type Tx

type Tx struct {

	// Argument is the client for interacting with the Argument builders.
	Argument *ArgumentClient
	// FieldType is the client for interacting with the FieldType builders.
	FieldType *FieldTypeClient
	// ObjectType is the client for interacting with the ObjectType builders.
	ObjectType *ObjectTypeClient
	// contains filtered or unexported fields
}

Tx is a transactional client that is created by calling Client.Tx().

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

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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