1
0
api/ent/ma_update.go

942 lines
24 KiB
Go
Raw Normal View History

2024-04-02 09:57:04 +00:00
// Code generated by ent, DO NOT EDIT.
package ent
import (
"api/ent/ma"
"api/ent/predicate"
"api/ent/user"
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// MaUpdate is the builder for updating Ma entities.
type MaUpdate struct {
config
hooks []Hook
mutation *MaMutation
}
// Where appends a list predicates to the MaUpdate builder.
func (mu *MaUpdate) Where(ps ...predicate.Ma) *MaUpdate {
mu.mutation.Where(ps...)
return mu
}
// SetToken sets the "token" field.
func (mu *MaUpdate) SetToken(s string) *MaUpdate {
mu.mutation.SetToken(s)
return mu
}
// SetNillableToken sets the "token" field if the given value is not nil.
func (mu *MaUpdate) SetNillableToken(s *string) *MaUpdate {
if s != nil {
mu.SetToken(*s)
}
return mu
}
// ClearToken clears the value of the "token" field.
func (mu *MaUpdate) ClearToken() *MaUpdate {
mu.mutation.ClearToken()
return mu
}
// SetLimit sets the "limit" field.
func (mu *MaUpdate) SetLimit(b bool) *MaUpdate {
mu.mutation.SetLimit(b)
return mu
}
// SetNillableLimit sets the "limit" field if the given value is not nil.
func (mu *MaUpdate) SetNillableLimit(b *bool) *MaUpdate {
if b != nil {
mu.SetLimit(*b)
}
return mu
}
// ClearLimit clears the value of the "limit" field.
func (mu *MaUpdate) ClearLimit() *MaUpdate {
mu.mutation.ClearLimit()
return mu
}
// SetCount sets the "count" field.
func (mu *MaUpdate) SetCount(i int) *MaUpdate {
mu.mutation.ResetCount()
mu.mutation.SetCount(i)
return mu
}
// SetNillableCount sets the "count" field if the given value is not nil.
func (mu *MaUpdate) SetNillableCount(i *int) *MaUpdate {
if i != nil {
mu.SetCount(*i)
}
return mu
}
// AddCount adds i to the "count" field.
func (mu *MaUpdate) AddCount(i int) *MaUpdate {
mu.mutation.AddCount(i)
return mu
}
// ClearCount clears the value of the "count" field.
func (mu *MaUpdate) ClearCount() *MaUpdate {
mu.mutation.ClearCount()
return mu
}
// SetHandle sets the "handle" field.
func (mu *MaUpdate) SetHandle(s string) *MaUpdate {
mu.mutation.SetHandle(s)
return mu
}
// SetNillableHandle sets the "handle" field if the given value is not nil.
func (mu *MaUpdate) SetNillableHandle(s *string) *MaUpdate {
if s != nil {
mu.SetHandle(*s)
}
return mu
}
// ClearHandle clears the value of the "handle" field.
func (mu *MaUpdate) ClearHandle() *MaUpdate {
mu.mutation.ClearHandle()
return mu
}
// SetText sets the "text" field.
func (mu *MaUpdate) SetText(s string) *MaUpdate {
mu.mutation.SetText(s)
return mu
}
// SetNillableText sets the "text" field if the given value is not nil.
func (mu *MaUpdate) SetNillableText(s *string) *MaUpdate {
if s != nil {
mu.SetText(*s)
}
return mu
}
// ClearText clears the value of the "text" field.
func (mu *MaUpdate) ClearText() *MaUpdate {
mu.mutation.ClearText()
return mu
}
// SetDid sets the "did" field.
func (mu *MaUpdate) SetDid(s string) *MaUpdate {
mu.mutation.SetDid(s)
return mu
}
// SetNillableDid sets the "did" field if the given value is not nil.
func (mu *MaUpdate) SetNillableDid(s *string) *MaUpdate {
if s != nil {
mu.SetDid(*s)
}
return mu
}
// ClearDid clears the value of the "did" field.
func (mu *MaUpdate) ClearDid() *MaUpdate {
mu.mutation.ClearDid()
return mu
}
// SetAvatar sets the "avatar" field.
func (mu *MaUpdate) SetAvatar(s string) *MaUpdate {
mu.mutation.SetAvatar(s)
return mu
}
// SetNillableAvatar sets the "avatar" field if the given value is not nil.
func (mu *MaUpdate) SetNillableAvatar(s *string) *MaUpdate {
if s != nil {
mu.SetAvatar(*s)
}
return mu
}
// ClearAvatar clears the value of the "avatar" field.
func (mu *MaUpdate) ClearAvatar() *MaUpdate {
mu.mutation.ClearAvatar()
return mu
}
// SetCid sets the "cid" field.
func (mu *MaUpdate) SetCid(s string) *MaUpdate {
mu.mutation.SetCid(s)
return mu
}
// SetNillableCid sets the "cid" field if the given value is not nil.
func (mu *MaUpdate) SetNillableCid(s *string) *MaUpdate {
if s != nil {
mu.SetCid(*s)
}
return mu
}
// ClearCid clears the value of the "cid" field.
func (mu *MaUpdate) ClearCid() *MaUpdate {
mu.mutation.ClearCid()
return mu
}
// SetURI sets the "uri" field.
func (mu *MaUpdate) SetURI(s string) *MaUpdate {
mu.mutation.SetURI(s)
return mu
}
// SetNillableURI sets the "uri" field if the given value is not nil.
func (mu *MaUpdate) SetNillableURI(s *string) *MaUpdate {
if s != nil {
mu.SetURI(*s)
}
return mu
}
// ClearURI clears the value of the "uri" field.
func (mu *MaUpdate) ClearURI() *MaUpdate {
mu.mutation.ClearURI()
return mu
}
// SetRkey sets the "rkey" field.
func (mu *MaUpdate) SetRkey(s string) *MaUpdate {
mu.mutation.SetRkey(s)
return mu
}
// SetNillableRkey sets the "rkey" field if the given value is not nil.
func (mu *MaUpdate) SetNillableRkey(s *string) *MaUpdate {
if s != nil {
mu.SetRkey(*s)
}
return mu
}
// ClearRkey clears the value of the "rkey" field.
func (mu *MaUpdate) ClearRkey() *MaUpdate {
mu.mutation.ClearRkey()
return mu
}
// SetBskyURL sets the "bsky_url" field.
func (mu *MaUpdate) SetBskyURL(s string) *MaUpdate {
mu.mutation.SetBskyURL(s)
return mu
}
// SetNillableBskyURL sets the "bsky_url" field if the given value is not nil.
func (mu *MaUpdate) SetNillableBskyURL(s *string) *MaUpdate {
if s != nil {
mu.SetBskyURL(*s)
}
return mu
}
// ClearBskyURL clears the value of the "bsky_url" field.
func (mu *MaUpdate) ClearBskyURL() *MaUpdate {
mu.mutation.ClearBskyURL()
return mu
}
// SetUpdatedAt sets the "updated_at" field.
func (mu *MaUpdate) SetUpdatedAt(t time.Time) *MaUpdate {
mu.mutation.SetUpdatedAt(t)
return mu
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (mu *MaUpdate) SetNillableUpdatedAt(t *time.Time) *MaUpdate {
if t != nil {
mu.SetUpdatedAt(*t)
}
return mu
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (mu *MaUpdate) ClearUpdatedAt() *MaUpdate {
mu.mutation.ClearUpdatedAt()
return mu
}
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (mu *MaUpdate) SetOwnerID(id int) *MaUpdate {
mu.mutation.SetOwnerID(id)
return mu
}
// SetOwner sets the "owner" edge to the User entity.
func (mu *MaUpdate) SetOwner(u *User) *MaUpdate {
return mu.SetOwnerID(u.ID)
}
// Mutation returns the MaMutation object of the builder.
func (mu *MaUpdate) Mutation() *MaMutation {
return mu.mutation
}
// ClearOwner clears the "owner" edge to the User entity.
func (mu *MaUpdate) ClearOwner() *MaUpdate {
mu.mutation.ClearOwner()
return mu
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (mu *MaUpdate) Save(ctx context.Context) (int, error) {
return withHooks[int, MaMutation](ctx, mu.sqlSave, mu.mutation, mu.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (mu *MaUpdate) SaveX(ctx context.Context) int {
affected, err := mu.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (mu *MaUpdate) Exec(ctx context.Context) error {
_, err := mu.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (mu *MaUpdate) ExecX(ctx context.Context) {
if err := mu.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (mu *MaUpdate) check() error {
if _, ok := mu.mutation.OwnerID(); mu.mutation.OwnerCleared() && !ok {
return errors.New(`ent: clearing a required unique edge "Ma.owner"`)
}
return nil
}
func (mu *MaUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := mu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(ma.Table, ma.Columns, sqlgraph.NewFieldSpec(ma.FieldID, field.TypeInt))
if ps := mu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := mu.mutation.Token(); ok {
_spec.SetField(ma.FieldToken, field.TypeString, value)
}
if mu.mutation.TokenCleared() {
_spec.ClearField(ma.FieldToken, field.TypeString)
}
if value, ok := mu.mutation.Limit(); ok {
_spec.SetField(ma.FieldLimit, field.TypeBool, value)
}
if mu.mutation.LimitCleared() {
_spec.ClearField(ma.FieldLimit, field.TypeBool)
}
if value, ok := mu.mutation.Count(); ok {
_spec.SetField(ma.FieldCount, field.TypeInt, value)
}
if value, ok := mu.mutation.AddedCount(); ok {
_spec.AddField(ma.FieldCount, field.TypeInt, value)
}
if mu.mutation.CountCleared() {
_spec.ClearField(ma.FieldCount, field.TypeInt)
}
if value, ok := mu.mutation.Handle(); ok {
_spec.SetField(ma.FieldHandle, field.TypeString, value)
}
if mu.mutation.HandleCleared() {
_spec.ClearField(ma.FieldHandle, field.TypeString)
}
if value, ok := mu.mutation.Text(); ok {
_spec.SetField(ma.FieldText, field.TypeString, value)
}
if mu.mutation.TextCleared() {
_spec.ClearField(ma.FieldText, field.TypeString)
}
if value, ok := mu.mutation.Did(); ok {
_spec.SetField(ma.FieldDid, field.TypeString, value)
}
if mu.mutation.DidCleared() {
_spec.ClearField(ma.FieldDid, field.TypeString)
}
if value, ok := mu.mutation.Avatar(); ok {
_spec.SetField(ma.FieldAvatar, field.TypeString, value)
}
if mu.mutation.AvatarCleared() {
_spec.ClearField(ma.FieldAvatar, field.TypeString)
}
if value, ok := mu.mutation.Cid(); ok {
_spec.SetField(ma.FieldCid, field.TypeString, value)
}
if mu.mutation.CidCleared() {
_spec.ClearField(ma.FieldCid, field.TypeString)
}
if value, ok := mu.mutation.URI(); ok {
_spec.SetField(ma.FieldURI, field.TypeString, value)
}
if mu.mutation.URICleared() {
_spec.ClearField(ma.FieldURI, field.TypeString)
}
if value, ok := mu.mutation.Rkey(); ok {
_spec.SetField(ma.FieldRkey, field.TypeString, value)
}
if mu.mutation.RkeyCleared() {
_spec.ClearField(ma.FieldRkey, field.TypeString)
}
if value, ok := mu.mutation.BskyURL(); ok {
_spec.SetField(ma.FieldBskyURL, field.TypeString, value)
}
if mu.mutation.BskyURLCleared() {
_spec.ClearField(ma.FieldBskyURL, field.TypeString)
}
if value, ok := mu.mutation.UpdatedAt(); ok {
_spec.SetField(ma.FieldUpdatedAt, field.TypeTime, value)
}
if mu.mutation.UpdatedAtCleared() {
_spec.ClearField(ma.FieldUpdatedAt, field.TypeTime)
}
if mu.mutation.CreatedAtCleared() {
_spec.ClearField(ma.FieldCreatedAt, field.TypeTime)
}
if mu.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: ma.OwnerTable,
Columns: []string{ma.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := mu.mutation.OwnerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: ma.OwnerTable,
Columns: []string{ma.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{ma.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
mu.mutation.done = true
return n, nil
}
// MaUpdateOne is the builder for updating a single Ma entity.
type MaUpdateOne struct {
config
fields []string
hooks []Hook
mutation *MaMutation
}
// SetToken sets the "token" field.
func (muo *MaUpdateOne) SetToken(s string) *MaUpdateOne {
muo.mutation.SetToken(s)
return muo
}
// SetNillableToken sets the "token" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableToken(s *string) *MaUpdateOne {
if s != nil {
muo.SetToken(*s)
}
return muo
}
// ClearToken clears the value of the "token" field.
func (muo *MaUpdateOne) ClearToken() *MaUpdateOne {
muo.mutation.ClearToken()
return muo
}
// SetLimit sets the "limit" field.
func (muo *MaUpdateOne) SetLimit(b bool) *MaUpdateOne {
muo.mutation.SetLimit(b)
return muo
}
// SetNillableLimit sets the "limit" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableLimit(b *bool) *MaUpdateOne {
if b != nil {
muo.SetLimit(*b)
}
return muo
}
// ClearLimit clears the value of the "limit" field.
func (muo *MaUpdateOne) ClearLimit() *MaUpdateOne {
muo.mutation.ClearLimit()
return muo
}
// SetCount sets the "count" field.
func (muo *MaUpdateOne) SetCount(i int) *MaUpdateOne {
muo.mutation.ResetCount()
muo.mutation.SetCount(i)
return muo
}
// SetNillableCount sets the "count" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableCount(i *int) *MaUpdateOne {
if i != nil {
muo.SetCount(*i)
}
return muo
}
// AddCount adds i to the "count" field.
func (muo *MaUpdateOne) AddCount(i int) *MaUpdateOne {
muo.mutation.AddCount(i)
return muo
}
// ClearCount clears the value of the "count" field.
func (muo *MaUpdateOne) ClearCount() *MaUpdateOne {
muo.mutation.ClearCount()
return muo
}
// SetHandle sets the "handle" field.
func (muo *MaUpdateOne) SetHandle(s string) *MaUpdateOne {
muo.mutation.SetHandle(s)
return muo
}
// SetNillableHandle sets the "handle" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableHandle(s *string) *MaUpdateOne {
if s != nil {
muo.SetHandle(*s)
}
return muo
}
// ClearHandle clears the value of the "handle" field.
func (muo *MaUpdateOne) ClearHandle() *MaUpdateOne {
muo.mutation.ClearHandle()
return muo
}
// SetText sets the "text" field.
func (muo *MaUpdateOne) SetText(s string) *MaUpdateOne {
muo.mutation.SetText(s)
return muo
}
// SetNillableText sets the "text" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableText(s *string) *MaUpdateOne {
if s != nil {
muo.SetText(*s)
}
return muo
}
// ClearText clears the value of the "text" field.
func (muo *MaUpdateOne) ClearText() *MaUpdateOne {
muo.mutation.ClearText()
return muo
}
// SetDid sets the "did" field.
func (muo *MaUpdateOne) SetDid(s string) *MaUpdateOne {
muo.mutation.SetDid(s)
return muo
}
// SetNillableDid sets the "did" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableDid(s *string) *MaUpdateOne {
if s != nil {
muo.SetDid(*s)
}
return muo
}
// ClearDid clears the value of the "did" field.
func (muo *MaUpdateOne) ClearDid() *MaUpdateOne {
muo.mutation.ClearDid()
return muo
}
// SetAvatar sets the "avatar" field.
func (muo *MaUpdateOne) SetAvatar(s string) *MaUpdateOne {
muo.mutation.SetAvatar(s)
return muo
}
// SetNillableAvatar sets the "avatar" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableAvatar(s *string) *MaUpdateOne {
if s != nil {
muo.SetAvatar(*s)
}
return muo
}
// ClearAvatar clears the value of the "avatar" field.
func (muo *MaUpdateOne) ClearAvatar() *MaUpdateOne {
muo.mutation.ClearAvatar()
return muo
}
// SetCid sets the "cid" field.
func (muo *MaUpdateOne) SetCid(s string) *MaUpdateOne {
muo.mutation.SetCid(s)
return muo
}
// SetNillableCid sets the "cid" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableCid(s *string) *MaUpdateOne {
if s != nil {
muo.SetCid(*s)
}
return muo
}
// ClearCid clears the value of the "cid" field.
func (muo *MaUpdateOne) ClearCid() *MaUpdateOne {
muo.mutation.ClearCid()
return muo
}
// SetURI sets the "uri" field.
func (muo *MaUpdateOne) SetURI(s string) *MaUpdateOne {
muo.mutation.SetURI(s)
return muo
}
// SetNillableURI sets the "uri" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableURI(s *string) *MaUpdateOne {
if s != nil {
muo.SetURI(*s)
}
return muo
}
// ClearURI clears the value of the "uri" field.
func (muo *MaUpdateOne) ClearURI() *MaUpdateOne {
muo.mutation.ClearURI()
return muo
}
// SetRkey sets the "rkey" field.
func (muo *MaUpdateOne) SetRkey(s string) *MaUpdateOne {
muo.mutation.SetRkey(s)
return muo
}
// SetNillableRkey sets the "rkey" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableRkey(s *string) *MaUpdateOne {
if s != nil {
muo.SetRkey(*s)
}
return muo
}
// ClearRkey clears the value of the "rkey" field.
func (muo *MaUpdateOne) ClearRkey() *MaUpdateOne {
muo.mutation.ClearRkey()
return muo
}
// SetBskyURL sets the "bsky_url" field.
func (muo *MaUpdateOne) SetBskyURL(s string) *MaUpdateOne {
muo.mutation.SetBskyURL(s)
return muo
}
// SetNillableBskyURL sets the "bsky_url" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableBskyURL(s *string) *MaUpdateOne {
if s != nil {
muo.SetBskyURL(*s)
}
return muo
}
// ClearBskyURL clears the value of the "bsky_url" field.
func (muo *MaUpdateOne) ClearBskyURL() *MaUpdateOne {
muo.mutation.ClearBskyURL()
return muo
}
// SetUpdatedAt sets the "updated_at" field.
func (muo *MaUpdateOne) SetUpdatedAt(t time.Time) *MaUpdateOne {
muo.mutation.SetUpdatedAt(t)
return muo
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableUpdatedAt(t *time.Time) *MaUpdateOne {
if t != nil {
muo.SetUpdatedAt(*t)
}
return muo
}
// ClearUpdatedAt clears the value of the "updated_at" field.
func (muo *MaUpdateOne) ClearUpdatedAt() *MaUpdateOne {
muo.mutation.ClearUpdatedAt()
return muo
}
// SetOwnerID sets the "owner" edge to the User entity by ID.
func (muo *MaUpdateOne) SetOwnerID(id int) *MaUpdateOne {
muo.mutation.SetOwnerID(id)
return muo
}
// SetOwner sets the "owner" edge to the User entity.
func (muo *MaUpdateOne) SetOwner(u *User) *MaUpdateOne {
return muo.SetOwnerID(u.ID)
}
// Mutation returns the MaMutation object of the builder.
func (muo *MaUpdateOne) Mutation() *MaMutation {
return muo.mutation
}
// ClearOwner clears the "owner" edge to the User entity.
func (muo *MaUpdateOne) ClearOwner() *MaUpdateOne {
muo.mutation.ClearOwner()
return muo
}
// Where appends a list predicates to the MaUpdate builder.
func (muo *MaUpdateOne) Where(ps ...predicate.Ma) *MaUpdateOne {
muo.mutation.Where(ps...)
return muo
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (muo *MaUpdateOne) Select(field string, fields ...string) *MaUpdateOne {
muo.fields = append([]string{field}, fields...)
return muo
}
// Save executes the query and returns the updated Ma entity.
func (muo *MaUpdateOne) Save(ctx context.Context) (*Ma, error) {
return withHooks[*Ma, MaMutation](ctx, muo.sqlSave, muo.mutation, muo.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (muo *MaUpdateOne) SaveX(ctx context.Context) *Ma {
node, err := muo.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (muo *MaUpdateOne) Exec(ctx context.Context) error {
_, err := muo.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (muo *MaUpdateOne) ExecX(ctx context.Context) {
if err := muo.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (muo *MaUpdateOne) check() error {
if _, ok := muo.mutation.OwnerID(); muo.mutation.OwnerCleared() && !ok {
return errors.New(`ent: clearing a required unique edge "Ma.owner"`)
}
return nil
}
func (muo *MaUpdateOne) sqlSave(ctx context.Context) (_node *Ma, err error) {
if err := muo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(ma.Table, ma.Columns, sqlgraph.NewFieldSpec(ma.FieldID, field.TypeInt))
id, ok := muo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Ma.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := muo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, ma.FieldID)
for _, f := range fields {
if !ma.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != ma.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := muo.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := muo.mutation.Token(); ok {
_spec.SetField(ma.FieldToken, field.TypeString, value)
}
if muo.mutation.TokenCleared() {
_spec.ClearField(ma.FieldToken, field.TypeString)
}
if value, ok := muo.mutation.Limit(); ok {
_spec.SetField(ma.FieldLimit, field.TypeBool, value)
}
if muo.mutation.LimitCleared() {
_spec.ClearField(ma.FieldLimit, field.TypeBool)
}
if value, ok := muo.mutation.Count(); ok {
_spec.SetField(ma.FieldCount, field.TypeInt, value)
}
if value, ok := muo.mutation.AddedCount(); ok {
_spec.AddField(ma.FieldCount, field.TypeInt, value)
}
if muo.mutation.CountCleared() {
_spec.ClearField(ma.FieldCount, field.TypeInt)
}
if value, ok := muo.mutation.Handle(); ok {
_spec.SetField(ma.FieldHandle, field.TypeString, value)
}
if muo.mutation.HandleCleared() {
_spec.ClearField(ma.FieldHandle, field.TypeString)
}
if value, ok := muo.mutation.Text(); ok {
_spec.SetField(ma.FieldText, field.TypeString, value)
}
if muo.mutation.TextCleared() {
_spec.ClearField(ma.FieldText, field.TypeString)
}
if value, ok := muo.mutation.Did(); ok {
_spec.SetField(ma.FieldDid, field.TypeString, value)
}
if muo.mutation.DidCleared() {
_spec.ClearField(ma.FieldDid, field.TypeString)
}
if value, ok := muo.mutation.Avatar(); ok {
_spec.SetField(ma.FieldAvatar, field.TypeString, value)
}
if muo.mutation.AvatarCleared() {
_spec.ClearField(ma.FieldAvatar, field.TypeString)
}
if value, ok := muo.mutation.Cid(); ok {
_spec.SetField(ma.FieldCid, field.TypeString, value)
}
if muo.mutation.CidCleared() {
_spec.ClearField(ma.FieldCid, field.TypeString)
}
if value, ok := muo.mutation.URI(); ok {
_spec.SetField(ma.FieldURI, field.TypeString, value)
}
if muo.mutation.URICleared() {
_spec.ClearField(ma.FieldURI, field.TypeString)
}
if value, ok := muo.mutation.Rkey(); ok {
_spec.SetField(ma.FieldRkey, field.TypeString, value)
}
if muo.mutation.RkeyCleared() {
_spec.ClearField(ma.FieldRkey, field.TypeString)
}
if value, ok := muo.mutation.BskyURL(); ok {
_spec.SetField(ma.FieldBskyURL, field.TypeString, value)
}
if muo.mutation.BskyURLCleared() {
_spec.ClearField(ma.FieldBskyURL, field.TypeString)
}
if value, ok := muo.mutation.UpdatedAt(); ok {
_spec.SetField(ma.FieldUpdatedAt, field.TypeTime, value)
}
if muo.mutation.UpdatedAtCleared() {
_spec.ClearField(ma.FieldUpdatedAt, field.TypeTime)
}
if muo.mutation.CreatedAtCleared() {
_spec.ClearField(ma.FieldCreatedAt, field.TypeTime)
}
if muo.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: ma.OwnerTable,
Columns: []string{ma.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := muo.mutation.OwnerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: ma.OwnerTable,
Columns: []string{ma.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &Ma{config: muo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{ma.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
muo.mutation.done = true
return _node, nil
}