1
0
api/ent/ma_update.go
2024-04-25 14:05:59 +09:00

1410 lines
35 KiB
Go

// 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
}
// SetCidRoot sets the "cid_root" field.
func (mu *MaUpdate) SetCidRoot(s string) *MaUpdate {
mu.mutation.SetCidRoot(s)
return mu
}
// SetNillableCidRoot sets the "cid_root" field if the given value is not nil.
func (mu *MaUpdate) SetNillableCidRoot(s *string) *MaUpdate {
if s != nil {
mu.SetCidRoot(*s)
}
return mu
}
// ClearCidRoot clears the value of the "cid_root" field.
func (mu *MaUpdate) ClearCidRoot() *MaUpdate {
mu.mutation.ClearCidRoot()
return mu
}
// SetURIRoot sets the "uri_root" field.
func (mu *MaUpdate) SetURIRoot(s string) *MaUpdate {
mu.mutation.SetURIRoot(s)
return mu
}
// SetNillableURIRoot sets the "uri_root" field if the given value is not nil.
func (mu *MaUpdate) SetNillableURIRoot(s *string) *MaUpdate {
if s != nil {
mu.SetURIRoot(*s)
}
return mu
}
// ClearURIRoot clears the value of the "uri_root" field.
func (mu *MaUpdate) ClearURIRoot() *MaUpdate {
mu.mutation.ClearURIRoot()
return mu
}
// SetRoot sets the "root" field.
func (mu *MaUpdate) SetRoot(s string) *MaUpdate {
mu.mutation.SetRoot(s)
return mu
}
// SetNillableRoot sets the "root" field if the given value is not nil.
func (mu *MaUpdate) SetNillableRoot(s *string) *MaUpdate {
if s != nil {
mu.SetRoot(*s)
}
return mu
}
// ClearRoot clears the value of the "root" field.
func (mu *MaUpdate) ClearRoot() *MaUpdate {
mu.mutation.ClearRoot()
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
}
// SetComment sets the "comment" field.
func (mu *MaUpdate) SetComment(s string) *MaUpdate {
mu.mutation.SetComment(s)
return mu
}
// SetNillableComment sets the "comment" field if the given value is not nil.
func (mu *MaUpdate) SetNillableComment(s *string) *MaUpdate {
if s != nil {
mu.SetComment(*s)
}
return mu
}
// ClearComment clears the value of the "comment" field.
func (mu *MaUpdate) ClearComment() *MaUpdate {
mu.mutation.ClearComment()
return mu
}
// SetBlog sets the "blog" field.
func (mu *MaUpdate) SetBlog(s string) *MaUpdate {
mu.mutation.SetBlog(s)
return mu
}
// SetNillableBlog sets the "blog" field if the given value is not nil.
func (mu *MaUpdate) SetNillableBlog(s *string) *MaUpdate {
if s != nil {
mu.SetBlog(*s)
}
return mu
}
// ClearBlog clears the value of the "blog" field.
func (mu *MaUpdate) ClearBlog() *MaUpdate {
mu.mutation.ClearBlog()
return mu
}
// SetBlogURL sets the "blog_url" field.
func (mu *MaUpdate) SetBlogURL(s string) *MaUpdate {
mu.mutation.SetBlogURL(s)
return mu
}
// SetNillableBlogURL sets the "blog_url" field if the given value is not nil.
func (mu *MaUpdate) SetNillableBlogURL(s *string) *MaUpdate {
if s != nil {
mu.SetBlogURL(*s)
}
return mu
}
// ClearBlogURL clears the value of the "blog_url" field.
func (mu *MaUpdate) ClearBlogURL() *MaUpdate {
mu.mutation.ClearBlogURL()
return mu
}
// SetDomain sets the "domain" field.
func (mu *MaUpdate) SetDomain(s string) *MaUpdate {
mu.mutation.SetDomain(s)
return mu
}
// SetNillableDomain sets the "domain" field if the given value is not nil.
func (mu *MaUpdate) SetNillableDomain(s *string) *MaUpdate {
if s != nil {
mu.SetDomain(*s)
}
return mu
}
// ClearDomain clears the value of the "domain" field.
func (mu *MaUpdate) ClearDomain() *MaUpdate {
mu.mutation.ClearDomain()
return mu
}
// SetHost sets the "host" field.
func (mu *MaUpdate) SetHost(s string) *MaUpdate {
mu.mutation.SetHost(s)
return mu
}
// SetNillableHost sets the "host" field if the given value is not nil.
func (mu *MaUpdate) SetNillableHost(s *string) *MaUpdate {
if s != nil {
mu.SetHost(*s)
}
return mu
}
// ClearHost clears the value of the "host" field.
func (mu *MaUpdate) ClearHost() *MaUpdate {
mu.mutation.ClearHost()
return mu
}
// SetFeed sets the "feed" field.
func (mu *MaUpdate) SetFeed(s string) *MaUpdate {
mu.mutation.SetFeed(s)
return mu
}
// SetNillableFeed sets the "feed" field if the given value is not nil.
func (mu *MaUpdate) SetNillableFeed(s *string) *MaUpdate {
if s != nil {
mu.SetFeed(*s)
}
return mu
}
// ClearFeed clears the value of the "feed" field.
func (mu *MaUpdate) ClearFeed() *MaUpdate {
mu.mutation.ClearFeed()
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.CidRoot(); ok {
_spec.SetField(ma.FieldCidRoot, field.TypeString, value)
}
if mu.mutation.CidRootCleared() {
_spec.ClearField(ma.FieldCidRoot, field.TypeString)
}
if value, ok := mu.mutation.URIRoot(); ok {
_spec.SetField(ma.FieldURIRoot, field.TypeString, value)
}
if mu.mutation.URIRootCleared() {
_spec.ClearField(ma.FieldURIRoot, field.TypeString)
}
if value, ok := mu.mutation.Root(); ok {
_spec.SetField(ma.FieldRoot, field.TypeString, value)
}
if mu.mutation.RootCleared() {
_spec.ClearField(ma.FieldRoot, 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.Comment(); ok {
_spec.SetField(ma.FieldComment, field.TypeString, value)
}
if mu.mutation.CommentCleared() {
_spec.ClearField(ma.FieldComment, field.TypeString)
}
if value, ok := mu.mutation.Blog(); ok {
_spec.SetField(ma.FieldBlog, field.TypeString, value)
}
if mu.mutation.BlogCleared() {
_spec.ClearField(ma.FieldBlog, field.TypeString)
}
if value, ok := mu.mutation.BlogURL(); ok {
_spec.SetField(ma.FieldBlogURL, field.TypeString, value)
}
if mu.mutation.BlogURLCleared() {
_spec.ClearField(ma.FieldBlogURL, field.TypeString)
}
if value, ok := mu.mutation.Domain(); ok {
_spec.SetField(ma.FieldDomain, field.TypeString, value)
}
if mu.mutation.DomainCleared() {
_spec.ClearField(ma.FieldDomain, field.TypeString)
}
if value, ok := mu.mutation.Host(); ok {
_spec.SetField(ma.FieldHost, field.TypeString, value)
}
if mu.mutation.HostCleared() {
_spec.ClearField(ma.FieldHost, field.TypeString)
}
if value, ok := mu.mutation.Feed(); ok {
_spec.SetField(ma.FieldFeed, field.TypeString, value)
}
if mu.mutation.FeedCleared() {
_spec.ClearField(ma.FieldFeed, 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
}
// SetCidRoot sets the "cid_root" field.
func (muo *MaUpdateOne) SetCidRoot(s string) *MaUpdateOne {
muo.mutation.SetCidRoot(s)
return muo
}
// SetNillableCidRoot sets the "cid_root" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableCidRoot(s *string) *MaUpdateOne {
if s != nil {
muo.SetCidRoot(*s)
}
return muo
}
// ClearCidRoot clears the value of the "cid_root" field.
func (muo *MaUpdateOne) ClearCidRoot() *MaUpdateOne {
muo.mutation.ClearCidRoot()
return muo
}
// SetURIRoot sets the "uri_root" field.
func (muo *MaUpdateOne) SetURIRoot(s string) *MaUpdateOne {
muo.mutation.SetURIRoot(s)
return muo
}
// SetNillableURIRoot sets the "uri_root" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableURIRoot(s *string) *MaUpdateOne {
if s != nil {
muo.SetURIRoot(*s)
}
return muo
}
// ClearURIRoot clears the value of the "uri_root" field.
func (muo *MaUpdateOne) ClearURIRoot() *MaUpdateOne {
muo.mutation.ClearURIRoot()
return muo
}
// SetRoot sets the "root" field.
func (muo *MaUpdateOne) SetRoot(s string) *MaUpdateOne {
muo.mutation.SetRoot(s)
return muo
}
// SetNillableRoot sets the "root" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableRoot(s *string) *MaUpdateOne {
if s != nil {
muo.SetRoot(*s)
}
return muo
}
// ClearRoot clears the value of the "root" field.
func (muo *MaUpdateOne) ClearRoot() *MaUpdateOne {
muo.mutation.ClearRoot()
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
}
// SetComment sets the "comment" field.
func (muo *MaUpdateOne) SetComment(s string) *MaUpdateOne {
muo.mutation.SetComment(s)
return muo
}
// SetNillableComment sets the "comment" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableComment(s *string) *MaUpdateOne {
if s != nil {
muo.SetComment(*s)
}
return muo
}
// ClearComment clears the value of the "comment" field.
func (muo *MaUpdateOne) ClearComment() *MaUpdateOne {
muo.mutation.ClearComment()
return muo
}
// SetBlog sets the "blog" field.
func (muo *MaUpdateOne) SetBlog(s string) *MaUpdateOne {
muo.mutation.SetBlog(s)
return muo
}
// SetNillableBlog sets the "blog" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableBlog(s *string) *MaUpdateOne {
if s != nil {
muo.SetBlog(*s)
}
return muo
}
// ClearBlog clears the value of the "blog" field.
func (muo *MaUpdateOne) ClearBlog() *MaUpdateOne {
muo.mutation.ClearBlog()
return muo
}
// SetBlogURL sets the "blog_url" field.
func (muo *MaUpdateOne) SetBlogURL(s string) *MaUpdateOne {
muo.mutation.SetBlogURL(s)
return muo
}
// SetNillableBlogURL sets the "blog_url" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableBlogURL(s *string) *MaUpdateOne {
if s != nil {
muo.SetBlogURL(*s)
}
return muo
}
// ClearBlogURL clears the value of the "blog_url" field.
func (muo *MaUpdateOne) ClearBlogURL() *MaUpdateOne {
muo.mutation.ClearBlogURL()
return muo
}
// SetDomain sets the "domain" field.
func (muo *MaUpdateOne) SetDomain(s string) *MaUpdateOne {
muo.mutation.SetDomain(s)
return muo
}
// SetNillableDomain sets the "domain" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableDomain(s *string) *MaUpdateOne {
if s != nil {
muo.SetDomain(*s)
}
return muo
}
// ClearDomain clears the value of the "domain" field.
func (muo *MaUpdateOne) ClearDomain() *MaUpdateOne {
muo.mutation.ClearDomain()
return muo
}
// SetHost sets the "host" field.
func (muo *MaUpdateOne) SetHost(s string) *MaUpdateOne {
muo.mutation.SetHost(s)
return muo
}
// SetNillableHost sets the "host" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableHost(s *string) *MaUpdateOne {
if s != nil {
muo.SetHost(*s)
}
return muo
}
// ClearHost clears the value of the "host" field.
func (muo *MaUpdateOne) ClearHost() *MaUpdateOne {
muo.mutation.ClearHost()
return muo
}
// SetFeed sets the "feed" field.
func (muo *MaUpdateOne) SetFeed(s string) *MaUpdateOne {
muo.mutation.SetFeed(s)
return muo
}
// SetNillableFeed sets the "feed" field if the given value is not nil.
func (muo *MaUpdateOne) SetNillableFeed(s *string) *MaUpdateOne {
if s != nil {
muo.SetFeed(*s)
}
return muo
}
// ClearFeed clears the value of the "feed" field.
func (muo *MaUpdateOne) ClearFeed() *MaUpdateOne {
muo.mutation.ClearFeed()
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.CidRoot(); ok {
_spec.SetField(ma.FieldCidRoot, field.TypeString, value)
}
if muo.mutation.CidRootCleared() {
_spec.ClearField(ma.FieldCidRoot, field.TypeString)
}
if value, ok := muo.mutation.URIRoot(); ok {
_spec.SetField(ma.FieldURIRoot, field.TypeString, value)
}
if muo.mutation.URIRootCleared() {
_spec.ClearField(ma.FieldURIRoot, field.TypeString)
}
if value, ok := muo.mutation.Root(); ok {
_spec.SetField(ma.FieldRoot, field.TypeString, value)
}
if muo.mutation.RootCleared() {
_spec.ClearField(ma.FieldRoot, 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.Comment(); ok {
_spec.SetField(ma.FieldComment, field.TypeString, value)
}
if muo.mutation.CommentCleared() {
_spec.ClearField(ma.FieldComment, field.TypeString)
}
if value, ok := muo.mutation.Blog(); ok {
_spec.SetField(ma.FieldBlog, field.TypeString, value)
}
if muo.mutation.BlogCleared() {
_spec.ClearField(ma.FieldBlog, field.TypeString)
}
if value, ok := muo.mutation.BlogURL(); ok {
_spec.SetField(ma.FieldBlogURL, field.TypeString, value)
}
if muo.mutation.BlogURLCleared() {
_spec.ClearField(ma.FieldBlogURL, field.TypeString)
}
if value, ok := muo.mutation.Domain(); ok {
_spec.SetField(ma.FieldDomain, field.TypeString, value)
}
if muo.mutation.DomainCleared() {
_spec.ClearField(ma.FieldDomain, field.TypeString)
}
if value, ok := muo.mutation.Host(); ok {
_spec.SetField(ma.FieldHost, field.TypeString, value)
}
if muo.mutation.HostCleared() {
_spec.ClearField(ma.FieldHost, field.TypeString)
}
if value, ok := muo.mutation.Feed(); ok {
_spec.SetField(ma.FieldFeed, field.TypeString, value)
}
if muo.mutation.FeedCleared() {
_spec.ClearField(ma.FieldFeed, 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
}