ent

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 21 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.
	TypeCategory  = "Category"
	TypeEquipment = "Equipment"
	TypeVehicle   = "Vehicle"
)

Variables

This section is empty.

Functions

func IsConstraintError

func IsConstraintError(err error) bool

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

func IsNotFound

func IsNotFound(err error) bool

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

func IsNotLoaded

func IsNotLoaded(err error) bool

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

func IsNotSingular

func IsNotSingular(err error) bool

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

func IsValidationError

func IsValidationError(err error) bool

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

func MaskNotFound

func MaskNotFound(err error) error

MaskNotFound masks not found error.

func NewContext

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

NewContext returns a new context with the given Client attached.

func NewTxContext

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

NewTxContext returns a new context with the given Tx attached.

func OpenTxFromContext added in v0.3.0

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) 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 Categories added in v0.4.0

type Categories []*Category

Categories is a parsable slice of Category.

type Category added in v0.4.0

type Category struct {

	// ID of the ent.
	ID int `json:"id,omitempty"`
	// Name holds the value of the "name" field.
	Name string `json:"name,omitempty"`
	// contains filtered or unexported fields
}

Category is the model entity for the Category schema.

func (*Category) String added in v0.4.0

func (c *Category) String() string

String implements the fmt.Stringer.

func (*Category) Unwrap added in v0.4.0

func (c *Category) Unwrap() *Category

Unwrap unwraps the Category 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 (*Category) Update added in v0.4.0

func (c *Category) Update() *CategoryUpdateOne

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

type CategoryClient added in v0.4.0

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

CategoryClient is a client for the Category schema.

func NewCategoryClient added in v0.4.0

func NewCategoryClient(c config) *CategoryClient

NewCategoryClient returns a client for the Category from the given config.

func (*CategoryClient) Create added in v0.4.0

func (c *CategoryClient) Create() *CategoryCreate

Create returns a create builder for Category.

func (*CategoryClient) CreateBulk added in v0.4.0

func (c *CategoryClient) CreateBulk(builders ...*CategoryCreate) *CategoryCreateBulk

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

func (*CategoryClient) Delete added in v0.4.0

func (c *CategoryClient) Delete() *CategoryDelete

Delete returns a delete builder for Category.

func (*CategoryClient) DeleteOne added in v0.4.0

func (c *CategoryClient) DeleteOne(ca *Category) *CategoryDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*CategoryClient) DeleteOneID added in v0.4.0

func (c *CategoryClient) DeleteOneID(id int) *CategoryDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*CategoryClient) Get added in v0.4.0

func (c *CategoryClient) Get(ctx context.Context, id int) (*Category, error)

Get returns a Category entity by its id.

func (*CategoryClient) GetX added in v0.4.0

func (c *CategoryClient) GetX(ctx context.Context, id int) *Category

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

func (*CategoryClient) Hooks added in v0.4.0

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

Hooks returns the client hooks.

func (*CategoryClient) Query added in v0.4.0

func (c *CategoryClient) Query() *CategoryQuery

Query returns a query builder for Category.

func (*CategoryClient) Update added in v0.4.0

func (c *CategoryClient) Update() *CategoryUpdate

Update returns an update builder for Category.

func (*CategoryClient) UpdateOne added in v0.4.0

func (c *CategoryClient) UpdateOne(ca *Category) *CategoryUpdateOne

UpdateOne returns an update builder for the given entity.

func (*CategoryClient) UpdateOneID added in v0.4.0

func (c *CategoryClient) UpdateOneID(id int) *CategoryUpdateOne

UpdateOneID returns an update builder for the given id.

func (*CategoryClient) Use added in v0.4.0

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

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

type CategoryCreate added in v0.4.0

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

CategoryCreate is the builder for creating a Category entity.

func (*CategoryCreate) Exec added in v0.4.0

func (cc *CategoryCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*CategoryCreate) ExecX added in v0.4.0

func (cc *CategoryCreate) ExecX(ctx context.Context)

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

func (*CategoryCreate) Mutation added in v0.4.0

func (cc *CategoryCreate) Mutation() *CategoryMutation

Mutation returns the CategoryMutation object of the builder.

func (*CategoryCreate) Save added in v0.4.0

func (cc *CategoryCreate) Save(ctx context.Context) (*Category, error)

Save creates the Category in the database.

func (*CategoryCreate) SaveX added in v0.4.0

func (cc *CategoryCreate) SaveX(ctx context.Context) *Category

SaveX calls Save and panics if Save returns an error.

func (*CategoryCreate) SetName added in v0.4.0

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

SetName sets the "name" field.

type CategoryCreateBulk added in v0.4.0

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

CategoryCreateBulk is the builder for creating many Category entities in bulk.

func (*CategoryCreateBulk) Exec added in v0.4.0

func (ccb *CategoryCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*CategoryCreateBulk) ExecX added in v0.4.0

func (ccb *CategoryCreateBulk) ExecX(ctx context.Context)

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

func (*CategoryCreateBulk) Save added in v0.4.0

func (ccb *CategoryCreateBulk) Save(ctx context.Context) ([]*Category, error)

Save creates the Category entities in the database.

func (*CategoryCreateBulk) SaveX added in v0.4.0

func (ccb *CategoryCreateBulk) SaveX(ctx context.Context) []*Category

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

type CategoryDelete added in v0.4.0

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

CategoryDelete is the builder for deleting a Category entity.

func (*CategoryDelete) Exec added in v0.4.0

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

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

func (*CategoryDelete) ExecX added in v0.4.0

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

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

func (*CategoryDelete) Where added in v0.4.0

func (cd *CategoryDelete) Where(ps ...predicate.Category) *CategoryDelete

Where appends a list predicates to the CategoryDelete builder.

type CategoryDeleteOne added in v0.4.0

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

CategoryDeleteOne is the builder for deleting a single Category entity.

func (*CategoryDeleteOne) Exec added in v0.4.0

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

Exec executes the deletion query.

func (*CategoryDeleteOne) ExecX added in v0.4.0

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

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

type CategoryGroupBy added in v0.4.0

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

CategoryGroupBy is the group-by builder for Category entities.

func (*CategoryGroupBy) Aggregate added in v0.4.0

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

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

func (*CategoryGroupBy) Bool added in v0.4.0

func (cgb *CategoryGroupBy) 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 (*CategoryGroupBy) BoolX added in v0.4.0

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

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

func (*CategoryGroupBy) Bools added in v0.4.0

func (cgb *CategoryGroupBy) 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 (*CategoryGroupBy) BoolsX added in v0.4.0

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

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

func (*CategoryGroupBy) Float64 added in v0.4.0

func (cgb *CategoryGroupBy) 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 (*CategoryGroupBy) Float64X added in v0.4.0

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

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

func (*CategoryGroupBy) Float64s added in v0.4.0

func (cgb *CategoryGroupBy) 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 (*CategoryGroupBy) Float64sX added in v0.4.0

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

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

func (*CategoryGroupBy) Int added in v0.4.0

func (cgb *CategoryGroupBy) 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 (*CategoryGroupBy) IntX added in v0.4.0

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

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

func (*CategoryGroupBy) Ints added in v0.4.0

func (cgb *CategoryGroupBy) 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 (*CategoryGroupBy) IntsX added in v0.4.0

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

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

func (*CategoryGroupBy) Scan added in v0.4.0

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

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

func (*CategoryGroupBy) ScanX added in v0.4.0

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

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

func (*CategoryGroupBy) String added in v0.4.0

func (cgb *CategoryGroupBy) 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 (*CategoryGroupBy) StringX added in v0.4.0

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

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

func (*CategoryGroupBy) Strings added in v0.4.0

func (cgb *CategoryGroupBy) 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 (*CategoryGroupBy) StringsX added in v0.4.0

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

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

type CategoryMutation added in v0.4.0

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

CategoryMutation represents an operation that mutates the Category nodes in the graph.

func (*CategoryMutation) AddField added in v0.4.0

func (m *CategoryMutation) 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 (*CategoryMutation) AddedEdges added in v0.4.0

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

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

func (*CategoryMutation) AddedField added in v0.4.0

func (m *CategoryMutation) 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 (*CategoryMutation) AddedFields added in v0.4.0

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

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

func (*CategoryMutation) AddedIDs added in v0.4.0

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

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

func (*CategoryMutation) ClearEdge added in v0.4.0

func (m *CategoryMutation) 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 (*CategoryMutation) ClearField added in v0.4.0

func (m *CategoryMutation) 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 (*CategoryMutation) ClearedEdges added in v0.4.0

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

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

func (*CategoryMutation) ClearedFields added in v0.4.0

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

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

func (CategoryMutation) Client added in v0.4.0

func (m CategoryMutation) 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 (*CategoryMutation) EdgeCleared added in v0.4.0

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

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

func (*CategoryMutation) Field added in v0.4.0

func (m *CategoryMutation) 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 (*CategoryMutation) FieldCleared added in v0.4.0

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

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

func (*CategoryMutation) Fields added in v0.4.0

func (m *CategoryMutation) 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 (*CategoryMutation) ID added in v0.4.0

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

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

func (*CategoryMutation) Name added in v0.4.0

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

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

func (*CategoryMutation) OldField added in v0.4.0

func (m *CategoryMutation) 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 (*CategoryMutation) OldName added in v0.4.0

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

OldName returns the old "name" field's value of the Category entity. If the Category 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 (*CategoryMutation) Op added in v0.4.0

func (m *CategoryMutation) Op() Op

Op returns the operation name.

func (*CategoryMutation) RemovedEdges added in v0.4.0

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

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

func (*CategoryMutation) RemovedIDs added in v0.4.0

func (m *CategoryMutation) 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 (*CategoryMutation) ResetEdge added in v0.4.0

func (m *CategoryMutation) 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 (*CategoryMutation) ResetField added in v0.4.0

func (m *CategoryMutation) 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 (*CategoryMutation) ResetName added in v0.4.0

func (m *CategoryMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*CategoryMutation) SetField added in v0.4.0

func (m *CategoryMutation) 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 (*CategoryMutation) SetName added in v0.4.0

func (m *CategoryMutation) SetName(s string)

SetName sets the "name" field.

func (CategoryMutation) Tx added in v0.4.0

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

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

func (*CategoryMutation) Type added in v0.4.0

func (m *CategoryMutation) Type() string

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

func (*CategoryMutation) Where added in v0.4.0

func (m *CategoryMutation) Where(ps ...predicate.Category)

Where appends a list predicates to the CategoryMutation builder.

type CategoryQuery added in v0.4.0

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

CategoryQuery is the builder for querying Category entities.

func (*CategoryQuery) All added in v0.4.0

func (cq *CategoryQuery) All(ctx context.Context) ([]*Category, error)

All executes the query and returns a list of Categories.

func (*CategoryQuery) AllX added in v0.4.0

func (cq *CategoryQuery) AllX(ctx context.Context) []*Category

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

func (*CategoryQuery) Clone added in v0.4.0

func (cq *CategoryQuery) Clone() *CategoryQuery

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

func (*CategoryQuery) Count added in v0.4.0

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

Count returns the count of the given query.

func (*CategoryQuery) CountX added in v0.4.0

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

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

func (*CategoryQuery) Exist added in v0.4.0

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

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

func (*CategoryQuery) ExistX added in v0.4.0

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

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

func (*CategoryQuery) First added in v0.4.0

func (cq *CategoryQuery) First(ctx context.Context) (*Category, error)

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

func (*CategoryQuery) FirstID added in v0.4.0

func (cq *CategoryQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*CategoryQuery) FirstIDX added in v0.4.0

func (cq *CategoryQuery) FirstIDX(ctx context.Context) int

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

func (*CategoryQuery) FirstX added in v0.4.0

func (cq *CategoryQuery) FirstX(ctx context.Context) *Category

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

func (*CategoryQuery) GroupBy added in v0.4.0

func (cq *CategoryQuery) GroupBy(field string, fields ...string) *CategoryGroupBy

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

func (*CategoryQuery) IDs added in v0.4.0

func (cq *CategoryQuery) IDs(ctx context.Context) ([]int, error)

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

func (*CategoryQuery) IDsX added in v0.4.0

func (cq *CategoryQuery) IDsX(ctx context.Context) []int

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

func (*CategoryQuery) Limit added in v0.4.0

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

Limit adds a limit step to the query.

func (*CategoryQuery) Offset added in v0.4.0

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

Offset adds an offset step to the query.

func (*CategoryQuery) Only added in v0.4.0

func (cq *CategoryQuery) Only(ctx context.Context) (*Category, error)

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

func (*CategoryQuery) OnlyID added in v0.4.0

func (cq *CategoryQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*CategoryQuery) OnlyIDX added in v0.4.0

func (cq *CategoryQuery) OnlyIDX(ctx context.Context) int

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

func (*CategoryQuery) OnlyX added in v0.4.0

func (cq *CategoryQuery) OnlyX(ctx context.Context) *Category

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

func (*CategoryQuery) Order added in v0.4.0

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

Order adds an order step to the query.

func (*CategoryQuery) Select added in v0.4.0

func (cq *CategoryQuery) Select(fields ...string) *CategorySelect

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

func (*CategoryQuery) Unique added in v0.4.0

func (cq *CategoryQuery) Unique(unique bool) *CategoryQuery

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

func (*CategoryQuery) Where added in v0.4.0

func (cq *CategoryQuery) Where(ps ...predicate.Category) *CategoryQuery

Where adds a new predicate for the CategoryQuery builder.

type CategorySelect added in v0.4.0

type CategorySelect struct {
	*CategoryQuery
	// contains filtered or unexported fields
}

CategorySelect is the builder for selecting fields of Category entities.

func (*CategorySelect) Bool added in v0.4.0

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

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

func (*CategorySelect) BoolX added in v0.4.0

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

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

func (*CategorySelect) Bools added in v0.4.0

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

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

func (*CategorySelect) BoolsX added in v0.4.0

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

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

func (*CategorySelect) Float64 added in v0.4.0

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

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

func (*CategorySelect) Float64X added in v0.4.0

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

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

func (*CategorySelect) Float64s added in v0.4.0

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

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

func (*CategorySelect) Float64sX added in v0.4.0

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

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

func (*CategorySelect) Int added in v0.4.0

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

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

func (*CategorySelect) IntX added in v0.4.0

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

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

func (*CategorySelect) Ints added in v0.4.0

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

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

func (*CategorySelect) IntsX added in v0.4.0

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

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

func (*CategorySelect) Scan added in v0.4.0

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

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

func (*CategorySelect) ScanX added in v0.4.0

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

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

func (*CategorySelect) String added in v0.4.0

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

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

func (*CategorySelect) StringX added in v0.4.0

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

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

func (*CategorySelect) Strings added in v0.4.0

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

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

func (*CategorySelect) StringsX added in v0.4.0

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

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

type CategoryUpdate added in v0.4.0

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

CategoryUpdate is the builder for updating Category entities.

func (*CategoryUpdate) Exec added in v0.4.0

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

Exec executes the query.

func (*CategoryUpdate) ExecX added in v0.4.0

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

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

func (*CategoryUpdate) Mutation added in v0.4.0

func (cu *CategoryUpdate) Mutation() *CategoryMutation

Mutation returns the CategoryMutation object of the builder.

func (*CategoryUpdate) Save added in v0.4.0

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

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

func (*CategoryUpdate) SaveX added in v0.4.0

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

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

func (*CategoryUpdate) SetName added in v0.4.0

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

SetName sets the "name" field.

func (*CategoryUpdate) Where added in v0.4.0

func (cu *CategoryUpdate) Where(ps ...predicate.Category) *CategoryUpdate

Where appends a list predicates to the CategoryUpdate builder.

type CategoryUpdateOne added in v0.4.0

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

CategoryUpdateOne is the builder for updating a single Category entity.

func (*CategoryUpdateOne) Exec added in v0.4.0

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

Exec executes the query on the entity.

func (*CategoryUpdateOne) ExecX added in v0.4.0

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

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

func (*CategoryUpdateOne) Mutation added in v0.4.0

func (cuo *CategoryUpdateOne) Mutation() *CategoryMutation

Mutation returns the CategoryMutation object of the builder.

func (*CategoryUpdateOne) Save added in v0.4.0

func (cuo *CategoryUpdateOne) Save(ctx context.Context) (*Category, error)

Save executes the query and returns the updated Category entity.

func (*CategoryUpdateOne) SaveX added in v0.4.0

func (cuo *CategoryUpdateOne) SaveX(ctx context.Context) *Category

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

func (*CategoryUpdateOne) Select added in v0.4.0

func (cuo *CategoryUpdateOne) Select(field string, fields ...string) *CategoryUpdateOne

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

func (*CategoryUpdateOne) SetName added in v0.4.0

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

SetName sets the "name" field.

type Client

type Client struct {

	// Schema is the client for creating, migrating and dropping schema.
	Schema *migrate.Schema
	// Category is the client for interacting with the Category builders.
	Category *CategoryClient
	// Equipment is the client for interacting with the Equipment builders.
	Equipment *EquipmentClient
	// Vehicle is the client for interacting with the Vehicle builders.
	Vehicle *VehicleClient
	// 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().
	Category.
	Query().
	Count(ctx)

func (*Client) OpenTx added in v0.3.0

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 Equipment

type Equipment 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"`
	// Condition holds the value of the "condition" field.
	Condition string `json:"condition,omitempty"`
	// contains filtered or unexported fields
}

Equipment is the model entity for the Equipment schema.

func (*Equipment) String

func (e *Equipment) String() string

String implements the fmt.Stringer.

func (*Equipment) Unwrap

func (e *Equipment) Unwrap() *Equipment

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

func (e *Equipment) Update() *EquipmentUpdateOne

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

type EquipmentClient

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

EquipmentClient is a client for the Equipment schema.

func NewEquipmentClient

func NewEquipmentClient(c config) *EquipmentClient

NewEquipmentClient returns a client for the Equipment from the given config.

func (*EquipmentClient) Create

func (c *EquipmentClient) Create() *EquipmentCreate

Create returns a create builder for Equipment.

func (*EquipmentClient) CreateBulk

func (c *EquipmentClient) CreateBulk(builders ...*EquipmentCreate) *EquipmentCreateBulk

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

func (*EquipmentClient) Delete

func (c *EquipmentClient) Delete() *EquipmentDelete

Delete returns a delete builder for Equipment.

func (*EquipmentClient) DeleteOne

func (c *EquipmentClient) DeleteOne(e *Equipment) *EquipmentDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*EquipmentClient) DeleteOneID

func (c *EquipmentClient) DeleteOneID(id int) *EquipmentDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*EquipmentClient) Get

func (c *EquipmentClient) Get(ctx context.Context, id int) (*Equipment, error)

Get returns a Equipment entity by its id.

func (*EquipmentClient) GetX

func (c *EquipmentClient) GetX(ctx context.Context, id int) *Equipment

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

func (*EquipmentClient) Hooks

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

Hooks returns the client hooks.

func (*EquipmentClient) Query

func (c *EquipmentClient) Query() *EquipmentQuery

Query returns a query builder for Equipment.

func (*EquipmentClient) Update

func (c *EquipmentClient) Update() *EquipmentUpdate

Update returns an update builder for Equipment.

func (*EquipmentClient) UpdateOne

func (c *EquipmentClient) UpdateOne(e *Equipment) *EquipmentUpdateOne

UpdateOne returns an update builder for the given entity.

func (*EquipmentClient) UpdateOneID

func (c *EquipmentClient) UpdateOneID(id int) *EquipmentUpdateOne

UpdateOneID returns an update builder for the given id.

func (*EquipmentClient) Use

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

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

type EquipmentCreate

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

EquipmentCreate is the builder for creating a Equipment entity.

func (*EquipmentCreate) Exec

func (ec *EquipmentCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*EquipmentCreate) ExecX

func (ec *EquipmentCreate) ExecX(ctx context.Context)

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

func (*EquipmentCreate) Mutation

func (ec *EquipmentCreate) Mutation() *EquipmentMutation

Mutation returns the EquipmentMutation object of the builder.

func (*EquipmentCreate) Save

func (ec *EquipmentCreate) Save(ctx context.Context) (*Equipment, error)

Save creates the Equipment in the database.

func (*EquipmentCreate) SaveX

func (ec *EquipmentCreate) SaveX(ctx context.Context) *Equipment

SaveX calls Save and panics if Save returns an error.

func (*EquipmentCreate) SetCondition

func (ec *EquipmentCreate) SetCondition(s string) *EquipmentCreate

SetCondition sets the "condition" field.

func (*EquipmentCreate) SetCreateTime added in v0.3.0

func (ec *EquipmentCreate) SetCreateTime(t time.Time) *EquipmentCreate

SetCreateTime sets the "create_time" field.

func (*EquipmentCreate) SetName

func (ec *EquipmentCreate) SetName(s string) *EquipmentCreate

SetName sets the "name" field.

func (*EquipmentCreate) SetNillableCreateTime added in v0.3.0

func (ec *EquipmentCreate) SetNillableCreateTime(t *time.Time) *EquipmentCreate

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

func (*EquipmentCreate) SetNillableUpdateTime added in v0.3.0

func (ec *EquipmentCreate) SetNillableUpdateTime(t *time.Time) *EquipmentCreate

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

func (*EquipmentCreate) SetUpdateTime added in v0.3.0

func (ec *EquipmentCreate) SetUpdateTime(t time.Time) *EquipmentCreate

SetUpdateTime sets the "update_time" field.

type EquipmentCreateBulk

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

EquipmentCreateBulk is the builder for creating many Equipment entities in bulk.

func (*EquipmentCreateBulk) Exec

func (ecb *EquipmentCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*EquipmentCreateBulk) ExecX

func (ecb *EquipmentCreateBulk) ExecX(ctx context.Context)

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

func (*EquipmentCreateBulk) Save

func (ecb *EquipmentCreateBulk) Save(ctx context.Context) ([]*Equipment, error)

Save creates the Equipment entities in the database.

func (*EquipmentCreateBulk) SaveX

func (ecb *EquipmentCreateBulk) SaveX(ctx context.Context) []*Equipment

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

type EquipmentDelete

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

EquipmentDelete is the builder for deleting a Equipment entity.

func (*EquipmentDelete) Exec

func (ed *EquipmentDelete) Exec(ctx context.Context) (int, error)

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

func (*EquipmentDelete) ExecX

func (ed *EquipmentDelete) ExecX(ctx context.Context) int

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

func (*EquipmentDelete) Where

Where appends a list predicates to the EquipmentDelete builder.

type EquipmentDeleteOne

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

EquipmentDeleteOne is the builder for deleting a single Equipment entity.

func (*EquipmentDeleteOne) Exec

func (edo *EquipmentDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*EquipmentDeleteOne) ExecX

func (edo *EquipmentDeleteOne) ExecX(ctx context.Context)

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

type EquipmentGroupBy

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

EquipmentGroupBy is the group-by builder for Equipment entities.

func (*EquipmentGroupBy) Aggregate

func (egb *EquipmentGroupBy) Aggregate(fns ...AggregateFunc) *EquipmentGroupBy

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

func (*EquipmentGroupBy) Bool

func (egb *EquipmentGroupBy) 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 (*EquipmentGroupBy) BoolX

func (egb *EquipmentGroupBy) BoolX(ctx context.Context) bool

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

func (*EquipmentGroupBy) Bools

func (egb *EquipmentGroupBy) 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 (*EquipmentGroupBy) BoolsX

func (egb *EquipmentGroupBy) BoolsX(ctx context.Context) []bool

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

func (*EquipmentGroupBy) Float64

func (egb *EquipmentGroupBy) 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 (*EquipmentGroupBy) Float64X

func (egb *EquipmentGroupBy) Float64X(ctx context.Context) float64

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

func (*EquipmentGroupBy) Float64s

func (egb *EquipmentGroupBy) 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 (*EquipmentGroupBy) Float64sX

func (egb *EquipmentGroupBy) Float64sX(ctx context.Context) []float64

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

func (*EquipmentGroupBy) Int

func (egb *EquipmentGroupBy) 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 (*EquipmentGroupBy) IntX

func (egb *EquipmentGroupBy) IntX(ctx context.Context) int

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

func (*EquipmentGroupBy) Ints

func (egb *EquipmentGroupBy) 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 (*EquipmentGroupBy) IntsX

func (egb *EquipmentGroupBy) IntsX(ctx context.Context) []int

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

func (*EquipmentGroupBy) Scan

func (egb *EquipmentGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*EquipmentGroupBy) ScanX

func (egb *EquipmentGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*EquipmentGroupBy) String

func (egb *EquipmentGroupBy) 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 (*EquipmentGroupBy) StringX

func (egb *EquipmentGroupBy) StringX(ctx context.Context) string

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

func (*EquipmentGroupBy) Strings

func (egb *EquipmentGroupBy) 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 (*EquipmentGroupBy) StringsX

func (egb *EquipmentGroupBy) StringsX(ctx context.Context) []string

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

type EquipmentMutation

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

EquipmentMutation represents an operation that mutates the Equipment nodes in the graph.

func (*EquipmentMutation) AddField

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

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

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

func (*EquipmentMutation) AddedField

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

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

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

func (*EquipmentMutation) AddedIDs

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

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

func (*EquipmentMutation) ClearEdge

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

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

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

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

func (*EquipmentMutation) ClearedFields

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

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

func (EquipmentMutation) Client

func (m EquipmentMutation) 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 (*EquipmentMutation) Condition

func (m *EquipmentMutation) Condition() (r string, exists bool)

Condition returns the value of the "condition" field in the mutation.

func (*EquipmentMutation) CreateTime added in v0.3.0

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

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

func (*EquipmentMutation) EdgeCleared

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

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

func (*EquipmentMutation) Field

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

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

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

func (*EquipmentMutation) Fields

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

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

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

func (*EquipmentMutation) Name

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

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

func (*EquipmentMutation) OldCondition

func (m *EquipmentMutation) OldCondition(ctx context.Context) (v string, err error)

OldCondition returns the old "condition" field's value of the Equipment entity. If the Equipment 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 (*EquipmentMutation) OldCreateTime added in v0.3.0

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

OldCreateTime returns the old "create_time" field's value of the Equipment entity. If the Equipment 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 (*EquipmentMutation) OldField

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

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

OldName returns the old "name" field's value of the Equipment entity. If the Equipment 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 (*EquipmentMutation) OldUpdateTime added in v0.3.0

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

OldUpdateTime returns the old "update_time" field's value of the Equipment entity. If the Equipment 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 (*EquipmentMutation) Op

func (m *EquipmentMutation) Op() Op

Op returns the operation name.

func (*EquipmentMutation) RemovedEdges

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

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

func (*EquipmentMutation) RemovedIDs

func (m *EquipmentMutation) 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 (*EquipmentMutation) ResetCondition

func (m *EquipmentMutation) ResetCondition()

ResetCondition resets all changes to the "condition" field.

func (*EquipmentMutation) ResetCreateTime added in v0.3.0

func (m *EquipmentMutation) ResetCreateTime()

ResetCreateTime resets all changes to the "create_time" field.

func (*EquipmentMutation) ResetEdge

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

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

func (m *EquipmentMutation) ResetName()

ResetName resets all changes to the "name" field.

func (*EquipmentMutation) ResetUpdateTime added in v0.3.0

func (m *EquipmentMutation) ResetUpdateTime()

ResetUpdateTime resets all changes to the "update_time" field.

func (*EquipmentMutation) SetCondition

func (m *EquipmentMutation) SetCondition(s string)

SetCondition sets the "condition" field.

func (*EquipmentMutation) SetCreateTime added in v0.3.0

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

SetCreateTime sets the "create_time" field.

func (*EquipmentMutation) SetField

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

func (m *EquipmentMutation) SetName(s string)

SetName sets the "name" field.

func (*EquipmentMutation) SetUpdateTime added in v0.3.0

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

SetUpdateTime sets the "update_time" field.

func (EquipmentMutation) Tx

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

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

func (*EquipmentMutation) Type

func (m *EquipmentMutation) Type() string

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

func (*EquipmentMutation) UpdateTime added in v0.3.0

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

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

func (*EquipmentMutation) Where

func (m *EquipmentMutation) Where(ps ...predicate.Equipment)

Where appends a list predicates to the EquipmentMutation builder.

type EquipmentQuery

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

EquipmentQuery is the builder for querying Equipment entities.

func (*EquipmentQuery) All

func (eq *EquipmentQuery) All(ctx context.Context) ([]*Equipment, error)

All executes the query and returns a list of EquipmentSlice.

func (*EquipmentQuery) AllX

func (eq *EquipmentQuery) AllX(ctx context.Context) []*Equipment

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

func (*EquipmentQuery) Clone

func (eq *EquipmentQuery) Clone() *EquipmentQuery

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

func (*EquipmentQuery) CollectFields added in v0.3.0

func (e *EquipmentQuery) CollectFields(ctx context.Context, satisfies ...string) *EquipmentQuery

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

func (*EquipmentQuery) Count

func (eq *EquipmentQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*EquipmentQuery) CountX

func (eq *EquipmentQuery) CountX(ctx context.Context) int

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

func (*EquipmentQuery) Exist

func (eq *EquipmentQuery) Exist(ctx context.Context) (bool, error)

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

func (*EquipmentQuery) ExistX

func (eq *EquipmentQuery) ExistX(ctx context.Context) bool

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

func (*EquipmentQuery) First

func (eq *EquipmentQuery) First(ctx context.Context) (*Equipment, error)

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

func (*EquipmentQuery) FirstID

func (eq *EquipmentQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*EquipmentQuery) FirstIDX

func (eq *EquipmentQuery) FirstIDX(ctx context.Context) int

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

func (*EquipmentQuery) FirstX

func (eq *EquipmentQuery) FirstX(ctx context.Context) *Equipment

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

func (*EquipmentQuery) GroupBy

func (eq *EquipmentQuery) GroupBy(field string, fields ...string) *EquipmentGroupBy

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.Equipment.Query().
	GroupBy(equipment.FieldCreateTime).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*EquipmentQuery) IDs

func (eq *EquipmentQuery) IDs(ctx context.Context) ([]int, error)

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

func (*EquipmentQuery) IDsX

func (eq *EquipmentQuery) IDsX(ctx context.Context) []int

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

func (*EquipmentQuery) Limit

func (eq *EquipmentQuery) Limit(limit int) *EquipmentQuery

Limit adds a limit step to the query.

func (*EquipmentQuery) Offset

func (eq *EquipmentQuery) Offset(offset int) *EquipmentQuery

Offset adds an offset step to the query.

func (*EquipmentQuery) Only

func (eq *EquipmentQuery) Only(ctx context.Context) (*Equipment, error)

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

func (*EquipmentQuery) OnlyID

func (eq *EquipmentQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*EquipmentQuery) OnlyIDX

func (eq *EquipmentQuery) OnlyIDX(ctx context.Context) int

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

func (*EquipmentQuery) OnlyX

func (eq *EquipmentQuery) OnlyX(ctx context.Context) *Equipment

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

func (*EquipmentQuery) Order

func (eq *EquipmentQuery) Order(o ...OrderFunc) *EquipmentQuery

Order adds an order step to the query.

func (*EquipmentQuery) Select

func (eq *EquipmentQuery) Select(fields ...string) *EquipmentSelect

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.Equipment.Query().
	Select(equipment.FieldCreateTime).
	Scan(ctx, &v)

func (*EquipmentQuery) Unique

func (eq *EquipmentQuery) Unique(unique bool) *EquipmentQuery

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

func (*EquipmentQuery) Where

Where adds a new predicate for the EquipmentQuery builder.

type EquipmentSelect

type EquipmentSelect struct {
	*EquipmentQuery
	// contains filtered or unexported fields
}

EquipmentSelect is the builder for selecting fields of Equipment entities.

func (*EquipmentSelect) Bool

func (es *EquipmentSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*EquipmentSelect) BoolX

func (es *EquipmentSelect) BoolX(ctx context.Context) bool

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

func (*EquipmentSelect) Bools

func (es *EquipmentSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*EquipmentSelect) BoolsX

func (es *EquipmentSelect) BoolsX(ctx context.Context) []bool

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

func (*EquipmentSelect) Float64

func (es *EquipmentSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*EquipmentSelect) Float64X

func (es *EquipmentSelect) Float64X(ctx context.Context) float64

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

func (*EquipmentSelect) Float64s

func (es *EquipmentSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*EquipmentSelect) Float64sX

func (es *EquipmentSelect) Float64sX(ctx context.Context) []float64

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

func (*EquipmentSelect) Int

func (es *EquipmentSelect) Int(ctx context.Context) (_ int, err error)

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

func (*EquipmentSelect) IntX

func (es *EquipmentSelect) IntX(ctx context.Context) int

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

func (*EquipmentSelect) Ints

func (es *EquipmentSelect) Ints(ctx context.Context) ([]int, error)

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

func (*EquipmentSelect) IntsX

func (es *EquipmentSelect) IntsX(ctx context.Context) []int

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

func (*EquipmentSelect) Scan

func (es *EquipmentSelect) Scan(ctx context.Context, v interface{}) error

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

func (*EquipmentSelect) ScanX

func (es *EquipmentSelect) ScanX(ctx context.Context, v interface{})

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

func (*EquipmentSelect) String

func (es *EquipmentSelect) String(ctx context.Context) (_ string, err error)

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

func (*EquipmentSelect) StringX

func (es *EquipmentSelect) StringX(ctx context.Context) string

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

func (*EquipmentSelect) Strings

func (es *EquipmentSelect) Strings(ctx context.Context) ([]string, error)

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

func (*EquipmentSelect) StringsX

func (es *EquipmentSelect) StringsX(ctx context.Context) []string

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

type EquipmentSlice

type EquipmentSlice []*Equipment

EquipmentSlice is a parsable slice of Equipment.

type EquipmentUpdate

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

EquipmentUpdate is the builder for updating Equipment entities.

func (*EquipmentUpdate) Exec

func (eu *EquipmentUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*EquipmentUpdate) ExecX

func (eu *EquipmentUpdate) ExecX(ctx context.Context)

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

func (*EquipmentUpdate) Mutation

func (eu *EquipmentUpdate) Mutation() *EquipmentMutation

Mutation returns the EquipmentMutation object of the builder.

func (*EquipmentUpdate) Save

func (eu *EquipmentUpdate) Save(ctx context.Context) (int, error)

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

func (*EquipmentUpdate) SaveX

func (eu *EquipmentUpdate) SaveX(ctx context.Context) int

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

func (*EquipmentUpdate) SetCondition

func (eu *EquipmentUpdate) SetCondition(s string) *EquipmentUpdate

SetCondition sets the "condition" field.

func (*EquipmentUpdate) SetCreateTime added in v0.4.0

func (eu *EquipmentUpdate) SetCreateTime(t time.Time) *EquipmentUpdate

SetCreateTime sets the "create_time" field.

func (*EquipmentUpdate) SetName

func (eu *EquipmentUpdate) SetName(s string) *EquipmentUpdate

SetName sets the "name" field.

func (*EquipmentUpdate) SetNillableCreateTime added in v0.4.0

func (eu *EquipmentUpdate) SetNillableCreateTime(t *time.Time) *EquipmentUpdate

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

func (*EquipmentUpdate) SetUpdateTime added in v0.3.0

func (eu *EquipmentUpdate) SetUpdateTime(t time.Time) *EquipmentUpdate

SetUpdateTime sets the "update_time" field.

func (*EquipmentUpdate) Where

Where appends a list predicates to the EquipmentUpdate builder.

type EquipmentUpdateOne

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

EquipmentUpdateOne is the builder for updating a single Equipment entity.

func (*EquipmentUpdateOne) Exec

func (euo *EquipmentUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*EquipmentUpdateOne) ExecX

func (euo *EquipmentUpdateOne) ExecX(ctx context.Context)

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

func (*EquipmentUpdateOne) Mutation

func (euo *EquipmentUpdateOne) Mutation() *EquipmentMutation

Mutation returns the EquipmentMutation object of the builder.

func (*EquipmentUpdateOne) Save

func (euo *EquipmentUpdateOne) Save(ctx context.Context) (*Equipment, error)

Save executes the query and returns the updated Equipment entity.

func (*EquipmentUpdateOne) SaveX

func (euo *EquipmentUpdateOne) SaveX(ctx context.Context) *Equipment

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

func (*EquipmentUpdateOne) Select

func (euo *EquipmentUpdateOne) Select(field string, fields ...string) *EquipmentUpdateOne

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

func (*EquipmentUpdateOne) SetCondition

func (euo *EquipmentUpdateOne) SetCondition(s string) *EquipmentUpdateOne

SetCondition sets the "condition" field.

func (*EquipmentUpdateOne) SetCreateTime added in v0.4.0

func (euo *EquipmentUpdateOne) SetCreateTime(t time.Time) *EquipmentUpdateOne

SetCreateTime sets the "create_time" field.

func (*EquipmentUpdateOne) SetName

func (euo *EquipmentUpdateOne) SetName(s string) *EquipmentUpdateOne

SetName sets the "name" field.

func (*EquipmentUpdateOne) SetNillableCreateTime added in v0.4.0

func (euo *EquipmentUpdateOne) SetNillableCreateTime(t *time.Time) *EquipmentUpdateOne

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

func (*EquipmentUpdateOne) SetUpdateTime added in v0.3.0

func (euo *EquipmentUpdateOne) SetUpdateTime(t time.Time) *EquipmentUpdateOne

SetUpdateTime sets the "update_time" field.

type Hook

type Hook = ent.Hook

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

type MutateFunc

type MutateFunc = ent.MutateFunc

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

type Mutation

type Mutation = ent.Mutation

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

type Mutator

type Mutator = ent.Mutator

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

type NotFoundError

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

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

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

type NotLoadedError

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

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

func (*NotLoadedError) Error

func (e *NotLoadedError) Error() string

Error implements the error interface.

type NotSingularError

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

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

func (*NotSingularError) Error

func (e *NotSingularError) Error() string

Error implements the error interface.

type Op

type Op = ent.Op

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

type Option

type Option func(*config)

Option function to configure the client.

func Debug

func Debug() Option

Debug enables debug logging on the ent.Driver.

func Driver

func Driver(driver dialect.Driver) Option

Driver configures the client driver.

func Log

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

Log sets the logging function for debug mode.

type OrderFunc

type OrderFunc func(*sql.Selector)

OrderFunc applies an ordering on the sql selector.

func Asc

func Asc(fields ...string) OrderFunc

Asc applies the given fields in ASC order.

func Desc

func Desc(fields ...string) OrderFunc

Desc applies the given fields in DESC order.

type Policy

type Policy = ent.Policy

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

type Query

type Query = ent.Query

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

type RollbackFunc

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

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

func (RollbackFunc) Rollback

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

Rollback calls f(ctx, m).

type RollbackHook

type RollbackHook func(Rollbacker) Rollbacker

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

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

type Rollbacker

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

Rollbacker is the interface that wraps the Rollbacker method.

type Tx

type Tx struct {

	// Category is the client for interacting with the Category builders.
	Category *CategoryClient
	// Equipment is the client for interacting with the Equipment builders.
	Equipment *EquipmentClient
	// Vehicle is the client for interacting with the Vehicle builders.
	Vehicle *VehicleClient
	// contains filtered or unexported fields
}

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

func TxFromContext

func TxFromContext(ctx context.Context) *Tx

TxFromContext returns a Tx stored inside a context, or nil if there isn't one.

func (*Tx) Client

func (tx *Tx) Client() *Client

Client returns a Client that binds to current transaction.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) OnCommit

func (tx *Tx) OnCommit(f CommitHook)

OnCommit adds a hook to call on commit.

func (*Tx) OnRollback

func (tx *Tx) OnRollback(f RollbackHook)

OnRollback adds a hook to call on rollback.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback rollbacks the transaction.

type ValidationError

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

ValidationError returns when validating a field fails.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

Unwrap implements the errors.Wrapper interface.

type Value

type Value = ent.Value

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

type Vehicle

type Vehicle 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"`
	// Make holds the value of the "make" field.
	Make string `json:"make,omitempty"`
	// Model holds the value of the "model" field.
	Model string `json:"model,omitempty"`
	// Miles holds the value of the "miles" field.
	Miles int64 `json:"miles,omitempty"`
	// Mpg holds the value of the "mpg" field.
	Mpg int64 `json:"mpg,omitempty"`
	// Owner holds the value of the "owner" field.
	Owner string `json:"owner,omitempty"`
	// Year holds the value of the "year" field.
	Year string `json:"year,omitempty"`
	// Active holds the value of the "active" field.
	Active bool `json:"active,omitempty"`
	// Condition holds the value of the "condition" field.
	Condition string `json:"condition,omitempty"`
	// contains filtered or unexported fields
}

Vehicle is the model entity for the Vehicle schema.

func (*Vehicle) String

func (v *Vehicle) String() string

String implements the fmt.Stringer.

func (*Vehicle) Unwrap

func (v *Vehicle) Unwrap() *Vehicle

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

func (v *Vehicle) Update() *VehicleUpdateOne

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

type VehicleClient

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

VehicleClient is a client for the Vehicle schema.

func NewVehicleClient

func NewVehicleClient(c config) *VehicleClient

NewVehicleClient returns a client for the Vehicle from the given config.

func (*VehicleClient) Create

func (c *VehicleClient) Create() *VehicleCreate

Create returns a create builder for Vehicle.

func (*VehicleClient) CreateBulk

func (c *VehicleClient) CreateBulk(builders ...*VehicleCreate) *VehicleCreateBulk

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

func (*VehicleClient) Delete

func (c *VehicleClient) Delete() *VehicleDelete

Delete returns a delete builder for Vehicle.

func (*VehicleClient) DeleteOne

func (c *VehicleClient) DeleteOne(v *Vehicle) *VehicleDeleteOne

DeleteOne returns a delete builder for the given entity.

func (*VehicleClient) DeleteOneID

func (c *VehicleClient) DeleteOneID(id int) *VehicleDeleteOne

DeleteOneID returns a delete builder for the given id.

func (*VehicleClient) Get

func (c *VehicleClient) Get(ctx context.Context, id int) (*Vehicle, error)

Get returns a Vehicle entity by its id.

func (*VehicleClient) GetX

func (c *VehicleClient) GetX(ctx context.Context, id int) *Vehicle

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

func (*VehicleClient) Hooks

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

Hooks returns the client hooks.

func (*VehicleClient) Query

func (c *VehicleClient) Query() *VehicleQuery

Query returns a query builder for Vehicle.

func (*VehicleClient) Update

func (c *VehicleClient) Update() *VehicleUpdate

Update returns an update builder for Vehicle.

func (*VehicleClient) UpdateOne

func (c *VehicleClient) UpdateOne(v *Vehicle) *VehicleUpdateOne

UpdateOne returns an update builder for the given entity.

func (*VehicleClient) UpdateOneID

func (c *VehicleClient) UpdateOneID(id int) *VehicleUpdateOne

UpdateOneID returns an update builder for the given id.

func (*VehicleClient) Use

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

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

type VehicleCreate

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

VehicleCreate is the builder for creating a Vehicle entity.

func (*VehicleCreate) Exec

func (vc *VehicleCreate) Exec(ctx context.Context) error

Exec executes the query.

func (*VehicleCreate) ExecX

func (vc *VehicleCreate) ExecX(ctx context.Context)

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

func (*VehicleCreate) Mutation

func (vc *VehicleCreate) Mutation() *VehicleMutation

Mutation returns the VehicleMutation object of the builder.

func (*VehicleCreate) Save

func (vc *VehicleCreate) Save(ctx context.Context) (*Vehicle, error)

Save creates the Vehicle in the database.

func (*VehicleCreate) SaveX

func (vc *VehicleCreate) SaveX(ctx context.Context) *Vehicle

SaveX calls Save and panics if Save returns an error.

func (*VehicleCreate) SetActive added in v0.2.0

func (vc *VehicleCreate) SetActive(b bool) *VehicleCreate

SetActive sets the "active" field.

func (*VehicleCreate) SetCondition

func (vc *VehicleCreate) SetCondition(s string) *VehicleCreate

SetCondition sets the "condition" field.

func (*VehicleCreate) SetCreateTime added in v0.3.0

func (vc *VehicleCreate) SetCreateTime(t time.Time) *VehicleCreate

SetCreateTime sets the "create_time" field.

func (*VehicleCreate) SetMake

func (vc *VehicleCreate) SetMake(s string) *VehicleCreate

SetMake sets the "make" field.

func (*VehicleCreate) SetMiles added in v0.3.0

func (vc *VehicleCreate) SetMiles(i int64) *VehicleCreate

SetMiles sets the "miles" field.

func (*VehicleCreate) SetModel

func (vc *VehicleCreate) SetModel(s string) *VehicleCreate

SetModel sets the "model" field.

func (*VehicleCreate) SetMpg added in v0.3.0

func (vc *VehicleCreate) SetMpg(i int64) *VehicleCreate

SetMpg sets the "mpg" field.

func (*VehicleCreate) SetNillableActive added in v0.3.0

func (vc *VehicleCreate) SetNillableActive(b *bool) *VehicleCreate

SetNillableActive sets the "active" field if the given value is not nil.

func (*VehicleCreate) SetNillableCondition added in v0.3.0

func (vc *VehicleCreate) SetNillableCondition(s *string) *VehicleCreate

SetNillableCondition sets the "condition" field if the given value is not nil.

func (*VehicleCreate) SetNillableCreateTime added in v0.3.0

func (vc *VehicleCreate) SetNillableCreateTime(t *time.Time) *VehicleCreate

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

func (*VehicleCreate) SetNillableMiles added in v0.3.0

func (vc *VehicleCreate) SetNillableMiles(i *int64) *VehicleCreate

SetNillableMiles sets the "miles" field if the given value is not nil.

func (*VehicleCreate) SetNillableMpg added in v0.3.0

func (vc *VehicleCreate) SetNillableMpg(i *int64) *VehicleCreate

SetNillableMpg sets the "mpg" field if the given value is not nil.

func (*VehicleCreate) SetNillableOwner added in v0.3.0

func (vc *VehicleCreate) SetNillableOwner(s *string) *VehicleCreate

SetNillableOwner sets the "owner" field if the given value is not nil.

func (*VehicleCreate) SetNillableUpdateTime added in v0.3.0

func (vc *VehicleCreate) SetNillableUpdateTime(t *time.Time) *VehicleCreate

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

func (*VehicleCreate) SetNillableYear added in v0.3.0

func (vc *VehicleCreate) SetNillableYear(s *string) *VehicleCreate

SetNillableYear sets the "year" field if the given value is not nil.

func (*VehicleCreate) SetOwner added in v0.3.0

func (vc *VehicleCreate) SetOwner(s string) *VehicleCreate

SetOwner sets the "owner" field.

func (*VehicleCreate) SetUpdateTime added in v0.3.0

func (vc *VehicleCreate) SetUpdateTime(t time.Time) *VehicleCreate

SetUpdateTime sets the "update_time" field.

func (*VehicleCreate) SetYear

func (vc *VehicleCreate) SetYear(s string) *VehicleCreate

SetYear sets the "year" field.

type VehicleCreateBulk

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

VehicleCreateBulk is the builder for creating many Vehicle entities in bulk.

func (*VehicleCreateBulk) Exec

func (vcb *VehicleCreateBulk) Exec(ctx context.Context) error

Exec executes the query.

func (*VehicleCreateBulk) ExecX

func (vcb *VehicleCreateBulk) ExecX(ctx context.Context)

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

func (*VehicleCreateBulk) Save

func (vcb *VehicleCreateBulk) Save(ctx context.Context) ([]*Vehicle, error)

Save creates the Vehicle entities in the database.

func (*VehicleCreateBulk) SaveX

func (vcb *VehicleCreateBulk) SaveX(ctx context.Context) []*Vehicle

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

type VehicleDelete

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

VehicleDelete is the builder for deleting a Vehicle entity.

func (*VehicleDelete) Exec

func (vd *VehicleDelete) Exec(ctx context.Context) (int, error)

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

func (*VehicleDelete) ExecX

func (vd *VehicleDelete) ExecX(ctx context.Context) int

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

func (*VehicleDelete) Where

func (vd *VehicleDelete) Where(ps ...predicate.Vehicle) *VehicleDelete

Where appends a list predicates to the VehicleDelete builder.

type VehicleDeleteOne

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

VehicleDeleteOne is the builder for deleting a single Vehicle entity.

func (*VehicleDeleteOne) Exec

func (vdo *VehicleDeleteOne) Exec(ctx context.Context) error

Exec executes the deletion query.

func (*VehicleDeleteOne) ExecX

func (vdo *VehicleDeleteOne) ExecX(ctx context.Context)

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

type VehicleGroupBy

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

VehicleGroupBy is the group-by builder for Vehicle entities.

func (*VehicleGroupBy) Aggregate

func (vgb *VehicleGroupBy) Aggregate(fns ...AggregateFunc) *VehicleGroupBy

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

func (*VehicleGroupBy) Bool

func (vgb *VehicleGroupBy) 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 (*VehicleGroupBy) BoolX

func (vgb *VehicleGroupBy) BoolX(ctx context.Context) bool

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

func (*VehicleGroupBy) Bools

func (vgb *VehicleGroupBy) 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 (*VehicleGroupBy) BoolsX

func (vgb *VehicleGroupBy) BoolsX(ctx context.Context) []bool

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

func (*VehicleGroupBy) Float64

func (vgb *VehicleGroupBy) 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 (*VehicleGroupBy) Float64X

func (vgb *VehicleGroupBy) Float64X(ctx context.Context) float64

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

func (*VehicleGroupBy) Float64s

func (vgb *VehicleGroupBy) 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 (*VehicleGroupBy) Float64sX

func (vgb *VehicleGroupBy) Float64sX(ctx context.Context) []float64

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

func (*VehicleGroupBy) Int

func (vgb *VehicleGroupBy) 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 (*VehicleGroupBy) IntX

func (vgb *VehicleGroupBy) IntX(ctx context.Context) int

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

func (*VehicleGroupBy) Ints

func (vgb *VehicleGroupBy) 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 (*VehicleGroupBy) IntsX

func (vgb *VehicleGroupBy) IntsX(ctx context.Context) []int

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

func (*VehicleGroupBy) Scan

func (vgb *VehicleGroupBy) Scan(ctx context.Context, v interface{}) error

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

func (*VehicleGroupBy) ScanX

func (vgb *VehicleGroupBy) ScanX(ctx context.Context, v interface{})

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

func (*VehicleGroupBy) String

func (vgb *VehicleGroupBy) 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 (*VehicleGroupBy) StringX

func (vgb *VehicleGroupBy) StringX(ctx context.Context) string

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

func (*VehicleGroupBy) Strings

func (vgb *VehicleGroupBy) 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 (*VehicleGroupBy) StringsX

func (vgb *VehicleGroupBy) StringsX(ctx context.Context) []string

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

type VehicleMutation

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

VehicleMutation represents an operation that mutates the Vehicle nodes in the graph.

func (*VehicleMutation) Active added in v0.2.0

func (m *VehicleMutation) Active() (r bool, exists bool)

Active returns the value of the "active" field in the mutation.

func (*VehicleMutation) ActiveCleared added in v0.3.0

func (m *VehicleMutation) ActiveCleared() bool

ActiveCleared returns if the "active" field was cleared in this mutation.

func (*VehicleMutation) AddField

func (m *VehicleMutation) 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 (*VehicleMutation) AddMiles added in v0.3.0

func (m *VehicleMutation) AddMiles(i int64)

AddMiles adds i to the "miles" field.

func (*VehicleMutation) AddMpg added in v0.3.0

func (m *VehicleMutation) AddMpg(i int64)

AddMpg adds i to the "mpg" field.

func (*VehicleMutation) AddedEdges

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

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

func (*VehicleMutation) AddedField

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

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

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

func (*VehicleMutation) AddedIDs

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

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

func (*VehicleMutation) AddedMiles added in v0.3.0

func (m *VehicleMutation) AddedMiles() (r int64, exists bool)

AddedMiles returns the value that was added to the "miles" field in this mutation.

func (*VehicleMutation) AddedMpg added in v0.3.0

func (m *VehicleMutation) AddedMpg() (r int64, exists bool)

AddedMpg returns the value that was added to the "mpg" field in this mutation.

func (*VehicleMutation) ClearActive added in v0.3.0

func (m *VehicleMutation) ClearActive()

ClearActive clears the value of the "active" field.

func (*VehicleMutation) ClearCondition added in v0.3.0

func (m *VehicleMutation) ClearCondition()

ClearCondition clears the value of the "condition" field.

func (*VehicleMutation) ClearEdge

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

func (m *VehicleMutation) 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 (*VehicleMutation) ClearMiles added in v0.3.0

func (m *VehicleMutation) ClearMiles()

ClearMiles clears the value of the "miles" field.

func (*VehicleMutation) ClearMpg added in v0.3.0

func (m *VehicleMutation) ClearMpg()

ClearMpg clears the value of the "mpg" field.

func (*VehicleMutation) ClearOwner added in v0.3.0

func (m *VehicleMutation) ClearOwner()

ClearOwner clears the value of the "owner" field.

func (*VehicleMutation) ClearYear added in v0.3.0

func (m *VehicleMutation) ClearYear()

ClearYear clears the value of the "year" field.

func (*VehicleMutation) ClearedEdges

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

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

func (*VehicleMutation) ClearedFields

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

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

func (VehicleMutation) Client

func (m VehicleMutation) 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 (*VehicleMutation) Condition

func (m *VehicleMutation) Condition() (r string, exists bool)

Condition returns the value of the "condition" field in the mutation.

func (*VehicleMutation) ConditionCleared added in v0.3.0

func (m *VehicleMutation) ConditionCleared() bool

ConditionCleared returns if the "condition" field was cleared in this mutation.

func (*VehicleMutation) CreateTime added in v0.3.0

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

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

func (*VehicleMutation) EdgeCleared

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

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

func (*VehicleMutation) Field

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

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

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

func (*VehicleMutation) Fields

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

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

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

func (*VehicleMutation) Make

func (m *VehicleMutation) Make() (r string, exists bool)

Make returns the value of the "make" field in the mutation.

func (*VehicleMutation) Miles added in v0.3.0

func (m *VehicleMutation) Miles() (r int64, exists bool)

Miles returns the value of the "miles" field in the mutation.

func (*VehicleMutation) MilesCleared added in v0.3.0

func (m *VehicleMutation) MilesCleared() bool

MilesCleared returns if the "miles" field was cleared in this mutation.

func (*VehicleMutation) Model

func (m *VehicleMutation) Model() (r string, exists bool)

Model returns the value of the "model" field in the mutation.

func (*VehicleMutation) Mpg added in v0.3.0

func (m *VehicleMutation) Mpg() (r int64, exists bool)

Mpg returns the value of the "mpg" field in the mutation.

func (*VehicleMutation) MpgCleared added in v0.3.0

func (m *VehicleMutation) MpgCleared() bool

MpgCleared returns if the "mpg" field was cleared in this mutation.

func (*VehicleMutation) OldActive added in v0.2.0

func (m *VehicleMutation) OldActive(ctx context.Context) (v bool, err error)

OldActive returns the old "active" field's value of the Vehicle entity. If the Vehicle 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 (*VehicleMutation) OldCondition

func (m *VehicleMutation) OldCondition(ctx context.Context) (v string, err error)

OldCondition returns the old "condition" field's value of the Vehicle entity. If the Vehicle 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 (*VehicleMutation) OldCreateTime added in v0.3.0

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

OldCreateTime returns the old "create_time" field's value of the Vehicle entity. If the Vehicle 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 (*VehicleMutation) OldField

func (m *VehicleMutation) 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 (*VehicleMutation) OldMake

func (m *VehicleMutation) OldMake(ctx context.Context) (v string, err error)

OldMake returns the old "make" field's value of the Vehicle entity. If the Vehicle 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 (*VehicleMutation) OldMiles added in v0.3.0

func (m *VehicleMutation) OldMiles(ctx context.Context) (v int64, err error)

OldMiles returns the old "miles" field's value of the Vehicle entity. If the Vehicle 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 (*VehicleMutation) OldModel

func (m *VehicleMutation) OldModel(ctx context.Context) (v string, err error)

OldModel returns the old "model" field's value of the Vehicle entity. If the Vehicle 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 (*VehicleMutation) OldMpg added in v0.3.0

func (m *VehicleMutation) OldMpg(ctx context.Context) (v int64, err error)

OldMpg returns the old "mpg" field's value of the Vehicle entity. If the Vehicle 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 (*VehicleMutation) OldOwner added in v0.3.0

func (m *VehicleMutation) OldOwner(ctx context.Context) (v string, err error)

OldOwner returns the old "owner" field's value of the Vehicle entity. If the Vehicle 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 (*VehicleMutation) OldUpdateTime added in v0.3.0

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

OldUpdateTime returns the old "update_time" field's value of the Vehicle entity. If the Vehicle 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 (*VehicleMutation) OldYear

func (m *VehicleMutation) OldYear(ctx context.Context) (v string, err error)

OldYear returns the old "year" field's value of the Vehicle entity. If the Vehicle 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 (*VehicleMutation) Op

func (m *VehicleMutation) Op() Op

Op returns the operation name.

func (*VehicleMutation) Owner added in v0.3.0

func (m *VehicleMutation) Owner() (r string, exists bool)

Owner returns the value of the "owner" field in the mutation.

func (*VehicleMutation) OwnerCleared added in v0.3.0

func (m *VehicleMutation) OwnerCleared() bool

OwnerCleared returns if the "owner" field was cleared in this mutation.

func (*VehicleMutation) RemovedEdges

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

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

func (*VehicleMutation) RemovedIDs

func (m *VehicleMutation) 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 (*VehicleMutation) ResetActive added in v0.2.0

func (m *VehicleMutation) ResetActive()

ResetActive resets all changes to the "active" field.

func (*VehicleMutation) ResetCondition

func (m *VehicleMutation) ResetCondition()

ResetCondition resets all changes to the "condition" field.

func (*VehicleMutation) ResetCreateTime added in v0.3.0

func (m *VehicleMutation) ResetCreateTime()

ResetCreateTime resets all changes to the "create_time" field.

func (*VehicleMutation) ResetEdge

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

func (m *VehicleMutation) 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 (*VehicleMutation) ResetMake

func (m *VehicleMutation) ResetMake()

ResetMake resets all changes to the "make" field.

func (*VehicleMutation) ResetMiles added in v0.3.0

func (m *VehicleMutation) ResetMiles()

ResetMiles resets all changes to the "miles" field.

func (*VehicleMutation) ResetModel

func (m *VehicleMutation) ResetModel()

ResetModel resets all changes to the "model" field.

func (*VehicleMutation) ResetMpg added in v0.3.0

func (m *VehicleMutation) ResetMpg()

ResetMpg resets all changes to the "mpg" field.

func (*VehicleMutation) ResetOwner added in v0.3.0

func (m *VehicleMutation) ResetOwner()

ResetOwner resets all changes to the "owner" field.

func (*VehicleMutation) ResetUpdateTime added in v0.3.0

func (m *VehicleMutation) ResetUpdateTime()

ResetUpdateTime resets all changes to the "update_time" field.

func (*VehicleMutation) ResetYear

func (m *VehicleMutation) ResetYear()

ResetYear resets all changes to the "year" field.

func (*VehicleMutation) SetActive added in v0.2.0

func (m *VehicleMutation) SetActive(b bool)

SetActive sets the "active" field.

func (*VehicleMutation) SetCondition

func (m *VehicleMutation) SetCondition(s string)

SetCondition sets the "condition" field.

func (*VehicleMutation) SetCreateTime added in v0.3.0

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

SetCreateTime sets the "create_time" field.

func (*VehicleMutation) SetField

func (m *VehicleMutation) 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 (*VehicleMutation) SetMake

func (m *VehicleMutation) SetMake(s string)

SetMake sets the "make" field.

func (*VehicleMutation) SetMiles added in v0.3.0

func (m *VehicleMutation) SetMiles(i int64)

SetMiles sets the "miles" field.

func (*VehicleMutation) SetModel

func (m *VehicleMutation) SetModel(s string)

SetModel sets the "model" field.

func (*VehicleMutation) SetMpg added in v0.3.0

func (m *VehicleMutation) SetMpg(i int64)

SetMpg sets the "mpg" field.

func (*VehicleMutation) SetOwner added in v0.3.0

func (m *VehicleMutation) SetOwner(s string)

SetOwner sets the "owner" field.

func (*VehicleMutation) SetUpdateTime added in v0.3.0

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

SetUpdateTime sets the "update_time" field.

func (*VehicleMutation) SetYear

func (m *VehicleMutation) SetYear(s string)

SetYear sets the "year" field.

func (VehicleMutation) Tx

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

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

func (*VehicleMutation) Type

func (m *VehicleMutation) Type() string

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

func (*VehicleMutation) UpdateTime added in v0.3.0

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

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

func (*VehicleMutation) Where

func (m *VehicleMutation) Where(ps ...predicate.Vehicle)

Where appends a list predicates to the VehicleMutation builder.

func (*VehicleMutation) Year

func (m *VehicleMutation) Year() (r string, exists bool)

Year returns the value of the "year" field in the mutation.

func (*VehicleMutation) YearCleared added in v0.3.0

func (m *VehicleMutation) YearCleared() bool

YearCleared returns if the "year" field was cleared in this mutation.

type VehicleQuery

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

VehicleQuery is the builder for querying Vehicle entities.

func (*VehicleQuery) All

func (vq *VehicleQuery) All(ctx context.Context) ([]*Vehicle, error)

All executes the query and returns a list of Vehicles.

func (*VehicleQuery) AllX

func (vq *VehicleQuery) AllX(ctx context.Context) []*Vehicle

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

func (*VehicleQuery) Clone

func (vq *VehicleQuery) Clone() *VehicleQuery

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

func (*VehicleQuery) CollectFields added in v0.3.0

func (v *VehicleQuery) CollectFields(ctx context.Context, satisfies ...string) *VehicleQuery

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

func (*VehicleQuery) Count

func (vq *VehicleQuery) Count(ctx context.Context) (int, error)

Count returns the count of the given query.

func (*VehicleQuery) CountX

func (vq *VehicleQuery) CountX(ctx context.Context) int

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

func (*VehicleQuery) Exist

func (vq *VehicleQuery) Exist(ctx context.Context) (bool, error)

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

func (*VehicleQuery) ExistX

func (vq *VehicleQuery) ExistX(ctx context.Context) bool

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

func (*VehicleQuery) First

func (vq *VehicleQuery) First(ctx context.Context) (*Vehicle, error)

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

func (*VehicleQuery) FirstID

func (vq *VehicleQuery) FirstID(ctx context.Context) (id int, err error)

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

func (*VehicleQuery) FirstIDX

func (vq *VehicleQuery) FirstIDX(ctx context.Context) int

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

func (*VehicleQuery) FirstX

func (vq *VehicleQuery) FirstX(ctx context.Context) *Vehicle

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

func (*VehicleQuery) GroupBy

func (vq *VehicleQuery) GroupBy(field string, fields ...string) *VehicleGroupBy

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.Vehicle.Query().
	GroupBy(vehicle.FieldCreateTime).
	Aggregate(ent.Count()).
	Scan(ctx, &v)

func (*VehicleQuery) IDs

func (vq *VehicleQuery) IDs(ctx context.Context) ([]int, error)

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

func (*VehicleQuery) IDsX

func (vq *VehicleQuery) IDsX(ctx context.Context) []int

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

func (*VehicleQuery) Limit

func (vq *VehicleQuery) Limit(limit int) *VehicleQuery

Limit adds a limit step to the query.

func (*VehicleQuery) Offset

func (vq *VehicleQuery) Offset(offset int) *VehicleQuery

Offset adds an offset step to the query.

func (*VehicleQuery) Only

func (vq *VehicleQuery) Only(ctx context.Context) (*Vehicle, error)

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

func (*VehicleQuery) OnlyID

func (vq *VehicleQuery) OnlyID(ctx context.Context) (id int, err error)

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

func (*VehicleQuery) OnlyIDX

func (vq *VehicleQuery) OnlyIDX(ctx context.Context) int

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

func (*VehicleQuery) OnlyX

func (vq *VehicleQuery) OnlyX(ctx context.Context) *Vehicle

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

func (*VehicleQuery) Order

func (vq *VehicleQuery) Order(o ...OrderFunc) *VehicleQuery

Order adds an order step to the query.

func (*VehicleQuery) Select

func (vq *VehicleQuery) Select(fields ...string) *VehicleSelect

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.Vehicle.Query().
	Select(vehicle.FieldCreateTime).
	Scan(ctx, &v)

func (*VehicleQuery) Unique

func (vq *VehicleQuery) Unique(unique bool) *VehicleQuery

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

func (*VehicleQuery) Where

func (vq *VehicleQuery) Where(ps ...predicate.Vehicle) *VehicleQuery

Where adds a new predicate for the VehicleQuery builder.

type VehicleSelect

type VehicleSelect struct {
	*VehicleQuery
	// contains filtered or unexported fields
}

VehicleSelect is the builder for selecting fields of Vehicle entities.

func (*VehicleSelect) Bool

func (vs *VehicleSelect) Bool(ctx context.Context) (_ bool, err error)

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

func (*VehicleSelect) BoolX

func (vs *VehicleSelect) BoolX(ctx context.Context) bool

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

func (*VehicleSelect) Bools

func (vs *VehicleSelect) Bools(ctx context.Context) ([]bool, error)

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

func (*VehicleSelect) BoolsX

func (vs *VehicleSelect) BoolsX(ctx context.Context) []bool

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

func (*VehicleSelect) Float64

func (vs *VehicleSelect) Float64(ctx context.Context) (_ float64, err error)

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

func (*VehicleSelect) Float64X

func (vs *VehicleSelect) Float64X(ctx context.Context) float64

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

func (*VehicleSelect) Float64s

func (vs *VehicleSelect) Float64s(ctx context.Context) ([]float64, error)

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

func (*VehicleSelect) Float64sX

func (vs *VehicleSelect) Float64sX(ctx context.Context) []float64

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

func (*VehicleSelect) Int

func (vs *VehicleSelect) Int(ctx context.Context) (_ int, err error)

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

func (*VehicleSelect) IntX

func (vs *VehicleSelect) IntX(ctx context.Context) int

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

func (*VehicleSelect) Ints

func (vs *VehicleSelect) Ints(ctx context.Context) ([]int, error)

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

func (*VehicleSelect) IntsX

func (vs *VehicleSelect) IntsX(ctx context.Context) []int

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

func (*VehicleSelect) Scan

func (vs *VehicleSelect) Scan(ctx context.Context, v interface{}) error

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

func (*VehicleSelect) ScanX

func (vs *VehicleSelect) ScanX(ctx context.Context, v interface{})

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

func (*VehicleSelect) String

func (vs *VehicleSelect) String(ctx context.Context) (_ string, err error)

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

func (*VehicleSelect) StringX

func (vs *VehicleSelect) StringX(ctx context.Context) string

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

func (*VehicleSelect) Strings

func (vs *VehicleSelect) Strings(ctx context.Context) ([]string, error)

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

func (*VehicleSelect) StringsX

func (vs *VehicleSelect) StringsX(ctx context.Context) []string

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

type VehicleUpdate

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

VehicleUpdate is the builder for updating Vehicle entities.

func (*VehicleUpdate) AddMiles added in v0.3.0

func (vu *VehicleUpdate) AddMiles(i int64) *VehicleUpdate

AddMiles adds i to the "miles" field.

func (*VehicleUpdate) AddMpg added in v0.3.0

func (vu *VehicleUpdate) AddMpg(i int64) *VehicleUpdate

AddMpg adds i to the "mpg" field.

func (*VehicleUpdate) ClearActive added in v0.3.0

func (vu *VehicleUpdate) ClearActive() *VehicleUpdate

ClearActive clears the value of the "active" field.

func (*VehicleUpdate) ClearCondition added in v0.3.0

func (vu *VehicleUpdate) ClearCondition() *VehicleUpdate

ClearCondition clears the value of the "condition" field.

func (*VehicleUpdate) ClearMiles added in v0.3.0

func (vu *VehicleUpdate) ClearMiles() *VehicleUpdate

ClearMiles clears the value of the "miles" field.

func (*VehicleUpdate) ClearMpg added in v0.3.0

func (vu *VehicleUpdate) ClearMpg() *VehicleUpdate

ClearMpg clears the value of the "mpg" field.

func (*VehicleUpdate) ClearOwner added in v0.3.0

func (vu *VehicleUpdate) ClearOwner() *VehicleUpdate

ClearOwner clears the value of the "owner" field.

func (*VehicleUpdate) ClearYear added in v0.3.0

func (vu *VehicleUpdate) ClearYear() *VehicleUpdate

ClearYear clears the value of the "year" field.

func (*VehicleUpdate) Exec

func (vu *VehicleUpdate) Exec(ctx context.Context) error

Exec executes the query.

func (*VehicleUpdate) ExecX

func (vu *VehicleUpdate) ExecX(ctx context.Context)

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

func (*VehicleUpdate) Mutation

func (vu *VehicleUpdate) Mutation() *VehicleMutation

Mutation returns the VehicleMutation object of the builder.

func (*VehicleUpdate) Save

func (vu *VehicleUpdate) Save(ctx context.Context) (int, error)

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

func (*VehicleUpdate) SaveX

func (vu *VehicleUpdate) SaveX(ctx context.Context) int

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

func (*VehicleUpdate) SetActive added in v0.2.0

func (vu *VehicleUpdate) SetActive(b bool) *VehicleUpdate

SetActive sets the "active" field.

func (*VehicleUpdate) SetCondition

func (vu *VehicleUpdate) SetCondition(s string) *VehicleUpdate

SetCondition sets the "condition" field.

func (*VehicleUpdate) SetCreateTime added in v0.4.0

func (vu *VehicleUpdate) SetCreateTime(t time.Time) *VehicleUpdate

SetCreateTime sets the "create_time" field.

func (*VehicleUpdate) SetMake

func (vu *VehicleUpdate) SetMake(s string) *VehicleUpdate

SetMake sets the "make" field.

func (*VehicleUpdate) SetMiles added in v0.3.0

func (vu *VehicleUpdate) SetMiles(i int64) *VehicleUpdate

SetMiles sets the "miles" field.

func (*VehicleUpdate) SetModel

func (vu *VehicleUpdate) SetModel(s string) *VehicleUpdate

SetModel sets the "model" field.

func (*VehicleUpdate) SetMpg added in v0.3.0

func (vu *VehicleUpdate) SetMpg(i int64) *VehicleUpdate

SetMpg sets the "mpg" field.

func (*VehicleUpdate) SetNillableActive added in v0.3.0

func (vu *VehicleUpdate) SetNillableActive(b *bool) *VehicleUpdate

SetNillableActive sets the "active" field if the given value is not nil.

func (*VehicleUpdate) SetNillableCondition added in v0.3.0

func (vu *VehicleUpdate) SetNillableCondition(s *string) *VehicleUpdate

SetNillableCondition sets the "condition" field if the given value is not nil.

func (*VehicleUpdate) SetNillableCreateTime added in v0.4.0

func (vu *VehicleUpdate) SetNillableCreateTime(t *time.Time) *VehicleUpdate

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

func (*VehicleUpdate) SetNillableMiles added in v0.3.0

func (vu *VehicleUpdate) SetNillableMiles(i *int64) *VehicleUpdate

SetNillableMiles sets the "miles" field if the given value is not nil.

func (*VehicleUpdate) SetNillableMpg added in v0.3.0

func (vu *VehicleUpdate) SetNillableMpg(i *int64) *VehicleUpdate

SetNillableMpg sets the "mpg" field if the given value is not nil.

func (*VehicleUpdate) SetNillableOwner added in v0.3.0

func (vu *VehicleUpdate) SetNillableOwner(s *string) *VehicleUpdate

SetNillableOwner sets the "owner" field if the given value is not nil.

func (*VehicleUpdate) SetNillableYear added in v0.3.0

func (vu *VehicleUpdate) SetNillableYear(s *string) *VehicleUpdate

SetNillableYear sets the "year" field if the given value is not nil.

func (*VehicleUpdate) SetOwner added in v0.3.0

func (vu *VehicleUpdate) SetOwner(s string) *VehicleUpdate

SetOwner sets the "owner" field.

func (*VehicleUpdate) SetUpdateTime added in v0.3.0

func (vu *VehicleUpdate) SetUpdateTime(t time.Time) *VehicleUpdate

SetUpdateTime sets the "update_time" field.

func (*VehicleUpdate) SetYear

func (vu *VehicleUpdate) SetYear(s string) *VehicleUpdate

SetYear sets the "year" field.

func (*VehicleUpdate) Where

func (vu *VehicleUpdate) Where(ps ...predicate.Vehicle) *VehicleUpdate

Where appends a list predicates to the VehicleUpdate builder.

type VehicleUpdateOne

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

VehicleUpdateOne is the builder for updating a single Vehicle entity.

func (*VehicleUpdateOne) AddMiles added in v0.3.0

func (vuo *VehicleUpdateOne) AddMiles(i int64) *VehicleUpdateOne

AddMiles adds i to the "miles" field.

func (*VehicleUpdateOne) AddMpg added in v0.3.0

func (vuo *VehicleUpdateOne) AddMpg(i int64) *VehicleUpdateOne

AddMpg adds i to the "mpg" field.

func (*VehicleUpdateOne) ClearActive added in v0.3.0

func (vuo *VehicleUpdateOne) ClearActive() *VehicleUpdateOne

ClearActive clears the value of the "active" field.

func (*VehicleUpdateOne) ClearCondition added in v0.3.0

func (vuo *VehicleUpdateOne) ClearCondition() *VehicleUpdateOne

ClearCondition clears the value of the "condition" field.

func (*VehicleUpdateOne) ClearMiles added in v0.3.0

func (vuo *VehicleUpdateOne) ClearMiles() *VehicleUpdateOne

ClearMiles clears the value of the "miles" field.

func (*VehicleUpdateOne) ClearMpg added in v0.3.0

func (vuo *VehicleUpdateOne) ClearMpg() *VehicleUpdateOne

ClearMpg clears the value of the "mpg" field.

func (*VehicleUpdateOne) ClearOwner added in v0.3.0

func (vuo *VehicleUpdateOne) ClearOwner() *VehicleUpdateOne

ClearOwner clears the value of the "owner" field.

func (*VehicleUpdateOne) ClearYear added in v0.3.0

func (vuo *VehicleUpdateOne) ClearYear() *VehicleUpdateOne

ClearYear clears the value of the "year" field.

func (*VehicleUpdateOne) Exec

func (vuo *VehicleUpdateOne) Exec(ctx context.Context) error

Exec executes the query on the entity.

func (*VehicleUpdateOne) ExecX

func (vuo *VehicleUpdateOne) ExecX(ctx context.Context)

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

func (*VehicleUpdateOne) Mutation

func (vuo *VehicleUpdateOne) Mutation() *VehicleMutation

Mutation returns the VehicleMutation object of the builder.

func (*VehicleUpdateOne) Save

func (vuo *VehicleUpdateOne) Save(ctx context.Context) (*Vehicle, error)

Save executes the query and returns the updated Vehicle entity.

func (*VehicleUpdateOne) SaveX

func (vuo *VehicleUpdateOne) SaveX(ctx context.Context) *Vehicle

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

func (*VehicleUpdateOne) Select

func (vuo *VehicleUpdateOne) Select(field string, fields ...string) *VehicleUpdateOne

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

func (*VehicleUpdateOne) SetActive added in v0.2.0

func (vuo *VehicleUpdateOne) SetActive(b bool) *VehicleUpdateOne

SetActive sets the "active" field.

func (*VehicleUpdateOne) SetCondition

func (vuo *VehicleUpdateOne) SetCondition(s string) *VehicleUpdateOne

SetCondition sets the "condition" field.

func (*VehicleUpdateOne) SetCreateTime added in v0.4.0

func (vuo *VehicleUpdateOne) SetCreateTime(t time.Time) *VehicleUpdateOne

SetCreateTime sets the "create_time" field.

func (*VehicleUpdateOne) SetMake

func (vuo *VehicleUpdateOne) SetMake(s string) *VehicleUpdateOne

SetMake sets the "make" field.

func (*VehicleUpdateOne) SetMiles added in v0.3.0

func (vuo *VehicleUpdateOne) SetMiles(i int64) *VehicleUpdateOne

SetMiles sets the "miles" field.

func (*VehicleUpdateOne) SetModel

func (vuo *VehicleUpdateOne) SetModel(s string) *VehicleUpdateOne

SetModel sets the "model" field.

func (*VehicleUpdateOne) SetMpg added in v0.3.0

func (vuo *VehicleUpdateOne) SetMpg(i int64) *VehicleUpdateOne

SetMpg sets the "mpg" field.

func (*VehicleUpdateOne) SetNillableActive added in v0.3.0

func (vuo *VehicleUpdateOne) SetNillableActive(b *bool) *VehicleUpdateOne

SetNillableActive sets the "active" field if the given value is not nil.

func (*VehicleUpdateOne) SetNillableCondition added in v0.3.0

func (vuo *VehicleUpdateOne) SetNillableCondition(s *string) *VehicleUpdateOne

SetNillableCondition sets the "condition" field if the given value is not nil.

func (*VehicleUpdateOne) SetNillableCreateTime added in v0.4.0

func (vuo *VehicleUpdateOne) SetNillableCreateTime(t *time.Time) *VehicleUpdateOne

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

func (*VehicleUpdateOne) SetNillableMiles added in v0.3.0

func (vuo *VehicleUpdateOne) SetNillableMiles(i *int64) *VehicleUpdateOne

SetNillableMiles sets the "miles" field if the given value is not nil.

func (*VehicleUpdateOne) SetNillableMpg added in v0.3.0

func (vuo *VehicleUpdateOne) SetNillableMpg(i *int64) *VehicleUpdateOne

SetNillableMpg sets the "mpg" field if the given value is not nil.

func (*VehicleUpdateOne) SetNillableOwner added in v0.3.0

func (vuo *VehicleUpdateOne) SetNillableOwner(s *string) *VehicleUpdateOne

SetNillableOwner sets the "owner" field if the given value is not nil.

func (*VehicleUpdateOne) SetNillableYear added in v0.3.0

func (vuo *VehicleUpdateOne) SetNillableYear(s *string) *VehicleUpdateOne

SetNillableYear sets the "year" field if the given value is not nil.

func (*VehicleUpdateOne) SetOwner added in v0.3.0

func (vuo *VehicleUpdateOne) SetOwner(s string) *VehicleUpdateOne

SetOwner sets the "owner" field.

func (*VehicleUpdateOne) SetUpdateTime added in v0.3.0

func (vuo *VehicleUpdateOne) SetUpdateTime(t time.Time) *VehicleUpdateOne

SetUpdateTime sets the "update_time" field.

func (*VehicleUpdateOne) SetYear

func (vuo *VehicleUpdateOne) SetYear(s string) *VehicleUpdateOne

SetYear sets the "year" field.

type Vehicles

type Vehicles []*Vehicle

Vehicles is a parsable slice of Vehicle.

Directories

Path Synopsis
proto
entpb
Code generated by protoc-gen-entgrpc.
Code generated by protoc-gen-entgrpc.

Jump to

Keyboard shortcuts

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