entc/gen: fix grammar and language usage in function comments (#1126)

* fix grammar and english usage in templates

* bindata gen

* codegen

* go generate ./again...
This commit is contained in:
Nathaniel Peiffer
2021-01-04 23:34:40 +11:00
committed by GitHub
parent 7afc24826b
commit b8b82f80a4
633 changed files with 15512 additions and 15072 deletions

View File

@@ -112,20 +112,20 @@ func (c *Card) assignValues(columns []string, values []interface{}) error {
return nil
}
// QueryOwner queries the owner edge of the Card.
// QueryOwner queries the "owner" edge of the Card entity.
func (c *Card) QueryOwner() *UserQuery {
return (&CardClient{config: c.config}).QueryOwner(c)
}
// Update returns a builder for updating this Card.
// Note that, you need to call Card.Unwrap() before calling this method, if this Card
// Note that you need to call Card.Unwrap() before calling this method if this Card
// was returned from a transaction, and the transaction was committed or rolled back.
func (c *Card) Update() *CardUpdateOne {
return (&CardClient{config: c.config}).UpdateOne(c)
}
// Unwrap unwraps the entity that was returned from a transaction after it was closed,
// so that all next queries will be executed through the driver which created the transaction.
// Unwrap unwraps the Card 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 (c *Card) Unwrap() *Card {
tx, ok := c.config.driver.(*txDriver)
if !ok {

View File

@@ -14,7 +14,7 @@ import (
"github.com/facebook/ent/examples/o2o2types/ent/predicate"
)
// ID filters vertices based on their identifier.
// ID filters vertices based on their ID field.
func ID(id int) predicate.Card {
return predicate.Card(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
@@ -326,7 +326,7 @@ func HasOwnerWith(preds ...predicate.User) predicate.Card {
})
}
// And groups list of predicates with the AND operator between them.
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.Card) predicate.Card {
return predicate.Card(func(s *sql.Selector) {
s1 := s.Clone().SetP(nil)
@@ -337,7 +337,7 @@ func And(predicates ...predicate.Card) predicate.Card {
})
}
// Or groups list of predicates with the OR operator between them.
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.Card) predicate.Card {
return predicate.Card(func(s *sql.Selector) {
s1 := s.Clone().SetP(nil)

View File

@@ -25,25 +25,25 @@ type CardCreate struct {
hooks []Hook
}
// SetExpired sets the expired field.
// SetExpired sets the "expired" field.
func (cc *CardCreate) SetExpired(t time.Time) *CardCreate {
cc.mutation.SetExpired(t)
return cc
}
// SetNumber sets the number field.
// SetNumber sets the "number" field.
func (cc *CardCreate) SetNumber(s string) *CardCreate {
cc.mutation.SetNumber(s)
return cc
}
// SetOwnerID sets the owner edge to User by id.
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (cc *CardCreate) SetOwnerID(id int) *CardCreate {
cc.mutation.SetOwnerID(id)
return cc
}
// SetOwner sets the owner edge to User.
// SetOwner sets the "owner" edge to the User entity.
func (cc *CardCreate) SetOwner(u *User) *CardCreate {
return cc.SetOwnerID(u.ID)
}
@@ -173,7 +173,7 @@ func (cc *CardCreate) createSpec() (*Card, *sqlgraph.CreateSpec) {
return _node, _spec
}
// CardCreateBulk is the builder for creating a bulk of Card entities.
// CardCreateBulk is the builder for creating many Card entities in bulk.
type CardCreateBulk struct {
config
builders []*CardCreate
@@ -230,7 +230,7 @@ func (ccb *CardCreateBulk) Save(ctx context.Context) ([]*Card, error) {
return nodes, nil
}
// SaveX calls Save and panics if Save returns an error.
// SaveX is like Save, but panics if an error occurs.
func (ccb *CardCreateBulk) SaveX(ctx context.Context) []*Card {
v, err := ccb.Save(ctx)
if err != nil {

View File

@@ -24,7 +24,7 @@ type CardDelete struct {
mutation *CardMutation
}
// Where adds a new predicate to the delete builder.
// Where adds a new predicate to the CardDelete builder.
func (cd *CardDelete) Where(ps ...predicate.Card) *CardDelete {
cd.mutation.predicates = append(cd.mutation.predicates, ps...)
return cd

View File

@@ -36,7 +36,7 @@ type CardQuery struct {
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the builder.
// Where adds a new predicate for the CardQuery builder.
func (cq *CardQuery) Where(ps ...predicate.Card) *CardQuery {
cq.predicates = append(cq.predicates, ps...)
return cq
@@ -60,7 +60,7 @@ func (cq *CardQuery) Order(o ...OrderFunc) *CardQuery {
return cq
}
// QueryOwner chains the current query on the owner edge.
// QueryOwner chains the current query on the "owner" edge.
func (cq *CardQuery) QueryOwner() *UserQuery {
query := &UserQuery{config: cq.config}
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
@@ -82,7 +82,8 @@ func (cq *CardQuery) QueryOwner() *UserQuery {
return query
}
// First returns the first Card entity in the query. Returns *NotFoundError when no card was found.
// First returns the first Card entity from the query.
// Returns a *NotFoundError when no Card was found.
func (cq *CardQuery) First(ctx context.Context) (*Card, error) {
nodes, err := cq.Limit(1).All(ctx)
if err != nil {
@@ -103,7 +104,8 @@ func (cq *CardQuery) FirstX(ctx context.Context) *Card {
return node
}
// FirstID returns the first Card id in the query. Returns *NotFoundError when no id was found.
// FirstID returns the first Card ID from the query.
// Returns a *NotFoundError when no Card ID was found.
func (cq *CardQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = cq.Limit(1).IDs(ctx); err != nil {
@@ -125,7 +127,9 @@ func (cq *CardQuery) FirstIDX(ctx context.Context) int {
return id
}
// Only returns the only Card entity in the query, returns an error if not exactly one entity was returned.
// Only returns a single Card entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when exactly one Card entity is not found.
// Returns a *NotFoundError when no Card entities are found.
func (cq *CardQuery) Only(ctx context.Context) (*Card, error) {
nodes, err := cq.Limit(2).All(ctx)
if err != nil {
@@ -150,7 +154,9 @@ func (cq *CardQuery) OnlyX(ctx context.Context) *Card {
return node
}
// OnlyID returns the only Card id in the query, returns an error if not exactly one id was returned.
// OnlyID is like Only, but returns the only Card ID in the query.
// Returns a *NotSingularError when exactly one Card ID is not found.
// Returns a *NotFoundError when no entities are found.
func (cq *CardQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = cq.Limit(2).IDs(ctx); err != nil {
@@ -193,7 +199,7 @@ func (cq *CardQuery) AllX(ctx context.Context) []*Card {
return nodes
}
// IDs executes the query and returns a list of Card ids.
// IDs executes the query and returns a list of Card IDs.
func (cq *CardQuery) IDs(ctx context.Context) ([]int, error) {
var ids []int
if err := cq.Select(card.FieldID).Scan(ctx, &ids); err != nil {
@@ -245,7 +251,7 @@ func (cq *CardQuery) ExistX(ctx context.Context) bool {
return exist
}
// Clone returns a duplicate of the query builder, including all associated steps. It can be
// Clone returns a duplicate of the CardQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (cq *CardQuery) Clone() *CardQuery {
if cq == nil {
@@ -264,8 +270,8 @@ func (cq *CardQuery) Clone() *CardQuery {
}
}
// WithOwner tells the query-builder to eager-loads the nodes that are connected to
// the "owner" edge. The optional arguments used to configure the query builder of the edge.
// WithOwner tells the query-builder to eager-load the nodes that are connected to
// the "owner" edge. The optional arguments are used to configure the query builder of the edge.
func (cq *CardQuery) WithOwner(opts ...func(*UserQuery)) *CardQuery {
query := &UserQuery{config: cq.config}
for _, opt := range opts {
@@ -275,7 +281,7 @@ func (cq *CardQuery) WithOwner(opts ...func(*UserQuery)) *CardQuery {
return cq
}
// GroupBy used to group vertices by one or more fields/columns.
// 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:
@@ -302,7 +308,8 @@ func (cq *CardQuery) GroupBy(field string, fields ...string) *CardGroupBy {
return group
}
// Select one or more fields from the given query.
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
@@ -481,7 +488,7 @@ func (cq *CardQuery) sqlQuery() *sql.Selector {
return selector
}
// CardGroupBy is the builder for group-by Card entities.
// CardGroupBy is the group-by builder for Card entities.
type CardGroupBy struct {
config
fields []string
@@ -497,7 +504,7 @@ func (cgb *CardGroupBy) Aggregate(fns ...AggregateFunc) *CardGroupBy {
return cgb
}
// Scan applies the group-by query and scan the result into the given value.
// Scan applies the group-by query and scans the result into the given value.
func (cgb *CardGroupBy) Scan(ctx context.Context, v interface{}) error {
query, err := cgb.path(ctx)
if err != nil {
@@ -514,7 +521,8 @@ func (cgb *CardGroupBy) ScanX(ctx context.Context, v interface{}) {
}
}
// Strings returns list of strings from group-by. It is only allowed when querying group-by with one field.
// Strings returns list of strings from group-by.
// It is only allowed when executing a group-by query with one field.
func (cgb *CardGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(cgb.fields) > 1 {
return nil, errors.New("ent: CardGroupBy.Strings is not achievable when grouping more than 1 field")
@@ -535,7 +543,8 @@ func (cgb *CardGroupBy) StringsX(ctx context.Context) []string {
return v
}
// String returns a single string from group-by. It is only allowed when querying group-by with one field.
// String returns a single string from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (cgb *CardGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = cgb.Strings(ctx); err != nil {
@@ -561,7 +570,8 @@ func (cgb *CardGroupBy) StringX(ctx context.Context) string {
return v
}
// Ints returns list of ints from group-by. It is only allowed when querying group-by with one field.
// Ints returns list of ints from group-by.
// It is only allowed when executing a group-by query with one field.
func (cgb *CardGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(cgb.fields) > 1 {
return nil, errors.New("ent: CardGroupBy.Ints is not achievable when grouping more than 1 field")
@@ -582,7 +592,8 @@ func (cgb *CardGroupBy) IntsX(ctx context.Context) []int {
return v
}
// Int returns a single int from group-by. It is only allowed when querying group-by with one field.
// Int returns a single int from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (cgb *CardGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = cgb.Ints(ctx); err != nil {
@@ -608,7 +619,8 @@ func (cgb *CardGroupBy) IntX(ctx context.Context) int {
return v
}
// Float64s returns list of float64s from group-by. It is only allowed when querying group-by with one field.
// Float64s returns list of float64s from group-by.
// It is only allowed when executing a group-by query with one field.
func (cgb *CardGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(cgb.fields) > 1 {
return nil, errors.New("ent: CardGroupBy.Float64s is not achievable when grouping more than 1 field")
@@ -629,7 +641,8 @@ func (cgb *CardGroupBy) Float64sX(ctx context.Context) []float64 {
return v
}
// Float64 returns a single float64 from group-by. It is only allowed when querying group-by with one field.
// Float64 returns a single float64 from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (cgb *CardGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = cgb.Float64s(ctx); err != nil {
@@ -655,7 +668,8 @@ func (cgb *CardGroupBy) Float64X(ctx context.Context) float64 {
return v
}
// Bools returns list of bools from group-by. It is only allowed when querying group-by with one field.
// Bools returns list of bools from group-by.
// It is only allowed when executing a group-by query with one field.
func (cgb *CardGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(cgb.fields) > 1 {
return nil, errors.New("ent: CardGroupBy.Bools is not achievable when grouping more than 1 field")
@@ -676,7 +690,8 @@ func (cgb *CardGroupBy) BoolsX(ctx context.Context) []bool {
return v
}
// Bool returns a single bool from group-by. It is only allowed when querying group-by with one field.
// Bool returns a single bool from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (cgb *CardGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = cgb.Bools(ctx); err != nil {
@@ -731,14 +746,14 @@ func (cgb *CardGroupBy) sqlQuery() *sql.Selector {
return selector.Select(columns...).GroupBy(cgb.fields...)
}
// CardSelect is the builder for select fields of Card entities.
// CardSelect is the builder for selecting fields of Card entities.
type CardSelect struct {
*CardQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
// Scan applies the selector query and scan the result into the given value.
// Scan applies the selector query and scans the result into the given value.
func (cs *CardSelect) Scan(ctx context.Context, v interface{}) error {
if err := cs.prepareQuery(ctx); err != nil {
return err
@@ -754,7 +769,7 @@ func (cs *CardSelect) ScanX(ctx context.Context, v interface{}) {
}
}
// Strings returns list of strings from selector. It is only allowed when selecting one field.
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (cs *CardSelect) Strings(ctx context.Context) ([]string, error) {
if len(cs.fields) > 1 {
return nil, errors.New("ent: CardSelect.Strings is not achievable when selecting more than 1 field")
@@ -775,7 +790,7 @@ func (cs *CardSelect) StringsX(ctx context.Context) []string {
return v
}
// String returns a single string from selector. It is only allowed when selecting one field.
// String returns a single string from a selector. It is only allowed when selecting one field.
func (cs *CardSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = cs.Strings(ctx); err != nil {
@@ -801,7 +816,7 @@ func (cs *CardSelect) StringX(ctx context.Context) string {
return v
}
// Ints returns list of ints from selector. It is only allowed when selecting one field.
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (cs *CardSelect) Ints(ctx context.Context) ([]int, error) {
if len(cs.fields) > 1 {
return nil, errors.New("ent: CardSelect.Ints is not achievable when selecting more than 1 field")
@@ -822,7 +837,7 @@ func (cs *CardSelect) IntsX(ctx context.Context) []int {
return v
}
// Int returns a single int from selector. It is only allowed when selecting one field.
// Int returns a single int from a selector. It is only allowed when selecting one field.
func (cs *CardSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = cs.Ints(ctx); err != nil {
@@ -848,7 +863,7 @@ func (cs *CardSelect) IntX(ctx context.Context) int {
return v
}
// Float64s returns list of float64s from selector. It is only allowed when selecting one field.
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (cs *CardSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(cs.fields) > 1 {
return nil, errors.New("ent: CardSelect.Float64s is not achievable when selecting more than 1 field")
@@ -869,7 +884,7 @@ func (cs *CardSelect) Float64sX(ctx context.Context) []float64 {
return v
}
// Float64 returns a single float64 from selector. It is only allowed when selecting one field.
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (cs *CardSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = cs.Float64s(ctx); err != nil {
@@ -895,7 +910,7 @@ func (cs *CardSelect) Float64X(ctx context.Context) float64 {
return v
}
// Bools returns list of bools from selector. It is only allowed when selecting one field.
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (cs *CardSelect) Bools(ctx context.Context) ([]bool, error) {
if len(cs.fields) > 1 {
return nil, errors.New("ent: CardSelect.Bools is not achievable when selecting more than 1 field")
@@ -916,7 +931,7 @@ func (cs *CardSelect) BoolsX(ctx context.Context) []bool {
return v
}
// Bool returns a single bool from selector. It is only allowed when selecting one field.
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (cs *CardSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = cs.Bools(ctx); err != nil {

View File

@@ -27,31 +27,31 @@ type CardUpdate struct {
mutation *CardMutation
}
// Where adds a new predicate for the builder.
// Where adds a new predicate for the CardUpdate builder.
func (cu *CardUpdate) Where(ps ...predicate.Card) *CardUpdate {
cu.mutation.predicates = append(cu.mutation.predicates, ps...)
return cu
}
// SetExpired sets the expired field.
// SetExpired sets the "expired" field.
func (cu *CardUpdate) SetExpired(t time.Time) *CardUpdate {
cu.mutation.SetExpired(t)
return cu
}
// SetNumber sets the number field.
// SetNumber sets the "number" field.
func (cu *CardUpdate) SetNumber(s string) *CardUpdate {
cu.mutation.SetNumber(s)
return cu
}
// SetOwnerID sets the owner edge to User by id.
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (cu *CardUpdate) SetOwnerID(id int) *CardUpdate {
cu.mutation.SetOwnerID(id)
return cu
}
// SetOwner sets the owner edge to User.
// SetOwner sets the "owner" edge to the User entity.
func (cu *CardUpdate) SetOwner(u *User) *CardUpdate {
return cu.SetOwnerID(u.ID)
}
@@ -61,7 +61,7 @@ func (cu *CardUpdate) Mutation() *CardMutation {
return cu.mutation
}
// ClearOwner clears the "owner" edge to type User.
// ClearOwner clears the "owner" edge to the User entity.
func (cu *CardUpdate) ClearOwner() *CardUpdate {
cu.mutation.ClearOwner()
return cu
@@ -217,25 +217,25 @@ type CardUpdateOne struct {
mutation *CardMutation
}
// SetExpired sets the expired field.
// SetExpired sets the "expired" field.
func (cuo *CardUpdateOne) SetExpired(t time.Time) *CardUpdateOne {
cuo.mutation.SetExpired(t)
return cuo
}
// SetNumber sets the number field.
// SetNumber sets the "number" field.
func (cuo *CardUpdateOne) SetNumber(s string) *CardUpdateOne {
cuo.mutation.SetNumber(s)
return cuo
}
// SetOwnerID sets the owner edge to User by id.
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (cuo *CardUpdateOne) SetOwnerID(id int) *CardUpdateOne {
cuo.mutation.SetOwnerID(id)
return cuo
}
// SetOwner sets the owner edge to User.
// SetOwner sets the "owner" edge to the User entity.
func (cuo *CardUpdateOne) SetOwner(u *User) *CardUpdateOne {
return cuo.SetOwnerID(u.ID)
}
@@ -245,13 +245,13 @@ func (cuo *CardUpdateOne) Mutation() *CardMutation {
return cuo.mutation
}
// ClearOwner clears the "owner" edge to type User.
// ClearOwner clears the "owner" edge to the User entity.
func (cuo *CardUpdateOne) ClearOwner() *CardUpdateOne {
cuo.mutation.ClearOwner()
return cuo
}
// Save executes the query and returns the updated entity.
// Save executes the query and returns the updated Card entity.
func (cuo *CardUpdateOne) Save(ctx context.Context) (*Card, error) {
var (
err error

View File

@@ -82,7 +82,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
}, nil
}
// BeginTx returns a transactional client with options.
// BeginTx returns a transactional client with specified options.
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
if _, ok := c.driver.(*txDriver); ok {
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")

View File

@@ -12,7 +12,7 @@ import (
type clientCtxKey struct{}
// FromContext returns the Client stored in a context, or nil if there isn't one.
// FromContext returns a Client stored inside a context, or nil if there isn't one.
func FromContext(ctx context.Context) *Client {
c, _ := ctx.Value(clientCtxKey{}).(*Client)
return c
@@ -25,13 +25,13 @@ func NewContext(parent context.Context, c *Client) context.Context {
type txCtxKey struct{}
// TxFromContext returns the Tx stored in a context, or nil if there isn't one.
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
func TxFromContext(ctx context.Context) *Tx {
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
return tx
}
// NewTxContext returns a new context with the given Client attached.
// NewTxContext returns a new context with the given Tx attached.
func NewTxContext(parent context.Context, tx *Tx) context.Context {
return context.WithValue(parent, txCtxKey{}, tx)
}

View File

@@ -17,7 +17,7 @@ import (
"github.com/facebook/ent/dialect/sql/sqlgraph"
)
// ent aliases to avoid import conflict in user's code.
// ent aliases to avoid import conflicts in user's code.
type (
Op = ent.Op
Hook = ent.Hook
@@ -262,7 +262,7 @@ func isSQLConstraintError(err error) (*ConstraintError, bool) {
return nil, false
}
// rollback calls to tx.Rollback and wraps the given error with the rollback error if occurred.
// rollback calls tx.Rollback and wraps the given error with the rollback error if present.
func rollback(tx dialect.Tx, err error) error {
if rerr := tx.Rollback(); rerr != nil {
err = fmt.Errorf("%s: %v", err.Error(), rerr)

View File

@@ -32,8 +32,7 @@ const (
TypeUser = "User"
)
// CardMutation represents an operation that mutate the Cards
// nodes in the graph.
// CardMutation represents an operation that mutates the Card nodes in the graph.
type CardMutation struct {
config
op Op
@@ -51,10 +50,10 @@ type CardMutation struct {
var _ ent.Mutation = (*CardMutation)(nil)
// cardOption allows to manage the mutation configuration using functional options.
// cardOption allows management of the mutation configuration using functional options.
type cardOption func(*CardMutation)
// newCardMutation creates new mutation for Card.
// newCardMutation creates new mutation for the Card entity.
func newCardMutation(c config, op Op, opts ...cardOption) *CardMutation {
m := &CardMutation{
config: c,
@@ -68,7 +67,7 @@ func newCardMutation(c config, op Op, opts ...cardOption) *CardMutation {
return m
}
// withCardID sets the id field of the mutation.
// withCardID sets the ID field of the mutation.
func withCardID(id int) cardOption {
return func(m *CardMutation) {
var (
@@ -119,8 +118,8 @@ func (m CardMutation) Tx() (*Tx, error) {
return tx, nil
}
// ID returns the id value in the mutation. Note that, the id
// is available only if it was provided to the builder.
// ID returns the ID value in the mutation. Note that the ID
// is only available if it was provided to the builder.
func (m *CardMutation) ID() (id int, exists bool) {
if m.id == nil {
return
@@ -128,12 +127,12 @@ func (m *CardMutation) ID() (id int, exists bool) {
return *m.id, true
}
// SetExpired sets the expired field.
// SetExpired sets the "expired" field.
func (m *CardMutation) SetExpired(t time.Time) {
m.expired = &t
}
// Expired returns the expired value in the mutation.
// Expired returns the value of the "expired" field in the mutation.
func (m *CardMutation) Expired() (r time.Time, exists bool) {
v := m.expired
if v == nil {
@@ -142,13 +141,12 @@ func (m *CardMutation) Expired() (r time.Time, exists bool) {
return *v, true
}
// OldExpired returns the old expired value of the Card.
// If the Card 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 database query fails.
// OldExpired returns the old "expired" field's value of the Card entity.
// If the Card 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 (m *CardMutation) OldExpired(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldExpired is allowed only on UpdateOne operations")
return v, fmt.Errorf("OldExpired is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldExpired requires an ID field in the mutation")
@@ -160,17 +158,17 @@ func (m *CardMutation) OldExpired(ctx context.Context) (v time.Time, err error)
return oldValue.Expired, nil
}
// ResetExpired reset all changes of the "expired" field.
// ResetExpired resets all changes to the "expired" field.
func (m *CardMutation) ResetExpired() {
m.expired = nil
}
// SetNumber sets the number field.
// SetNumber sets the "number" field.
func (m *CardMutation) SetNumber(s string) {
m.number = &s
}
// Number returns the number value in the mutation.
// Number returns the value of the "number" field in the mutation.
func (m *CardMutation) Number() (r string, exists bool) {
v := m.number
if v == nil {
@@ -179,13 +177,12 @@ func (m *CardMutation) Number() (r string, exists bool) {
return *v, true
}
// OldNumber returns the old number value of the Card.
// If the Card 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 database query fails.
// OldNumber returns the old "number" field's value of the Card entity.
// If the Card 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 (m *CardMutation) OldNumber(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldNumber is allowed only on UpdateOne operations")
return v, fmt.Errorf("OldNumber is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldNumber requires an ID field in the mutation")
@@ -197,27 +194,27 @@ func (m *CardMutation) OldNumber(ctx context.Context) (v string, err error) {
return oldValue.Number, nil
}
// ResetNumber reset all changes of the "number" field.
// ResetNumber resets all changes to the "number" field.
func (m *CardMutation) ResetNumber() {
m.number = nil
}
// SetOwnerID sets the owner edge to User by id.
// SetOwnerID sets the "owner" edge to the User entity by id.
func (m *CardMutation) SetOwnerID(id int) {
m.owner = &id
}
// ClearOwner clears the owner edge to User.
// ClearOwner clears the "owner" edge to the User entity.
func (m *CardMutation) ClearOwner() {
m.clearedowner = true
}
// OwnerCleared returns if the edge owner was cleared.
// OwnerCleared returns if the "owner" edge to the User entity was cleared.
func (m *CardMutation) OwnerCleared() bool {
return m.clearedowner
}
// OwnerID returns the owner id in the mutation.
// OwnerID returns the "owner" edge ID in the mutation.
func (m *CardMutation) OwnerID() (id int, exists bool) {
if m.owner != nil {
return *m.owner, true
@@ -225,8 +222,8 @@ func (m *CardMutation) OwnerID() (id int, exists bool) {
return
}
// OwnerIDs returns the owner ids in the mutation.
// Note that ids always returns len(ids) <= 1 for unique edges, and you should use
// OwnerIDs returns the "owner" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// OwnerID instead. It exists only for internal usage by the builders.
func (m *CardMutation) OwnerIDs() (ids []int) {
if id := m.owner; id != nil {
@@ -235,7 +232,7 @@ func (m *CardMutation) OwnerIDs() (ids []int) {
return
}
// ResetOwner reset all changes of the "owner" edge.
// ResetOwner resets all changes to the "owner" edge.
func (m *CardMutation) ResetOwner() {
m.owner = nil
m.clearedowner = false
@@ -251,9 +248,9 @@ func (m *CardMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during
// this mutation. Note that, in order to get all numeric
// fields that were in/decremented, call AddedFields().
// 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 (m *CardMutation) Fields() []string {
fields := make([]string, 0, 2)
if m.expired != nil {
@@ -265,9 +262,9 @@ func (m *CardMutation) Fields() []string {
return fields
}
// Field returns the value of a field with the given name.
// The second boolean value indicates that this field was
// not set, or was not define in the schema.
// 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 (m *CardMutation) Field(name string) (ent.Value, bool) {
switch name {
case card.FieldExpired:
@@ -278,9 +275,9 @@ func (m *CardMutation) Field(name string) (ent.Value, bool) {
return nil, false
}
// 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 was failed.
// 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 (m *CardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case card.FieldExpired:
@@ -291,9 +288,9 @@ func (m *CardMutation) OldField(ctx context.Context, name string) (ent.Value, er
return nil, fmt.Errorf("unknown Card field %s", name)
}
// SetField sets the value for the given name. It returns an
// error if the field is not defined in the schema, or if the
// type mismatch the field type.
// 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 (m *CardMutation) SetField(name string, value ent.Value) error {
switch name {
case card.FieldExpired:
@@ -314,50 +311,49 @@ func (m *CardMutation) SetField(name string, value ent.Value) error {
return fmt.Errorf("unknown Card field %s", name)
}
// AddedFields returns all numeric fields that were incremented
// or decremented during this mutation.
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *CardMutation) AddedFields() []string {
return nil
}
// AddedField returns the numeric value that was in/decremented
// from a field with the given name. The second value indicates
// that this field was not set, or was not define in the schema.
// 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 (m *CardMutation) AddedField(name string) (ent.Value, bool) {
return nil, false
}
// AddField adds the value for the given name. It returns an
// error if the field is not defined in the schema, or if the
// type mismatch the field type.
// 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 (m *CardMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown Card numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared
// during this mutation.
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *CardMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicates if this field was
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *CardMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value for the given name. It returns an
// 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 (m *CardMutation) ClearField(name string) error {
return fmt.Errorf("unknown Card nullable field %s", name)
}
// ResetField resets all changes in the mutation regarding the
// given field name. It returns an error if the field is not
// defined in the schema.
// 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 (m *CardMutation) ResetField(name string) error {
switch name {
case card.FieldExpired:
@@ -370,8 +366,7 @@ func (m *CardMutation) ResetField(name string) error {
return fmt.Errorf("unknown Card field %s", name)
}
// AddedEdges returns all edge names that were set/added in this
// mutation.
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *CardMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.owner != nil {
@@ -380,8 +375,8 @@ func (m *CardMutation) AddedEdges() []string {
return edges
}
// AddedIDs returns all ids (to other nodes) that were added for
// the given edge name.
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *CardMutation) AddedIDs(name string) []ent.Value {
switch name {
case card.EdgeOwner:
@@ -392,23 +387,21 @@ func (m *CardMutation) AddedIDs(name string) []ent.Value {
return nil
}
// RemovedEdges returns all edge names that were removed in this
// mutation.
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *CardMutation) RemovedEdges() []string {
edges := make([]string, 0, 1)
return edges
}
// RemovedIDs returns all ids (to other nodes) that were removed for
// the given edge name.
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *CardMutation) RemovedIDs(name string) []ent.Value {
switch name {
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this
// mutation.
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *CardMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedowner {
@@ -417,8 +410,8 @@ func (m *CardMutation) ClearedEdges() []string {
return edges
}
// EdgeCleared returns a boolean indicates if this edge was
// cleared in this mutation.
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *CardMutation) EdgeCleared(name string) bool {
switch name {
case card.EdgeOwner:
@@ -427,8 +420,8 @@ func (m *CardMutation) EdgeCleared(name string) bool {
return false
}
// ClearEdge clears the value for the given name. It returns an
// error if the edge name is not defined in the schema.
// 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 (m *CardMutation) ClearEdge(name string) error {
switch name {
case card.EdgeOwner:
@@ -438,9 +431,8 @@ func (m *CardMutation) ClearEdge(name string) error {
return fmt.Errorf("unknown Card unique edge %s", name)
}
// ResetEdge resets all changes in the mutation regarding the
// given edge name. It returns an error if the edge is not
// defined in the schema.
// 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 (m *CardMutation) ResetEdge(name string) error {
switch name {
case card.EdgeOwner:
@@ -450,8 +442,7 @@ func (m *CardMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown Card edge %s", name)
}
// UserMutation represents an operation that mutate the Users
// nodes in the graph.
// UserMutation represents an operation that mutates the User nodes in the graph.
type UserMutation struct {
config
op Op
@@ -470,10 +461,10 @@ type UserMutation struct {
var _ ent.Mutation = (*UserMutation)(nil)
// userOption allows to manage the mutation configuration using functional options.
// userOption allows management of the mutation configuration using functional options.
type userOption func(*UserMutation)
// newUserMutation creates new mutation for User.
// newUserMutation creates new mutation for the User entity.
func newUserMutation(c config, op Op, opts ...userOption) *UserMutation {
m := &UserMutation{
config: c,
@@ -487,7 +478,7 @@ func newUserMutation(c config, op Op, opts ...userOption) *UserMutation {
return m
}
// withUserID sets the id field of the mutation.
// withUserID sets the ID field of the mutation.
func withUserID(id int) userOption {
return func(m *UserMutation) {
var (
@@ -538,8 +529,8 @@ func (m UserMutation) Tx() (*Tx, error) {
return tx, nil
}
// ID returns the id value in the mutation. Note that, the id
// is available only if it was provided to the builder.
// ID returns the ID value in the mutation. Note that the ID
// is only available if it was provided to the builder.
func (m *UserMutation) ID() (id int, exists bool) {
if m.id == nil {
return
@@ -547,13 +538,13 @@ func (m *UserMutation) ID() (id int, exists bool) {
return *m.id, true
}
// SetAge sets the age field.
// SetAge sets the "age" field.
func (m *UserMutation) SetAge(i int) {
m.age = &i
m.addage = nil
}
// Age returns the age value in the mutation.
// Age returns the value of the "age" field in the mutation.
func (m *UserMutation) Age() (r int, exists bool) {
v := m.age
if v == nil {
@@ -562,13 +553,12 @@ func (m *UserMutation) Age() (r int, exists bool) {
return *v, true
}
// OldAge returns the old age value of the User.
// If the User object wasn't provided to the builder, the object is fetched
// from the database.
// An error is returned if the mutation operation is not UpdateOne, or database query fails.
// OldAge returns the old "age" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldAge(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldAge is allowed only on UpdateOne operations")
return v, fmt.Errorf("OldAge is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldAge requires an ID field in the mutation")
@@ -580,7 +570,7 @@ func (m *UserMutation) OldAge(ctx context.Context) (v int, err error) {
return oldValue.Age, nil
}
// AddAge adds i to age.
// AddAge adds i to the "age" field.
func (m *UserMutation) AddAge(i int) {
if m.addage != nil {
*m.addage += i
@@ -589,7 +579,7 @@ func (m *UserMutation) AddAge(i int) {
}
}
// AddedAge returns the value that was added to the age field in this mutation.
// AddedAge returns the value that was added to the "age" field in this mutation.
func (m *UserMutation) AddedAge() (r int, exists bool) {
v := m.addage
if v == nil {
@@ -598,18 +588,18 @@ func (m *UserMutation) AddedAge() (r int, exists bool) {
return *v, true
}
// ResetAge reset all changes of the "age" field.
// ResetAge resets all changes to the "age" field.
func (m *UserMutation) ResetAge() {
m.age = nil
m.addage = nil
}
// SetName sets the name field.
// SetName sets the "name" field.
func (m *UserMutation) SetName(s string) {
m.name = &s
}
// Name returns the name value in the mutation.
// Name returns the value of the "name" field in the mutation.
func (m *UserMutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
@@ -618,13 +608,12 @@ func (m *UserMutation) Name() (r string, exists bool) {
return *v, true
}
// OldName returns the old name value of the User.
// If the User object wasn't provided to the builder, the object is fetched
// from the database.
// An error is returned if the mutation operation is not UpdateOne, or database query fails.
// OldName returns the old "name" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, fmt.Errorf("OldName is allowed only on UpdateOne operations")
return v, fmt.Errorf("OldName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, fmt.Errorf("OldName requires an ID field in the mutation")
@@ -636,27 +625,27 @@ func (m *UserMutation) OldName(ctx context.Context) (v string, err error) {
return oldValue.Name, nil
}
// ResetName reset all changes of the "name" field.
// ResetName resets all changes to the "name" field.
func (m *UserMutation) ResetName() {
m.name = nil
}
// SetCardID sets the card edge to Card by id.
// SetCardID sets the "card" edge to the Card entity by id.
func (m *UserMutation) SetCardID(id int) {
m.card = &id
}
// ClearCard clears the card edge to Card.
// ClearCard clears the "card" edge to the Card entity.
func (m *UserMutation) ClearCard() {
m.clearedcard = true
}
// CardCleared returns if the edge card was cleared.
// CardCleared returns if the "card" edge to the Card entity was cleared.
func (m *UserMutation) CardCleared() bool {
return m.clearedcard
}
// CardID returns the card id in the mutation.
// CardID returns the "card" edge ID in the mutation.
func (m *UserMutation) CardID() (id int, exists bool) {
if m.card != nil {
return *m.card, true
@@ -664,8 +653,8 @@ func (m *UserMutation) CardID() (id int, exists bool) {
return
}
// CardIDs returns the card ids in the mutation.
// Note that ids always returns len(ids) <= 1 for unique edges, and you should use
// CardIDs returns the "card" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// CardID instead. It exists only for internal usage by the builders.
func (m *UserMutation) CardIDs() (ids []int) {
if id := m.card; id != nil {
@@ -674,7 +663,7 @@ func (m *UserMutation) CardIDs() (ids []int) {
return
}
// ResetCard reset all changes of the "card" edge.
// ResetCard resets all changes to the "card" edge.
func (m *UserMutation) ResetCard() {
m.card = nil
m.clearedcard = false
@@ -690,9 +679,9 @@ func (m *UserMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during
// this mutation. Note that, in order to get all numeric
// fields that were in/decremented, call AddedFields().
// 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 (m *UserMutation) Fields() []string {
fields := make([]string, 0, 2)
if m.age != nil {
@@ -704,9 +693,9 @@ func (m *UserMutation) Fields() []string {
return fields
}
// Field returns the value of a field with the given name.
// The second boolean value indicates that this field was
// not set, or was not define in the schema.
// 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 (m *UserMutation) Field(name string) (ent.Value, bool) {
switch name {
case user.FieldAge:
@@ -717,9 +706,9 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) {
return nil, false
}
// 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 was failed.
// 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 (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case user.FieldAge:
@@ -730,9 +719,9 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er
return nil, fmt.Errorf("unknown User field %s", name)
}
// SetField sets the value for the given name. It returns an
// error if the field is not defined in the schema, or if the
// type mismatch the field type.
// 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 (m *UserMutation) SetField(name string, value ent.Value) error {
switch name {
case user.FieldAge:
@@ -753,8 +742,8 @@ func (m *UserMutation) SetField(name string, value ent.Value) error {
return fmt.Errorf("unknown User field %s", name)
}
// AddedFields returns all numeric fields that were incremented
// or decremented during this mutation.
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *UserMutation) AddedFields() []string {
var fields []string
if m.addage != nil {
@@ -763,9 +752,9 @@ func (m *UserMutation) AddedFields() []string {
return fields
}
// AddedField returns the numeric value that was in/decremented
// from a field with the given name. The second value indicates
// that this field was not set, or was not define in the schema.
// 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 (m *UserMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case user.FieldAge:
@@ -774,9 +763,9 @@ func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
return nil, false
}
// AddField adds the value for the given name. It returns an
// error if the field is not defined in the schema, or if the
// type mismatch the field type.
// 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 (m *UserMutation) AddField(name string, value ent.Value) error {
switch name {
case user.FieldAge:
@@ -790,28 +779,27 @@ func (m *UserMutation) AddField(name string, value ent.Value) error {
return fmt.Errorf("unknown User numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared
// during this mutation.
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *UserMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicates if this field was
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *UserMutation) FieldCleared(name string) bool {
_, ok := m.clearedFields[name]
return ok
}
// ClearField clears the value for the given name. It returns an
// 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 (m *UserMutation) ClearField(name string) error {
return fmt.Errorf("unknown User nullable field %s", name)
}
// ResetField resets all changes in the mutation regarding the
// given field name. It returns an error if the field is not
// defined in the schema.
// 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 (m *UserMutation) ResetField(name string) error {
switch name {
case user.FieldAge:
@@ -824,8 +812,7 @@ func (m *UserMutation) ResetField(name string) error {
return fmt.Errorf("unknown User field %s", name)
}
// AddedEdges returns all edge names that were set/added in this
// mutation.
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *UserMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.card != nil {
@@ -834,8 +821,8 @@ func (m *UserMutation) AddedEdges() []string {
return edges
}
// AddedIDs returns all ids (to other nodes) that were added for
// the given edge name.
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *UserMutation) AddedIDs(name string) []ent.Value {
switch name {
case user.EdgeCard:
@@ -846,23 +833,21 @@ func (m *UserMutation) AddedIDs(name string) []ent.Value {
return nil
}
// RemovedEdges returns all edge names that were removed in this
// mutation.
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *UserMutation) RemovedEdges() []string {
edges := make([]string, 0, 1)
return edges
}
// RemovedIDs returns all ids (to other nodes) that were removed for
// the given edge name.
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *UserMutation) RemovedIDs(name string) []ent.Value {
switch name {
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this
// mutation.
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *UserMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedcard {
@@ -871,8 +856,8 @@ func (m *UserMutation) ClearedEdges() []string {
return edges
}
// EdgeCleared returns a boolean indicates if this edge was
// cleared in this mutation.
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *UserMutation) EdgeCleared(name string) bool {
switch name {
case user.EdgeCard:
@@ -881,8 +866,8 @@ func (m *UserMutation) EdgeCleared(name string) bool {
return false
}
// ClearEdge clears the value for the given name. It returns an
// error if the edge name is not defined in the schema.
// 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 (m *UserMutation) ClearEdge(name string) error {
switch name {
case user.EdgeCard:
@@ -892,9 +877,8 @@ func (m *UserMutation) ClearEdge(name string) error {
return fmt.Errorf("unknown User unique edge %s", name)
}
// ResetEdge resets all changes in the mutation regarding the
// given edge name. It returns an error if the edge is not
// defined in the schema.
// 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 (m *UserMutation) ResetEdge(name string) error {
switch name {
case user.EdgeCard:

View File

@@ -99,20 +99,20 @@ func (u *User) assignValues(columns []string, values []interface{}) error {
return nil
}
// QueryCard queries the card edge of the User.
// QueryCard queries the "card" edge of the User entity.
func (u *User) QueryCard() *CardQuery {
return (&UserClient{config: u.config}).QueryCard(u)
}
// Update returns a builder for updating this User.
// Note that, you need to call User.Unwrap() before calling this method, if this User
// Note that you need to call User.Unwrap() before calling this method if this User
// was returned from a transaction, and the transaction was committed or rolled back.
func (u *User) Update() *UserUpdateOne {
return (&UserClient{config: u.config}).UpdateOne(u)
}
// Unwrap unwraps the entity that was returned from a transaction after it was closed,
// so that all next queries will be executed through the driver which created the transaction.
// Unwrap unwraps the User entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (u *User) Unwrap() *User {
tx, ok := u.config.driver.(*txDriver)
if !ok {

View File

@@ -12,7 +12,7 @@ import (
"github.com/facebook/ent/examples/o2o2types/ent/predicate"
)
// ID filters vertices based on their identifier.
// ID filters vertices based on their ID field.
func ID(id int) predicate.User {
return predicate.User(func(s *sql.Selector) {
s.Where(sql.EQ(s.C(FieldID), id))
@@ -324,7 +324,7 @@ func HasCardWith(preds ...predicate.Card) predicate.User {
})
}
// And groups list of predicates with the AND operator between them.
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.User) predicate.User {
return predicate.User(func(s *sql.Selector) {
s1 := s.Clone().SetP(nil)
@@ -335,7 +335,7 @@ func And(predicates ...predicate.User) predicate.User {
})
}
// Or groups list of predicates with the OR operator between them.
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.User) predicate.User {
return predicate.User(func(s *sql.Selector) {
s1 := s.Clone().SetP(nil)

View File

@@ -24,25 +24,25 @@ type UserCreate struct {
hooks []Hook
}
// SetAge sets the age field.
// SetAge sets the "age" field.
func (uc *UserCreate) SetAge(i int) *UserCreate {
uc.mutation.SetAge(i)
return uc
}
// SetName sets the name field.
// SetName sets the "name" field.
func (uc *UserCreate) SetName(s string) *UserCreate {
uc.mutation.SetName(s)
return uc
}
// SetCardID sets the card edge to Card by id.
// SetCardID sets the "card" edge to the Card entity by ID.
func (uc *UserCreate) SetCardID(id int) *UserCreate {
uc.mutation.SetCardID(id)
return uc
}
// SetNillableCardID sets the card edge to Card by id if the given value is not nil.
// SetNillableCardID sets the "card" edge to the Card entity by ID if the given value is not nil.
func (uc *UserCreate) SetNillableCardID(id *int) *UserCreate {
if id != nil {
uc = uc.SetCardID(*id)
@@ -50,7 +50,7 @@ func (uc *UserCreate) SetNillableCardID(id *int) *UserCreate {
return uc
}
// SetCard sets the card edge to Card.
// SetCard sets the "card" edge to the Card entity.
func (uc *UserCreate) SetCard(c *Card) *UserCreate {
return uc.SetCardID(c.ID)
}
@@ -177,7 +177,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
return _node, _spec
}
// UserCreateBulk is the builder for creating a bulk of User entities.
// UserCreateBulk is the builder for creating many User entities in bulk.
type UserCreateBulk struct {
config
builders []*UserCreate
@@ -234,7 +234,7 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
return nodes, nil
}
// SaveX calls Save and panics if Save returns an error.
// SaveX is like Save, but panics if an error occurs.
func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User {
v, err := ucb.Save(ctx)
if err != nil {

View File

@@ -24,7 +24,7 @@ type UserDelete struct {
mutation *UserMutation
}
// Where adds a new predicate to the delete builder.
// Where adds a new predicate to the UserDelete builder.
func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete {
ud.mutation.predicates = append(ud.mutation.predicates, ps...)
return ud

View File

@@ -36,7 +36,7 @@ type UserQuery struct {
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the builder.
// Where adds a new predicate for the UserQuery builder.
func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery {
uq.predicates = append(uq.predicates, ps...)
return uq
@@ -60,7 +60,7 @@ func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery {
return uq
}
// QueryCard chains the current query on the card edge.
// QueryCard chains the current query on the "card" edge.
func (uq *UserQuery) QueryCard() *CardQuery {
query := &CardQuery{config: uq.config}
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
@@ -82,7 +82,8 @@ func (uq *UserQuery) QueryCard() *CardQuery {
return query
}
// First returns the first User entity in the query. Returns *NotFoundError when no user was found.
// First returns the first User entity from the query.
// Returns a *NotFoundError when no User was found.
func (uq *UserQuery) First(ctx context.Context) (*User, error) {
nodes, err := uq.Limit(1).All(ctx)
if err != nil {
@@ -103,7 +104,8 @@ func (uq *UserQuery) FirstX(ctx context.Context) *User {
return node
}
// FirstID returns the first User id in the query. Returns *NotFoundError when no id was found.
// FirstID returns the first User ID from the query.
// Returns a *NotFoundError when no User ID was found.
func (uq *UserQuery) FirstID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = uq.Limit(1).IDs(ctx); err != nil {
@@ -125,7 +127,9 @@ func (uq *UserQuery) FirstIDX(ctx context.Context) int {
return id
}
// Only returns the only User entity in the query, returns an error if not exactly one entity was returned.
// Only returns a single User entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when exactly one User entity is not found.
// Returns a *NotFoundError when no User entities are found.
func (uq *UserQuery) Only(ctx context.Context) (*User, error) {
nodes, err := uq.Limit(2).All(ctx)
if err != nil {
@@ -150,7 +154,9 @@ func (uq *UserQuery) OnlyX(ctx context.Context) *User {
return node
}
// OnlyID returns the only User id in the query, returns an error if not exactly one id was returned.
// OnlyID is like Only, but returns the only User ID in the query.
// Returns a *NotSingularError when exactly one User ID is not found.
// Returns a *NotFoundError when no entities are found.
func (uq *UserQuery) OnlyID(ctx context.Context) (id int, err error) {
var ids []int
if ids, err = uq.Limit(2).IDs(ctx); err != nil {
@@ -193,7 +199,7 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User {
return nodes
}
// IDs executes the query and returns a list of User ids.
// IDs executes the query and returns a list of User IDs.
func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) {
var ids []int
if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil {
@@ -245,7 +251,7 @@ func (uq *UserQuery) ExistX(ctx context.Context) bool {
return exist
}
// Clone returns a duplicate of the query builder, including all associated steps. It can be
// Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (uq *UserQuery) Clone() *UserQuery {
if uq == nil {
@@ -264,8 +270,8 @@ func (uq *UserQuery) Clone() *UserQuery {
}
}
// WithCard tells the query-builder to eager-loads the nodes that are connected to
// the "card" edge. The optional arguments used to configure the query builder of the edge.
// WithCard tells the query-builder to eager-load the nodes that are connected to
// the "card" edge. The optional arguments are used to configure the query builder of the edge.
func (uq *UserQuery) WithCard(opts ...func(*CardQuery)) *UserQuery {
query := &CardQuery{config: uq.config}
for _, opt := range opts {
@@ -275,7 +281,7 @@ func (uq *UserQuery) WithCard(opts ...func(*CardQuery)) *UserQuery {
return uq
}
// GroupBy used to group vertices by one or more fields/columns.
// 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:
@@ -302,7 +308,8 @@ func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy {
return group
}
// Select one or more fields from the given query.
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
@@ -477,7 +484,7 @@ func (uq *UserQuery) sqlQuery() *sql.Selector {
return selector
}
// UserGroupBy is the builder for group-by User entities.
// UserGroupBy is the group-by builder for User entities.
type UserGroupBy struct {
config
fields []string
@@ -493,7 +500,7 @@ func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy {
return ugb
}
// Scan applies the group-by query and scan the result into the given value.
// Scan applies the group-by query and scans the result into the given value.
func (ugb *UserGroupBy) Scan(ctx context.Context, v interface{}) error {
query, err := ugb.path(ctx)
if err != nil {
@@ -510,7 +517,8 @@ func (ugb *UserGroupBy) ScanX(ctx context.Context, v interface{}) {
}
}
// Strings returns list of strings from group-by. It is only allowed when querying group-by with one field.
// Strings returns list of strings from group-by.
// It is only allowed when executing a group-by query with one field.
func (ugb *UserGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(ugb.fields) > 1 {
return nil, errors.New("ent: UserGroupBy.Strings is not achievable when grouping more than 1 field")
@@ -531,7 +539,8 @@ func (ugb *UserGroupBy) StringsX(ctx context.Context) []string {
return v
}
// String returns a single string from group-by. It is only allowed when querying group-by with one field.
// String returns a single string from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (ugb *UserGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = ugb.Strings(ctx); err != nil {
@@ -557,7 +566,8 @@ func (ugb *UserGroupBy) StringX(ctx context.Context) string {
return v
}
// Ints returns list of ints from group-by. It is only allowed when querying group-by with one field.
// Ints returns list of ints from group-by.
// It is only allowed when executing a group-by query with one field.
func (ugb *UserGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(ugb.fields) > 1 {
return nil, errors.New("ent: UserGroupBy.Ints is not achievable when grouping more than 1 field")
@@ -578,7 +588,8 @@ func (ugb *UserGroupBy) IntsX(ctx context.Context) []int {
return v
}
// Int returns a single int from group-by. It is only allowed when querying group-by with one field.
// Int returns a single int from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (ugb *UserGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = ugb.Ints(ctx); err != nil {
@@ -604,7 +615,8 @@ func (ugb *UserGroupBy) IntX(ctx context.Context) int {
return v
}
// Float64s returns list of float64s from group-by. It is only allowed when querying group-by with one field.
// Float64s returns list of float64s from group-by.
// It is only allowed when executing a group-by query with one field.
func (ugb *UserGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(ugb.fields) > 1 {
return nil, errors.New("ent: UserGroupBy.Float64s is not achievable when grouping more than 1 field")
@@ -625,7 +637,8 @@ func (ugb *UserGroupBy) Float64sX(ctx context.Context) []float64 {
return v
}
// Float64 returns a single float64 from group-by. It is only allowed when querying group-by with one field.
// Float64 returns a single float64 from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (ugb *UserGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = ugb.Float64s(ctx); err != nil {
@@ -651,7 +664,8 @@ func (ugb *UserGroupBy) Float64X(ctx context.Context) float64 {
return v
}
// Bools returns list of bools from group-by. It is only allowed when querying group-by with one field.
// Bools returns list of bools from group-by.
// It is only allowed when executing a group-by query with one field.
func (ugb *UserGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(ugb.fields) > 1 {
return nil, errors.New("ent: UserGroupBy.Bools is not achievable when grouping more than 1 field")
@@ -672,7 +686,8 @@ func (ugb *UserGroupBy) BoolsX(ctx context.Context) []bool {
return v
}
// Bool returns a single bool from group-by. It is only allowed when querying group-by with one field.
// Bool returns a single bool from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (ugb *UserGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = ugb.Bools(ctx); err != nil {
@@ -727,14 +742,14 @@ func (ugb *UserGroupBy) sqlQuery() *sql.Selector {
return selector.Select(columns...).GroupBy(ugb.fields...)
}
// UserSelect is the builder for select fields of User entities.
// UserSelect is the builder for selecting fields of User entities.
type UserSelect struct {
*UserQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
// Scan applies the selector query and scan the result into the given value.
// Scan applies the selector query and scans the result into the given value.
func (us *UserSelect) Scan(ctx context.Context, v interface{}) error {
if err := us.prepareQuery(ctx); err != nil {
return err
@@ -750,7 +765,7 @@ func (us *UserSelect) ScanX(ctx context.Context, v interface{}) {
}
}
// Strings returns list of strings from selector. It is only allowed when selecting one field.
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (us *UserSelect) Strings(ctx context.Context) ([]string, error) {
if len(us.fields) > 1 {
return nil, errors.New("ent: UserSelect.Strings is not achievable when selecting more than 1 field")
@@ -771,7 +786,7 @@ func (us *UserSelect) StringsX(ctx context.Context) []string {
return v
}
// String returns a single string from selector. It is only allowed when selecting one field.
// String returns a single string from a selector. It is only allowed when selecting one field.
func (us *UserSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = us.Strings(ctx); err != nil {
@@ -797,7 +812,7 @@ func (us *UserSelect) StringX(ctx context.Context) string {
return v
}
// Ints returns list of ints from selector. It is only allowed when selecting one field.
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (us *UserSelect) Ints(ctx context.Context) ([]int, error) {
if len(us.fields) > 1 {
return nil, errors.New("ent: UserSelect.Ints is not achievable when selecting more than 1 field")
@@ -818,7 +833,7 @@ func (us *UserSelect) IntsX(ctx context.Context) []int {
return v
}
// Int returns a single int from selector. It is only allowed when selecting one field.
// Int returns a single int from a selector. It is only allowed when selecting one field.
func (us *UserSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = us.Ints(ctx); err != nil {
@@ -844,7 +859,7 @@ func (us *UserSelect) IntX(ctx context.Context) int {
return v
}
// Float64s returns list of float64s from selector. It is only allowed when selecting one field.
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (us *UserSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(us.fields) > 1 {
return nil, errors.New("ent: UserSelect.Float64s is not achievable when selecting more than 1 field")
@@ -865,7 +880,7 @@ func (us *UserSelect) Float64sX(ctx context.Context) []float64 {
return v
}
// Float64 returns a single float64 from selector. It is only allowed when selecting one field.
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (us *UserSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = us.Float64s(ctx); err != nil {
@@ -891,7 +906,7 @@ func (us *UserSelect) Float64X(ctx context.Context) float64 {
return v
}
// Bools returns list of bools from selector. It is only allowed when selecting one field.
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (us *UserSelect) Bools(ctx context.Context) ([]bool, error) {
if len(us.fields) > 1 {
return nil, errors.New("ent: UserSelect.Bools is not achievable when selecting more than 1 field")
@@ -912,7 +927,7 @@ func (us *UserSelect) BoolsX(ctx context.Context) []bool {
return v
}
// Bool returns a single bool from selector. It is only allowed when selecting one field.
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (us *UserSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = us.Bools(ctx); err != nil {

View File

@@ -25,38 +25,38 @@ type UserUpdate struct {
mutation *UserMutation
}
// Where adds a new predicate for the builder.
// Where adds a new predicate for the UserUpdate builder.
func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate {
uu.mutation.predicates = append(uu.mutation.predicates, ps...)
return uu
}
// SetAge sets the age field.
// SetAge sets the "age" field.
func (uu *UserUpdate) SetAge(i int) *UserUpdate {
uu.mutation.ResetAge()
uu.mutation.SetAge(i)
return uu
}
// AddAge adds i to age.
// AddAge adds i to the "age" field.
func (uu *UserUpdate) AddAge(i int) *UserUpdate {
uu.mutation.AddAge(i)
return uu
}
// SetName sets the name field.
// SetName sets the "name" field.
func (uu *UserUpdate) SetName(s string) *UserUpdate {
uu.mutation.SetName(s)
return uu
}
// SetCardID sets the card edge to Card by id.
// SetCardID sets the "card" edge to the Card entity by ID.
func (uu *UserUpdate) SetCardID(id int) *UserUpdate {
uu.mutation.SetCardID(id)
return uu
}
// SetNillableCardID sets the card edge to Card by id if the given value is not nil.
// SetNillableCardID sets the "card" edge to the Card entity by ID if the given value is not nil.
func (uu *UserUpdate) SetNillableCardID(id *int) *UserUpdate {
if id != nil {
uu = uu.SetCardID(*id)
@@ -64,7 +64,7 @@ func (uu *UserUpdate) SetNillableCardID(id *int) *UserUpdate {
return uu
}
// SetCard sets the card edge to Card.
// SetCard sets the "card" edge to the Card entity.
func (uu *UserUpdate) SetCard(c *Card) *UserUpdate {
return uu.SetCardID(c.ID)
}
@@ -74,7 +74,7 @@ func (uu *UserUpdate) Mutation() *UserMutation {
return uu.mutation
}
// ClearCard clears the "card" edge to type Card.
// ClearCard clears the "card" edge to the Card entity.
func (uu *UserUpdate) ClearCard() *UserUpdate {
uu.mutation.ClearCard()
return uu
@@ -223,32 +223,32 @@ type UserUpdateOne struct {
mutation *UserMutation
}
// SetAge sets the age field.
// SetAge sets the "age" field.
func (uuo *UserUpdateOne) SetAge(i int) *UserUpdateOne {
uuo.mutation.ResetAge()
uuo.mutation.SetAge(i)
return uuo
}
// AddAge adds i to age.
// AddAge adds i to the "age" field.
func (uuo *UserUpdateOne) AddAge(i int) *UserUpdateOne {
uuo.mutation.AddAge(i)
return uuo
}
// SetName sets the name field.
// SetName sets the "name" field.
func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne {
uuo.mutation.SetName(s)
return uuo
}
// SetCardID sets the card edge to Card by id.
// SetCardID sets the "card" edge to the Card entity by ID.
func (uuo *UserUpdateOne) SetCardID(id int) *UserUpdateOne {
uuo.mutation.SetCardID(id)
return uuo
}
// SetNillableCardID sets the card edge to Card by id if the given value is not nil.
// SetNillableCardID sets the "card" edge to the Card entity by ID if the given value is not nil.
func (uuo *UserUpdateOne) SetNillableCardID(id *int) *UserUpdateOne {
if id != nil {
uuo = uuo.SetCardID(*id)
@@ -256,7 +256,7 @@ func (uuo *UserUpdateOne) SetNillableCardID(id *int) *UserUpdateOne {
return uuo
}
// SetCard sets the card edge to Card.
// SetCard sets the "card" edge to the Card entity.
func (uuo *UserUpdateOne) SetCard(c *Card) *UserUpdateOne {
return uuo.SetCardID(c.ID)
}
@@ -266,13 +266,13 @@ func (uuo *UserUpdateOne) Mutation() *UserMutation {
return uuo.mutation
}
// ClearCard clears the "card" edge to type Card.
// ClearCard clears the "card" edge to the Card entity.
func (uuo *UserUpdateOne) ClearCard() *UserUpdateOne {
uuo.mutation.ClearCard()
return uuo
}
// Save executes the query and returns the updated entity.
// Save executes the query and returns the updated User entity.
func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) {
var (
err error