Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
post_update.go91.2 kB
// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/Southclaws/storyden/internal/ent/account" "github.com/Southclaws/storyden/internal/ent/asset" "github.com/Southclaws/storyden/internal/ent/category" "github.com/Southclaws/storyden/internal/ent/collection" "github.com/Southclaws/storyden/internal/ent/event" "github.com/Southclaws/storyden/internal/ent/likepost" "github.com/Southclaws/storyden/internal/ent/link" "github.com/Southclaws/storyden/internal/ent/mentionprofile" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/postread" "github.com/Southclaws/storyden/internal/ent/predicate" "github.com/Southclaws/storyden/internal/ent/react" "github.com/Southclaws/storyden/internal/ent/tag" "github.com/rs/xid" ) // PostUpdate is the builder for updating Post entities. type PostUpdate struct { config hooks []Hook mutation *PostMutation modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the PostUpdate builder. func (_u *PostUpdate) Where(ps ...predicate.Post) *PostUpdate { _u.mutation.Where(ps...) return _u } // SetUpdatedAt sets the "updated_at" field. func (_u *PostUpdate) SetUpdatedAt(v time.Time) *PostUpdate { _u.mutation.SetUpdatedAt(v) return _u } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (_u *PostUpdate) SetNillableUpdatedAt(v *time.Time) *PostUpdate { if v != nil { _u.SetUpdatedAt(*v) } return _u } // SetDeletedAt sets the "deleted_at" field. func (_u *PostUpdate) SetDeletedAt(v time.Time) *PostUpdate { _u.mutation.SetDeletedAt(v) return _u } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (_u *PostUpdate) SetNillableDeletedAt(v *time.Time) *PostUpdate { if v != nil { _u.SetDeletedAt(*v) } return _u } // ClearDeletedAt clears the value of the "deleted_at" field. func (_u *PostUpdate) ClearDeletedAt() *PostUpdate { _u.mutation.ClearDeletedAt() return _u } // SetIndexedAt sets the "indexed_at" field. func (_u *PostUpdate) SetIndexedAt(v time.Time) *PostUpdate { _u.mutation.SetIndexedAt(v) return _u } // SetNillableIndexedAt sets the "indexed_at" field if the given value is not nil. func (_u *PostUpdate) SetNillableIndexedAt(v *time.Time) *PostUpdate { if v != nil { _u.SetIndexedAt(*v) } return _u } // ClearIndexedAt clears the value of the "indexed_at" field. func (_u *PostUpdate) ClearIndexedAt() *PostUpdate { _u.mutation.ClearIndexedAt() return _u } // SetFirst sets the "first" field. func (_u *PostUpdate) SetFirst(v bool) *PostUpdate { _u.mutation.SetFirst(v) return _u } // SetNillableFirst sets the "first" field if the given value is not nil. func (_u *PostUpdate) SetNillableFirst(v *bool) *PostUpdate { if v != nil { _u.SetFirst(*v) } return _u } // SetTitle sets the "title" field. func (_u *PostUpdate) SetTitle(v string) *PostUpdate { _u.mutation.SetTitle(v) return _u } // SetNillableTitle sets the "title" field if the given value is not nil. func (_u *PostUpdate) SetNillableTitle(v *string) *PostUpdate { if v != nil { _u.SetTitle(*v) } return _u } // ClearTitle clears the value of the "title" field. func (_u *PostUpdate) ClearTitle() *PostUpdate { _u.mutation.ClearTitle() return _u } // SetSlug sets the "slug" field. func (_u *PostUpdate) SetSlug(v string) *PostUpdate { _u.mutation.SetSlug(v) return _u } // SetNillableSlug sets the "slug" field if the given value is not nil. func (_u *PostUpdate) SetNillableSlug(v *string) *PostUpdate { if v != nil { _u.SetSlug(*v) } return _u } // ClearSlug clears the value of the "slug" field. func (_u *PostUpdate) ClearSlug() *PostUpdate { _u.mutation.ClearSlug() return _u } // SetPinned sets the "pinned" field. func (_u *PostUpdate) SetPinned(v bool) *PostUpdate { _u.mutation.SetPinned(v) return _u } // SetNillablePinned sets the "pinned" field if the given value is not nil. func (_u *PostUpdate) SetNillablePinned(v *bool) *PostUpdate { if v != nil { _u.SetPinned(*v) } return _u } // SetLastReplyAt sets the "last_reply_at" field. func (_u *PostUpdate) SetLastReplyAt(v time.Time) *PostUpdate { _u.mutation.SetLastReplyAt(v) return _u } // SetNillableLastReplyAt sets the "last_reply_at" field if the given value is not nil. func (_u *PostUpdate) SetNillableLastReplyAt(v *time.Time) *PostUpdate { if v != nil { _u.SetLastReplyAt(*v) } return _u } // ClearLastReplyAt clears the value of the "last_reply_at" field. func (_u *PostUpdate) ClearLastReplyAt() *PostUpdate { _u.mutation.ClearLastReplyAt() return _u } // SetRootPostID sets the "root_post_id" field. func (_u *PostUpdate) SetRootPostID(v xid.ID) *PostUpdate { _u.mutation.SetRootPostID(v) return _u } // SetNillableRootPostID sets the "root_post_id" field if the given value is not nil. func (_u *PostUpdate) SetNillableRootPostID(v *xid.ID) *PostUpdate { if v != nil { _u.SetRootPostID(*v) } return _u } // ClearRootPostID clears the value of the "root_post_id" field. func (_u *PostUpdate) ClearRootPostID() *PostUpdate { _u.mutation.ClearRootPostID() return _u } // SetReplyToPostID sets the "reply_to_post_id" field. func (_u *PostUpdate) SetReplyToPostID(v xid.ID) *PostUpdate { _u.mutation.SetReplyToPostID(v) return _u } // SetNillableReplyToPostID sets the "reply_to_post_id" field if the given value is not nil. func (_u *PostUpdate) SetNillableReplyToPostID(v *xid.ID) *PostUpdate { if v != nil { _u.SetReplyToPostID(*v) } return _u } // ClearReplyToPostID clears the value of the "reply_to_post_id" field. func (_u *PostUpdate) ClearReplyToPostID() *PostUpdate { _u.mutation.ClearReplyToPostID() return _u } // SetBody sets the "body" field. func (_u *PostUpdate) SetBody(v string) *PostUpdate { _u.mutation.SetBody(v) return _u } // SetNillableBody sets the "body" field if the given value is not nil. func (_u *PostUpdate) SetNillableBody(v *string) *PostUpdate { if v != nil { _u.SetBody(*v) } return _u } // SetShort sets the "short" field. func (_u *PostUpdate) SetShort(v string) *PostUpdate { _u.mutation.SetShort(v) return _u } // SetNillableShort sets the "short" field if the given value is not nil. func (_u *PostUpdate) SetNillableShort(v *string) *PostUpdate { if v != nil { _u.SetShort(*v) } return _u } // SetMetadata sets the "metadata" field. func (_u *PostUpdate) SetMetadata(v map[string]interface{}) *PostUpdate { _u.mutation.SetMetadata(v) return _u } // ClearMetadata clears the value of the "metadata" field. func (_u *PostUpdate) ClearMetadata() *PostUpdate { _u.mutation.ClearMetadata() return _u } // SetVisibility sets the "visibility" field. func (_u *PostUpdate) SetVisibility(v post.Visibility) *PostUpdate { _u.mutation.SetVisibility(v) return _u } // SetNillableVisibility sets the "visibility" field if the given value is not nil. func (_u *PostUpdate) SetNillableVisibility(v *post.Visibility) *PostUpdate { if v != nil { _u.SetVisibility(*v) } return _u } // SetAccountPosts sets the "account_posts" field. func (_u *PostUpdate) SetAccountPosts(v xid.ID) *PostUpdate { _u.mutation.SetAccountPosts(v) return _u } // SetNillableAccountPosts sets the "account_posts" field if the given value is not nil. func (_u *PostUpdate) SetNillableAccountPosts(v *xid.ID) *PostUpdate { if v != nil { _u.SetAccountPosts(*v) } return _u } // SetCategoryID sets the "category_id" field. func (_u *PostUpdate) SetCategoryID(v xid.ID) *PostUpdate { _u.mutation.SetCategoryID(v) return _u } // SetNillableCategoryID sets the "category_id" field if the given value is not nil. func (_u *PostUpdate) SetNillableCategoryID(v *xid.ID) *PostUpdate { if v != nil { _u.SetCategoryID(*v) } return _u } // ClearCategoryID clears the value of the "category_id" field. func (_u *PostUpdate) ClearCategoryID() *PostUpdate { _u.mutation.ClearCategoryID() return _u } // SetLinkID sets the "link_id" field. func (_u *PostUpdate) SetLinkID(v xid.ID) *PostUpdate { _u.mutation.SetLinkID(v) return _u } // SetNillableLinkID sets the "link_id" field if the given value is not nil. func (_u *PostUpdate) SetNillableLinkID(v *xid.ID) *PostUpdate { if v != nil { _u.SetLinkID(*v) } return _u } // ClearLinkID clears the value of the "link_id" field. func (_u *PostUpdate) ClearLinkID() *PostUpdate { _u.mutation.ClearLinkID() return _u } // SetAuthorID sets the "author" edge to the Account entity by ID. func (_u *PostUpdate) SetAuthorID(id xid.ID) *PostUpdate { _u.mutation.SetAuthorID(id) return _u } // SetAuthor sets the "author" edge to the Account entity. func (_u *PostUpdate) SetAuthor(v *Account) *PostUpdate { return _u.SetAuthorID(v.ID) } // SetCategory sets the "category" edge to the Category entity. func (_u *PostUpdate) SetCategory(v *Category) *PostUpdate { return _u.SetCategoryID(v.ID) } // AddTagIDs adds the "tags" edge to the Tag entity by IDs. func (_u *PostUpdate) AddTagIDs(ids ...xid.ID) *PostUpdate { _u.mutation.AddTagIDs(ids...) return _u } // AddTags adds the "tags" edges to the Tag entity. func (_u *PostUpdate) AddTags(v ...*Tag) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddTagIDs(ids...) } // SetRootID sets the "root" edge to the Post entity by ID. func (_u *PostUpdate) SetRootID(id xid.ID) *PostUpdate { _u.mutation.SetRootID(id) return _u } // SetNillableRootID sets the "root" edge to the Post entity by ID if the given value is not nil. func (_u *PostUpdate) SetNillableRootID(id *xid.ID) *PostUpdate { if id != nil { _u = _u.SetRootID(*id) } return _u } // SetRoot sets the "root" edge to the Post entity. func (_u *PostUpdate) SetRoot(v *Post) *PostUpdate { return _u.SetRootID(v.ID) } // AddPostIDs adds the "posts" edge to the Post entity by IDs. func (_u *PostUpdate) AddPostIDs(ids ...xid.ID) *PostUpdate { _u.mutation.AddPostIDs(ids...) return _u } // AddPosts adds the "posts" edges to the Post entity. func (_u *PostUpdate) AddPosts(v ...*Post) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddPostIDs(ids...) } // SetReplyToID sets the "replyTo" edge to the Post entity by ID. func (_u *PostUpdate) SetReplyToID(id xid.ID) *PostUpdate { _u.mutation.SetReplyToID(id) return _u } // SetNillableReplyToID sets the "replyTo" edge to the Post entity by ID if the given value is not nil. func (_u *PostUpdate) SetNillableReplyToID(id *xid.ID) *PostUpdate { if id != nil { _u = _u.SetReplyToID(*id) } return _u } // SetReplyTo sets the "replyTo" edge to the Post entity. func (_u *PostUpdate) SetReplyTo(v *Post) *PostUpdate { return _u.SetReplyToID(v.ID) } // AddReplyIDs adds the "replies" edge to the Post entity by IDs. func (_u *PostUpdate) AddReplyIDs(ids ...xid.ID) *PostUpdate { _u.mutation.AddReplyIDs(ids...) return _u } // AddReplies adds the "replies" edges to the Post entity. func (_u *PostUpdate) AddReplies(v ...*Post) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddReplyIDs(ids...) } // AddReactIDs adds the "reacts" edge to the React entity by IDs. func (_u *PostUpdate) AddReactIDs(ids ...xid.ID) *PostUpdate { _u.mutation.AddReactIDs(ids...) return _u } // AddReacts adds the "reacts" edges to the React entity. func (_u *PostUpdate) AddReacts(v ...*React) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddReactIDs(ids...) } // AddLikeIDs adds the "likes" edge to the LikePost entity by IDs. func (_u *PostUpdate) AddLikeIDs(ids ...xid.ID) *PostUpdate { _u.mutation.AddLikeIDs(ids...) return _u } // AddLikes adds the "likes" edges to the LikePost entity. func (_u *PostUpdate) AddLikes(v ...*LikePost) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddLikeIDs(ids...) } // AddMentionIDs adds the "mentions" edge to the MentionProfile entity by IDs. func (_u *PostUpdate) AddMentionIDs(ids ...xid.ID) *PostUpdate { _u.mutation.AddMentionIDs(ids...) return _u } // AddMentions adds the "mentions" edges to the MentionProfile entity. func (_u *PostUpdate) AddMentions(v ...*MentionProfile) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddMentionIDs(ids...) } // AddAssetIDs adds the "assets" edge to the Asset entity by IDs. func (_u *PostUpdate) AddAssetIDs(ids ...xid.ID) *PostUpdate { _u.mutation.AddAssetIDs(ids...) return _u } // AddAssets adds the "assets" edges to the Asset entity. func (_u *PostUpdate) AddAssets(v ...*Asset) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddAssetIDs(ids...) } // AddCollectionIDs adds the "collections" edge to the Collection entity by IDs. func (_u *PostUpdate) AddCollectionIDs(ids ...xid.ID) *PostUpdate { _u.mutation.AddCollectionIDs(ids...) return _u } // AddCollections adds the "collections" edges to the Collection entity. func (_u *PostUpdate) AddCollections(v ...*Collection) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddCollectionIDs(ids...) } // SetLink sets the "link" edge to the Link entity. func (_u *PostUpdate) SetLink(v *Link) *PostUpdate { return _u.SetLinkID(v.ID) } // AddContentLinkIDs adds the "content_links" edge to the Link entity by IDs. func (_u *PostUpdate) AddContentLinkIDs(ids ...xid.ID) *PostUpdate { _u.mutation.AddContentLinkIDs(ids...) return _u } // AddContentLinks adds the "content_links" edges to the Link entity. func (_u *PostUpdate) AddContentLinks(v ...*Link) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddContentLinkIDs(ids...) } // AddEventIDs adds the "event" edge to the Event entity by IDs. func (_u *PostUpdate) AddEventIDs(ids ...xid.ID) *PostUpdate { _u.mutation.AddEventIDs(ids...) return _u } // AddEvent adds the "event" edges to the Event entity. func (_u *PostUpdate) AddEvent(v ...*Event) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddEventIDs(ids...) } // AddPostReadIDs adds the "post_reads" edge to the PostRead entity by IDs. func (_u *PostUpdate) AddPostReadIDs(ids ...xid.ID) *PostUpdate { _u.mutation.AddPostReadIDs(ids...) return _u } // AddPostReads adds the "post_reads" edges to the PostRead entity. func (_u *PostUpdate) AddPostReads(v ...*PostRead) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddPostReadIDs(ids...) } // Mutation returns the PostMutation object of the builder. func (_u *PostUpdate) Mutation() *PostMutation { return _u.mutation } // ClearAuthor clears the "author" edge to the Account entity. func (_u *PostUpdate) ClearAuthor() *PostUpdate { _u.mutation.ClearAuthor() return _u } // ClearCategory clears the "category" edge to the Category entity. func (_u *PostUpdate) ClearCategory() *PostUpdate { _u.mutation.ClearCategory() return _u } // ClearTags clears all "tags" edges to the Tag entity. func (_u *PostUpdate) ClearTags() *PostUpdate { _u.mutation.ClearTags() return _u } // RemoveTagIDs removes the "tags" edge to Tag entities by IDs. func (_u *PostUpdate) RemoveTagIDs(ids ...xid.ID) *PostUpdate { _u.mutation.RemoveTagIDs(ids...) return _u } // RemoveTags removes "tags" edges to Tag entities. func (_u *PostUpdate) RemoveTags(v ...*Tag) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveTagIDs(ids...) } // ClearRoot clears the "root" edge to the Post entity. func (_u *PostUpdate) ClearRoot() *PostUpdate { _u.mutation.ClearRoot() return _u } // ClearPosts clears all "posts" edges to the Post entity. func (_u *PostUpdate) ClearPosts() *PostUpdate { _u.mutation.ClearPosts() return _u } // RemovePostIDs removes the "posts" edge to Post entities by IDs. func (_u *PostUpdate) RemovePostIDs(ids ...xid.ID) *PostUpdate { _u.mutation.RemovePostIDs(ids...) return _u } // RemovePosts removes "posts" edges to Post entities. func (_u *PostUpdate) RemovePosts(v ...*Post) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemovePostIDs(ids...) } // ClearReplyTo clears the "replyTo" edge to the Post entity. func (_u *PostUpdate) ClearReplyTo() *PostUpdate { _u.mutation.ClearReplyTo() return _u } // ClearReplies clears all "replies" edges to the Post entity. func (_u *PostUpdate) ClearReplies() *PostUpdate { _u.mutation.ClearReplies() return _u } // RemoveReplyIDs removes the "replies" edge to Post entities by IDs. func (_u *PostUpdate) RemoveReplyIDs(ids ...xid.ID) *PostUpdate { _u.mutation.RemoveReplyIDs(ids...) return _u } // RemoveReplies removes "replies" edges to Post entities. func (_u *PostUpdate) RemoveReplies(v ...*Post) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveReplyIDs(ids...) } // ClearReacts clears all "reacts" edges to the React entity. func (_u *PostUpdate) ClearReacts() *PostUpdate { _u.mutation.ClearReacts() return _u } // RemoveReactIDs removes the "reacts" edge to React entities by IDs. func (_u *PostUpdate) RemoveReactIDs(ids ...xid.ID) *PostUpdate { _u.mutation.RemoveReactIDs(ids...) return _u } // RemoveReacts removes "reacts" edges to React entities. func (_u *PostUpdate) RemoveReacts(v ...*React) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveReactIDs(ids...) } // ClearLikes clears all "likes" edges to the LikePost entity. func (_u *PostUpdate) ClearLikes() *PostUpdate { _u.mutation.ClearLikes() return _u } // RemoveLikeIDs removes the "likes" edge to LikePost entities by IDs. func (_u *PostUpdate) RemoveLikeIDs(ids ...xid.ID) *PostUpdate { _u.mutation.RemoveLikeIDs(ids...) return _u } // RemoveLikes removes "likes" edges to LikePost entities. func (_u *PostUpdate) RemoveLikes(v ...*LikePost) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveLikeIDs(ids...) } // ClearMentions clears all "mentions" edges to the MentionProfile entity. func (_u *PostUpdate) ClearMentions() *PostUpdate { _u.mutation.ClearMentions() return _u } // RemoveMentionIDs removes the "mentions" edge to MentionProfile entities by IDs. func (_u *PostUpdate) RemoveMentionIDs(ids ...xid.ID) *PostUpdate { _u.mutation.RemoveMentionIDs(ids...) return _u } // RemoveMentions removes "mentions" edges to MentionProfile entities. func (_u *PostUpdate) RemoveMentions(v ...*MentionProfile) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveMentionIDs(ids...) } // ClearAssets clears all "assets" edges to the Asset entity. func (_u *PostUpdate) ClearAssets() *PostUpdate { _u.mutation.ClearAssets() return _u } // RemoveAssetIDs removes the "assets" edge to Asset entities by IDs. func (_u *PostUpdate) RemoveAssetIDs(ids ...xid.ID) *PostUpdate { _u.mutation.RemoveAssetIDs(ids...) return _u } // RemoveAssets removes "assets" edges to Asset entities. func (_u *PostUpdate) RemoveAssets(v ...*Asset) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveAssetIDs(ids...) } // ClearCollections clears all "collections" edges to the Collection entity. func (_u *PostUpdate) ClearCollections() *PostUpdate { _u.mutation.ClearCollections() return _u } // RemoveCollectionIDs removes the "collections" edge to Collection entities by IDs. func (_u *PostUpdate) RemoveCollectionIDs(ids ...xid.ID) *PostUpdate { _u.mutation.RemoveCollectionIDs(ids...) return _u } // RemoveCollections removes "collections" edges to Collection entities. func (_u *PostUpdate) RemoveCollections(v ...*Collection) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveCollectionIDs(ids...) } // ClearLink clears the "link" edge to the Link entity. func (_u *PostUpdate) ClearLink() *PostUpdate { _u.mutation.ClearLink() return _u } // ClearContentLinks clears all "content_links" edges to the Link entity. func (_u *PostUpdate) ClearContentLinks() *PostUpdate { _u.mutation.ClearContentLinks() return _u } // RemoveContentLinkIDs removes the "content_links" edge to Link entities by IDs. func (_u *PostUpdate) RemoveContentLinkIDs(ids ...xid.ID) *PostUpdate { _u.mutation.RemoveContentLinkIDs(ids...) return _u } // RemoveContentLinks removes "content_links" edges to Link entities. func (_u *PostUpdate) RemoveContentLinks(v ...*Link) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveContentLinkIDs(ids...) } // ClearEvent clears all "event" edges to the Event entity. func (_u *PostUpdate) ClearEvent() *PostUpdate { _u.mutation.ClearEvent() return _u } // RemoveEventIDs removes the "event" edge to Event entities by IDs. func (_u *PostUpdate) RemoveEventIDs(ids ...xid.ID) *PostUpdate { _u.mutation.RemoveEventIDs(ids...) return _u } // RemoveEvent removes "event" edges to Event entities. func (_u *PostUpdate) RemoveEvent(v ...*Event) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveEventIDs(ids...) } // ClearPostReads clears all "post_reads" edges to the PostRead entity. func (_u *PostUpdate) ClearPostReads() *PostUpdate { _u.mutation.ClearPostReads() return _u } // RemovePostReadIDs removes the "post_reads" edge to PostRead entities by IDs. func (_u *PostUpdate) RemovePostReadIDs(ids ...xid.ID) *PostUpdate { _u.mutation.RemovePostReadIDs(ids...) return _u } // RemovePostReads removes "post_reads" edges to PostRead entities. func (_u *PostUpdate) RemovePostReads(v ...*PostRead) *PostUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemovePostReadIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. func (_u *PostUpdate) Save(ctx context.Context) (int, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *PostUpdate) SaveX(ctx context.Context) int { affected, err := _u.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (_u *PostUpdate) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *PostUpdate) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. func (_u *PostUpdate) check() error { if v, ok := _u.mutation.Visibility(); ok { if err := post.VisibilityValidator(v); err != nil { return &ValidationError{Name: "visibility", err: fmt.Errorf(`ent: validator failed for field "Post.visibility": %w`, err)} } } if _u.mutation.AuthorCleared() && len(_u.mutation.AuthorIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Post.author"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (_u *PostUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PostUpdate { _u.modifiers = append(_u.modifiers, modifiers...) return _u } func (_u *PostUpdate) sqlSave(ctx context.Context) (_node int, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(post.Table, post.Columns, sqlgraph.NewFieldSpec(post.FieldID, field.TypeString)) if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.UpdatedAt(); ok { _spec.SetField(post.FieldUpdatedAt, field.TypeTime, value) } if value, ok := _u.mutation.DeletedAt(); ok { _spec.SetField(post.FieldDeletedAt, field.TypeTime, value) } if _u.mutation.DeletedAtCleared() { _spec.ClearField(post.FieldDeletedAt, field.TypeTime) } if value, ok := _u.mutation.IndexedAt(); ok { _spec.SetField(post.FieldIndexedAt, field.TypeTime, value) } if _u.mutation.IndexedAtCleared() { _spec.ClearField(post.FieldIndexedAt, field.TypeTime) } if value, ok := _u.mutation.First(); ok { _spec.SetField(post.FieldFirst, field.TypeBool, value) } if value, ok := _u.mutation.Title(); ok { _spec.SetField(post.FieldTitle, field.TypeString, value) } if _u.mutation.TitleCleared() { _spec.ClearField(post.FieldTitle, field.TypeString) } if value, ok := _u.mutation.Slug(); ok { _spec.SetField(post.FieldSlug, field.TypeString, value) } if _u.mutation.SlugCleared() { _spec.ClearField(post.FieldSlug, field.TypeString) } if value, ok := _u.mutation.Pinned(); ok { _spec.SetField(post.FieldPinned, field.TypeBool, value) } if value, ok := _u.mutation.LastReplyAt(); ok { _spec.SetField(post.FieldLastReplyAt, field.TypeTime, value) } if _u.mutation.LastReplyAtCleared() { _spec.ClearField(post.FieldLastReplyAt, field.TypeTime) } if value, ok := _u.mutation.Body(); ok { _spec.SetField(post.FieldBody, field.TypeString, value) } if value, ok := _u.mutation.Short(); ok { _spec.SetField(post.FieldShort, field.TypeString, value) } if value, ok := _u.mutation.Metadata(); ok { _spec.SetField(post.FieldMetadata, field.TypeJSON, value) } if _u.mutation.MetadataCleared() { _spec.ClearField(post.FieldMetadata, field.TypeJSON) } if value, ok := _u.mutation.Visibility(); ok { _spec.SetField(post.FieldVisibility, field.TypeEnum, value) } if _u.mutation.AuthorCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.AuthorTable, Columns: []string{post.AuthorColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.AuthorIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.AuthorTable, Columns: []string{post.AuthorColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.CategoryCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.CategoryTable, Columns: []string{post.CategoryColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(category.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.CategoryIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.CategoryTable, Columns: []string{post.CategoryColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(category.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.TagsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.TagsTable, Columns: post.TagsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedTagsIDs(); len(nodes) > 0 && !_u.mutation.TagsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.TagsTable, Columns: post.TagsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.TagsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.TagsTable, Columns: post.TagsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.RootCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.RootTable, Columns: []string{post.RootColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RootIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.RootTable, Columns: []string{post.RootColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.PostsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostsTable, Columns: []string{post.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedPostsIDs(); len(nodes) > 0 && !_u.mutation.PostsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostsTable, Columns: []string{post.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.PostsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostsTable, Columns: []string{post.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.ReplyToCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.ReplyToTable, Columns: []string{post.ReplyToColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ReplyToIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.ReplyToTable, Columns: []string{post.ReplyToColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.RepliesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.RepliesTable, Columns: []string{post.RepliesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedRepliesIDs(); len(nodes) > 0 && !_u.mutation.RepliesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.RepliesTable, Columns: []string{post.RepliesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RepliesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.RepliesTable, Columns: []string{post.RepliesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.ReactsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.ReactsTable, Columns: []string{post.ReactsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(react.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedReactsIDs(); len(nodes) > 0 && !_u.mutation.ReactsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.ReactsTable, Columns: []string{post.ReactsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(react.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ReactsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.ReactsTable, Columns: []string{post.ReactsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(react.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.LikesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.LikesTable, Columns: []string{post.LikesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(likepost.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedLikesIDs(); len(nodes) > 0 && !_u.mutation.LikesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.LikesTable, Columns: []string{post.LikesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(likepost.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.LikesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.LikesTable, Columns: []string{post.LikesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(likepost.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.MentionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.MentionsTable, Columns: []string{post.MentionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(mentionprofile.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedMentionsIDs(); len(nodes) > 0 && !_u.mutation.MentionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.MentionsTable, Columns: []string{post.MentionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(mentionprofile.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.MentionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.MentionsTable, Columns: []string{post.MentionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(mentionprofile.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.AssetsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: post.AssetsTable, Columns: post.AssetsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedAssetsIDs(); len(nodes) > 0 && !_u.mutation.AssetsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: post.AssetsTable, Columns: post.AssetsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.AssetsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: post.AssetsTable, Columns: post.AssetsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.CollectionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.CollectionsTable, Columns: post.CollectionsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(collection.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedCollectionsIDs(); len(nodes) > 0 && !_u.mutation.CollectionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.CollectionsTable, Columns: post.CollectionsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(collection.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.CollectionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.CollectionsTable, Columns: post.CollectionsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(collection.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.LinkCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.LinkTable, Columns: []string{post.LinkColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(link.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.LinkIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.LinkTable, Columns: []string{post.LinkColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(link.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.ContentLinksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.ContentLinksTable, Columns: post.ContentLinksPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(link.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedContentLinksIDs(); len(nodes) > 0 && !_u.mutation.ContentLinksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.ContentLinksTable, Columns: post.ContentLinksPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(link.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ContentLinksIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.ContentLinksTable, Columns: post.ContentLinksPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(link.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.EventCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.EventTable, Columns: []string{post.EventColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedEventIDs(); len(nodes) > 0 && !_u.mutation.EventCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.EventTable, Columns: []string{post.EventColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.EventIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.EventTable, Columns: []string{post.EventColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.PostReadsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostReadsTable, Columns: []string{post.PostReadsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postread.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedPostReadsIDs(); len(nodes) > 0 && !_u.mutation.PostReadsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostReadsTable, Columns: []string{post.PostReadsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postread.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.PostReadsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostReadsTable, Columns: []string{post.PostReadsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postread.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } _spec.AddModifiers(_u.modifiers...) if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{post.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } _u.mutation.done = true return _node, nil } // PostUpdateOne is the builder for updating a single Post entity. type PostUpdateOne struct { config fields []string hooks []Hook mutation *PostMutation modifiers []func(*sql.UpdateBuilder) } // SetUpdatedAt sets the "updated_at" field. func (_u *PostUpdateOne) SetUpdatedAt(v time.Time) *PostUpdateOne { _u.mutation.SetUpdatedAt(v) return _u } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableUpdatedAt(v *time.Time) *PostUpdateOne { if v != nil { _u.SetUpdatedAt(*v) } return _u } // SetDeletedAt sets the "deleted_at" field. func (_u *PostUpdateOne) SetDeletedAt(v time.Time) *PostUpdateOne { _u.mutation.SetDeletedAt(v) return _u } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableDeletedAt(v *time.Time) *PostUpdateOne { if v != nil { _u.SetDeletedAt(*v) } return _u } // ClearDeletedAt clears the value of the "deleted_at" field. func (_u *PostUpdateOne) ClearDeletedAt() *PostUpdateOne { _u.mutation.ClearDeletedAt() return _u } // SetIndexedAt sets the "indexed_at" field. func (_u *PostUpdateOne) SetIndexedAt(v time.Time) *PostUpdateOne { _u.mutation.SetIndexedAt(v) return _u } // SetNillableIndexedAt sets the "indexed_at" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableIndexedAt(v *time.Time) *PostUpdateOne { if v != nil { _u.SetIndexedAt(*v) } return _u } // ClearIndexedAt clears the value of the "indexed_at" field. func (_u *PostUpdateOne) ClearIndexedAt() *PostUpdateOne { _u.mutation.ClearIndexedAt() return _u } // SetFirst sets the "first" field. func (_u *PostUpdateOne) SetFirst(v bool) *PostUpdateOne { _u.mutation.SetFirst(v) return _u } // SetNillableFirst sets the "first" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableFirst(v *bool) *PostUpdateOne { if v != nil { _u.SetFirst(*v) } return _u } // SetTitle sets the "title" field. func (_u *PostUpdateOne) SetTitle(v string) *PostUpdateOne { _u.mutation.SetTitle(v) return _u } // SetNillableTitle sets the "title" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableTitle(v *string) *PostUpdateOne { if v != nil { _u.SetTitle(*v) } return _u } // ClearTitle clears the value of the "title" field. func (_u *PostUpdateOne) ClearTitle() *PostUpdateOne { _u.mutation.ClearTitle() return _u } // SetSlug sets the "slug" field. func (_u *PostUpdateOne) SetSlug(v string) *PostUpdateOne { _u.mutation.SetSlug(v) return _u } // SetNillableSlug sets the "slug" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableSlug(v *string) *PostUpdateOne { if v != nil { _u.SetSlug(*v) } return _u } // ClearSlug clears the value of the "slug" field. func (_u *PostUpdateOne) ClearSlug() *PostUpdateOne { _u.mutation.ClearSlug() return _u } // SetPinned sets the "pinned" field. func (_u *PostUpdateOne) SetPinned(v bool) *PostUpdateOne { _u.mutation.SetPinned(v) return _u } // SetNillablePinned sets the "pinned" field if the given value is not nil. func (_u *PostUpdateOne) SetNillablePinned(v *bool) *PostUpdateOne { if v != nil { _u.SetPinned(*v) } return _u } // SetLastReplyAt sets the "last_reply_at" field. func (_u *PostUpdateOne) SetLastReplyAt(v time.Time) *PostUpdateOne { _u.mutation.SetLastReplyAt(v) return _u } // SetNillableLastReplyAt sets the "last_reply_at" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableLastReplyAt(v *time.Time) *PostUpdateOne { if v != nil { _u.SetLastReplyAt(*v) } return _u } // ClearLastReplyAt clears the value of the "last_reply_at" field. func (_u *PostUpdateOne) ClearLastReplyAt() *PostUpdateOne { _u.mutation.ClearLastReplyAt() return _u } // SetRootPostID sets the "root_post_id" field. func (_u *PostUpdateOne) SetRootPostID(v xid.ID) *PostUpdateOne { _u.mutation.SetRootPostID(v) return _u } // SetNillableRootPostID sets the "root_post_id" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableRootPostID(v *xid.ID) *PostUpdateOne { if v != nil { _u.SetRootPostID(*v) } return _u } // ClearRootPostID clears the value of the "root_post_id" field. func (_u *PostUpdateOne) ClearRootPostID() *PostUpdateOne { _u.mutation.ClearRootPostID() return _u } // SetReplyToPostID sets the "reply_to_post_id" field. func (_u *PostUpdateOne) SetReplyToPostID(v xid.ID) *PostUpdateOne { _u.mutation.SetReplyToPostID(v) return _u } // SetNillableReplyToPostID sets the "reply_to_post_id" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableReplyToPostID(v *xid.ID) *PostUpdateOne { if v != nil { _u.SetReplyToPostID(*v) } return _u } // ClearReplyToPostID clears the value of the "reply_to_post_id" field. func (_u *PostUpdateOne) ClearReplyToPostID() *PostUpdateOne { _u.mutation.ClearReplyToPostID() return _u } // SetBody sets the "body" field. func (_u *PostUpdateOne) SetBody(v string) *PostUpdateOne { _u.mutation.SetBody(v) return _u } // SetNillableBody sets the "body" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableBody(v *string) *PostUpdateOne { if v != nil { _u.SetBody(*v) } return _u } // SetShort sets the "short" field. func (_u *PostUpdateOne) SetShort(v string) *PostUpdateOne { _u.mutation.SetShort(v) return _u } // SetNillableShort sets the "short" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableShort(v *string) *PostUpdateOne { if v != nil { _u.SetShort(*v) } return _u } // SetMetadata sets the "metadata" field. func (_u *PostUpdateOne) SetMetadata(v map[string]interface{}) *PostUpdateOne { _u.mutation.SetMetadata(v) return _u } // ClearMetadata clears the value of the "metadata" field. func (_u *PostUpdateOne) ClearMetadata() *PostUpdateOne { _u.mutation.ClearMetadata() return _u } // SetVisibility sets the "visibility" field. func (_u *PostUpdateOne) SetVisibility(v post.Visibility) *PostUpdateOne { _u.mutation.SetVisibility(v) return _u } // SetNillableVisibility sets the "visibility" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableVisibility(v *post.Visibility) *PostUpdateOne { if v != nil { _u.SetVisibility(*v) } return _u } // SetAccountPosts sets the "account_posts" field. func (_u *PostUpdateOne) SetAccountPosts(v xid.ID) *PostUpdateOne { _u.mutation.SetAccountPosts(v) return _u } // SetNillableAccountPosts sets the "account_posts" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableAccountPosts(v *xid.ID) *PostUpdateOne { if v != nil { _u.SetAccountPosts(*v) } return _u } // SetCategoryID sets the "category_id" field. func (_u *PostUpdateOne) SetCategoryID(v xid.ID) *PostUpdateOne { _u.mutation.SetCategoryID(v) return _u } // SetNillableCategoryID sets the "category_id" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableCategoryID(v *xid.ID) *PostUpdateOne { if v != nil { _u.SetCategoryID(*v) } return _u } // ClearCategoryID clears the value of the "category_id" field. func (_u *PostUpdateOne) ClearCategoryID() *PostUpdateOne { _u.mutation.ClearCategoryID() return _u } // SetLinkID sets the "link_id" field. func (_u *PostUpdateOne) SetLinkID(v xid.ID) *PostUpdateOne { _u.mutation.SetLinkID(v) return _u } // SetNillableLinkID sets the "link_id" field if the given value is not nil. func (_u *PostUpdateOne) SetNillableLinkID(v *xid.ID) *PostUpdateOne { if v != nil { _u.SetLinkID(*v) } return _u } // ClearLinkID clears the value of the "link_id" field. func (_u *PostUpdateOne) ClearLinkID() *PostUpdateOne { _u.mutation.ClearLinkID() return _u } // SetAuthorID sets the "author" edge to the Account entity by ID. func (_u *PostUpdateOne) SetAuthorID(id xid.ID) *PostUpdateOne { _u.mutation.SetAuthorID(id) return _u } // SetAuthor sets the "author" edge to the Account entity. func (_u *PostUpdateOne) SetAuthor(v *Account) *PostUpdateOne { return _u.SetAuthorID(v.ID) } // SetCategory sets the "category" edge to the Category entity. func (_u *PostUpdateOne) SetCategory(v *Category) *PostUpdateOne { return _u.SetCategoryID(v.ID) } // AddTagIDs adds the "tags" edge to the Tag entity by IDs. func (_u *PostUpdateOne) AddTagIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.AddTagIDs(ids...) return _u } // AddTags adds the "tags" edges to the Tag entity. func (_u *PostUpdateOne) AddTags(v ...*Tag) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddTagIDs(ids...) } // SetRootID sets the "root" edge to the Post entity by ID. func (_u *PostUpdateOne) SetRootID(id xid.ID) *PostUpdateOne { _u.mutation.SetRootID(id) return _u } // SetNillableRootID sets the "root" edge to the Post entity by ID if the given value is not nil. func (_u *PostUpdateOne) SetNillableRootID(id *xid.ID) *PostUpdateOne { if id != nil { _u = _u.SetRootID(*id) } return _u } // SetRoot sets the "root" edge to the Post entity. func (_u *PostUpdateOne) SetRoot(v *Post) *PostUpdateOne { return _u.SetRootID(v.ID) } // AddPostIDs adds the "posts" edge to the Post entity by IDs. func (_u *PostUpdateOne) AddPostIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.AddPostIDs(ids...) return _u } // AddPosts adds the "posts" edges to the Post entity. func (_u *PostUpdateOne) AddPosts(v ...*Post) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddPostIDs(ids...) } // SetReplyToID sets the "replyTo" edge to the Post entity by ID. func (_u *PostUpdateOne) SetReplyToID(id xid.ID) *PostUpdateOne { _u.mutation.SetReplyToID(id) return _u } // SetNillableReplyToID sets the "replyTo" edge to the Post entity by ID if the given value is not nil. func (_u *PostUpdateOne) SetNillableReplyToID(id *xid.ID) *PostUpdateOne { if id != nil { _u = _u.SetReplyToID(*id) } return _u } // SetReplyTo sets the "replyTo" edge to the Post entity. func (_u *PostUpdateOne) SetReplyTo(v *Post) *PostUpdateOne { return _u.SetReplyToID(v.ID) } // AddReplyIDs adds the "replies" edge to the Post entity by IDs. func (_u *PostUpdateOne) AddReplyIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.AddReplyIDs(ids...) return _u } // AddReplies adds the "replies" edges to the Post entity. func (_u *PostUpdateOne) AddReplies(v ...*Post) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddReplyIDs(ids...) } // AddReactIDs adds the "reacts" edge to the React entity by IDs. func (_u *PostUpdateOne) AddReactIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.AddReactIDs(ids...) return _u } // AddReacts adds the "reacts" edges to the React entity. func (_u *PostUpdateOne) AddReacts(v ...*React) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddReactIDs(ids...) } // AddLikeIDs adds the "likes" edge to the LikePost entity by IDs. func (_u *PostUpdateOne) AddLikeIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.AddLikeIDs(ids...) return _u } // AddLikes adds the "likes" edges to the LikePost entity. func (_u *PostUpdateOne) AddLikes(v ...*LikePost) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddLikeIDs(ids...) } // AddMentionIDs adds the "mentions" edge to the MentionProfile entity by IDs. func (_u *PostUpdateOne) AddMentionIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.AddMentionIDs(ids...) return _u } // AddMentions adds the "mentions" edges to the MentionProfile entity. func (_u *PostUpdateOne) AddMentions(v ...*MentionProfile) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddMentionIDs(ids...) } // AddAssetIDs adds the "assets" edge to the Asset entity by IDs. func (_u *PostUpdateOne) AddAssetIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.AddAssetIDs(ids...) return _u } // AddAssets adds the "assets" edges to the Asset entity. func (_u *PostUpdateOne) AddAssets(v ...*Asset) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddAssetIDs(ids...) } // AddCollectionIDs adds the "collections" edge to the Collection entity by IDs. func (_u *PostUpdateOne) AddCollectionIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.AddCollectionIDs(ids...) return _u } // AddCollections adds the "collections" edges to the Collection entity. func (_u *PostUpdateOne) AddCollections(v ...*Collection) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddCollectionIDs(ids...) } // SetLink sets the "link" edge to the Link entity. func (_u *PostUpdateOne) SetLink(v *Link) *PostUpdateOne { return _u.SetLinkID(v.ID) } // AddContentLinkIDs adds the "content_links" edge to the Link entity by IDs. func (_u *PostUpdateOne) AddContentLinkIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.AddContentLinkIDs(ids...) return _u } // AddContentLinks adds the "content_links" edges to the Link entity. func (_u *PostUpdateOne) AddContentLinks(v ...*Link) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddContentLinkIDs(ids...) } // AddEventIDs adds the "event" edge to the Event entity by IDs. func (_u *PostUpdateOne) AddEventIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.AddEventIDs(ids...) return _u } // AddEvent adds the "event" edges to the Event entity. func (_u *PostUpdateOne) AddEvent(v ...*Event) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddEventIDs(ids...) } // AddPostReadIDs adds the "post_reads" edge to the PostRead entity by IDs. func (_u *PostUpdateOne) AddPostReadIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.AddPostReadIDs(ids...) return _u } // AddPostReads adds the "post_reads" edges to the PostRead entity. func (_u *PostUpdateOne) AddPostReads(v ...*PostRead) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddPostReadIDs(ids...) } // Mutation returns the PostMutation object of the builder. func (_u *PostUpdateOne) Mutation() *PostMutation { return _u.mutation } // ClearAuthor clears the "author" edge to the Account entity. func (_u *PostUpdateOne) ClearAuthor() *PostUpdateOne { _u.mutation.ClearAuthor() return _u } // ClearCategory clears the "category" edge to the Category entity. func (_u *PostUpdateOne) ClearCategory() *PostUpdateOne { _u.mutation.ClearCategory() return _u } // ClearTags clears all "tags" edges to the Tag entity. func (_u *PostUpdateOne) ClearTags() *PostUpdateOne { _u.mutation.ClearTags() return _u } // RemoveTagIDs removes the "tags" edge to Tag entities by IDs. func (_u *PostUpdateOne) RemoveTagIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.RemoveTagIDs(ids...) return _u } // RemoveTags removes "tags" edges to Tag entities. func (_u *PostUpdateOne) RemoveTags(v ...*Tag) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveTagIDs(ids...) } // ClearRoot clears the "root" edge to the Post entity. func (_u *PostUpdateOne) ClearRoot() *PostUpdateOne { _u.mutation.ClearRoot() return _u } // ClearPosts clears all "posts" edges to the Post entity. func (_u *PostUpdateOne) ClearPosts() *PostUpdateOne { _u.mutation.ClearPosts() return _u } // RemovePostIDs removes the "posts" edge to Post entities by IDs. func (_u *PostUpdateOne) RemovePostIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.RemovePostIDs(ids...) return _u } // RemovePosts removes "posts" edges to Post entities. func (_u *PostUpdateOne) RemovePosts(v ...*Post) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemovePostIDs(ids...) } // ClearReplyTo clears the "replyTo" edge to the Post entity. func (_u *PostUpdateOne) ClearReplyTo() *PostUpdateOne { _u.mutation.ClearReplyTo() return _u } // ClearReplies clears all "replies" edges to the Post entity. func (_u *PostUpdateOne) ClearReplies() *PostUpdateOne { _u.mutation.ClearReplies() return _u } // RemoveReplyIDs removes the "replies" edge to Post entities by IDs. func (_u *PostUpdateOne) RemoveReplyIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.RemoveReplyIDs(ids...) return _u } // RemoveReplies removes "replies" edges to Post entities. func (_u *PostUpdateOne) RemoveReplies(v ...*Post) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveReplyIDs(ids...) } // ClearReacts clears all "reacts" edges to the React entity. func (_u *PostUpdateOne) ClearReacts() *PostUpdateOne { _u.mutation.ClearReacts() return _u } // RemoveReactIDs removes the "reacts" edge to React entities by IDs. func (_u *PostUpdateOne) RemoveReactIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.RemoveReactIDs(ids...) return _u } // RemoveReacts removes "reacts" edges to React entities. func (_u *PostUpdateOne) RemoveReacts(v ...*React) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveReactIDs(ids...) } // ClearLikes clears all "likes" edges to the LikePost entity. func (_u *PostUpdateOne) ClearLikes() *PostUpdateOne { _u.mutation.ClearLikes() return _u } // RemoveLikeIDs removes the "likes" edge to LikePost entities by IDs. func (_u *PostUpdateOne) RemoveLikeIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.RemoveLikeIDs(ids...) return _u } // RemoveLikes removes "likes" edges to LikePost entities. func (_u *PostUpdateOne) RemoveLikes(v ...*LikePost) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveLikeIDs(ids...) } // ClearMentions clears all "mentions" edges to the MentionProfile entity. func (_u *PostUpdateOne) ClearMentions() *PostUpdateOne { _u.mutation.ClearMentions() return _u } // RemoveMentionIDs removes the "mentions" edge to MentionProfile entities by IDs. func (_u *PostUpdateOne) RemoveMentionIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.RemoveMentionIDs(ids...) return _u } // RemoveMentions removes "mentions" edges to MentionProfile entities. func (_u *PostUpdateOne) RemoveMentions(v ...*MentionProfile) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveMentionIDs(ids...) } // ClearAssets clears all "assets" edges to the Asset entity. func (_u *PostUpdateOne) ClearAssets() *PostUpdateOne { _u.mutation.ClearAssets() return _u } // RemoveAssetIDs removes the "assets" edge to Asset entities by IDs. func (_u *PostUpdateOne) RemoveAssetIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.RemoveAssetIDs(ids...) return _u } // RemoveAssets removes "assets" edges to Asset entities. func (_u *PostUpdateOne) RemoveAssets(v ...*Asset) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveAssetIDs(ids...) } // ClearCollections clears all "collections" edges to the Collection entity. func (_u *PostUpdateOne) ClearCollections() *PostUpdateOne { _u.mutation.ClearCollections() return _u } // RemoveCollectionIDs removes the "collections" edge to Collection entities by IDs. func (_u *PostUpdateOne) RemoveCollectionIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.RemoveCollectionIDs(ids...) return _u } // RemoveCollections removes "collections" edges to Collection entities. func (_u *PostUpdateOne) RemoveCollections(v ...*Collection) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveCollectionIDs(ids...) } // ClearLink clears the "link" edge to the Link entity. func (_u *PostUpdateOne) ClearLink() *PostUpdateOne { _u.mutation.ClearLink() return _u } // ClearContentLinks clears all "content_links" edges to the Link entity. func (_u *PostUpdateOne) ClearContentLinks() *PostUpdateOne { _u.mutation.ClearContentLinks() return _u } // RemoveContentLinkIDs removes the "content_links" edge to Link entities by IDs. func (_u *PostUpdateOne) RemoveContentLinkIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.RemoveContentLinkIDs(ids...) return _u } // RemoveContentLinks removes "content_links" edges to Link entities. func (_u *PostUpdateOne) RemoveContentLinks(v ...*Link) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveContentLinkIDs(ids...) } // ClearEvent clears all "event" edges to the Event entity. func (_u *PostUpdateOne) ClearEvent() *PostUpdateOne { _u.mutation.ClearEvent() return _u } // RemoveEventIDs removes the "event" edge to Event entities by IDs. func (_u *PostUpdateOne) RemoveEventIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.RemoveEventIDs(ids...) return _u } // RemoveEvent removes "event" edges to Event entities. func (_u *PostUpdateOne) RemoveEvent(v ...*Event) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveEventIDs(ids...) } // ClearPostReads clears all "post_reads" edges to the PostRead entity. func (_u *PostUpdateOne) ClearPostReads() *PostUpdateOne { _u.mutation.ClearPostReads() return _u } // RemovePostReadIDs removes the "post_reads" edge to PostRead entities by IDs. func (_u *PostUpdateOne) RemovePostReadIDs(ids ...xid.ID) *PostUpdateOne { _u.mutation.RemovePostReadIDs(ids...) return _u } // RemovePostReads removes "post_reads" edges to PostRead entities. func (_u *PostUpdateOne) RemovePostReads(v ...*PostRead) *PostUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemovePostReadIDs(ids...) } // Where appends a list predicates to the PostUpdate builder. func (_u *PostUpdateOne) Where(ps ...predicate.Post) *PostUpdateOne { _u.mutation.Where(ps...) return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (_u *PostUpdateOne) Select(field string, fields ...string) *PostUpdateOne { _u.fields = append([]string{field}, fields...) return _u } // Save executes the query and returns the updated Post entity. func (_u *PostUpdateOne) Save(ctx context.Context) (*Post, error) { return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *PostUpdateOne) SaveX(ctx context.Context) *Post { node, err := _u.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (_u *PostUpdateOne) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *PostUpdateOne) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. func (_u *PostUpdateOne) check() error { if v, ok := _u.mutation.Visibility(); ok { if err := post.VisibilityValidator(v); err != nil { return &ValidationError{Name: "visibility", err: fmt.Errorf(`ent: validator failed for field "Post.visibility": %w`, err)} } } if _u.mutation.AuthorCleared() && len(_u.mutation.AuthorIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Post.author"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (_u *PostUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PostUpdateOne { _u.modifiers = append(_u.modifiers, modifiers...) return _u } func (_u *PostUpdateOne) sqlSave(ctx context.Context) (_node *Post, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(post.Table, post.Columns, sqlgraph.NewFieldSpec(post.FieldID, field.TypeString)) id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Post.id" for update`)} } _spec.Node.ID.Value = id if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, post.FieldID) for _, f := range fields { if !post.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != post.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, f) } } } if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.UpdatedAt(); ok { _spec.SetField(post.FieldUpdatedAt, field.TypeTime, value) } if value, ok := _u.mutation.DeletedAt(); ok { _spec.SetField(post.FieldDeletedAt, field.TypeTime, value) } if _u.mutation.DeletedAtCleared() { _spec.ClearField(post.FieldDeletedAt, field.TypeTime) } if value, ok := _u.mutation.IndexedAt(); ok { _spec.SetField(post.FieldIndexedAt, field.TypeTime, value) } if _u.mutation.IndexedAtCleared() { _spec.ClearField(post.FieldIndexedAt, field.TypeTime) } if value, ok := _u.mutation.First(); ok { _spec.SetField(post.FieldFirst, field.TypeBool, value) } if value, ok := _u.mutation.Title(); ok { _spec.SetField(post.FieldTitle, field.TypeString, value) } if _u.mutation.TitleCleared() { _spec.ClearField(post.FieldTitle, field.TypeString) } if value, ok := _u.mutation.Slug(); ok { _spec.SetField(post.FieldSlug, field.TypeString, value) } if _u.mutation.SlugCleared() { _spec.ClearField(post.FieldSlug, field.TypeString) } if value, ok := _u.mutation.Pinned(); ok { _spec.SetField(post.FieldPinned, field.TypeBool, value) } if value, ok := _u.mutation.LastReplyAt(); ok { _spec.SetField(post.FieldLastReplyAt, field.TypeTime, value) } if _u.mutation.LastReplyAtCleared() { _spec.ClearField(post.FieldLastReplyAt, field.TypeTime) } if value, ok := _u.mutation.Body(); ok { _spec.SetField(post.FieldBody, field.TypeString, value) } if value, ok := _u.mutation.Short(); ok { _spec.SetField(post.FieldShort, field.TypeString, value) } if value, ok := _u.mutation.Metadata(); ok { _spec.SetField(post.FieldMetadata, field.TypeJSON, value) } if _u.mutation.MetadataCleared() { _spec.ClearField(post.FieldMetadata, field.TypeJSON) } if value, ok := _u.mutation.Visibility(); ok { _spec.SetField(post.FieldVisibility, field.TypeEnum, value) } if _u.mutation.AuthorCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.AuthorTable, Columns: []string{post.AuthorColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.AuthorIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.AuthorTable, Columns: []string{post.AuthorColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.CategoryCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.CategoryTable, Columns: []string{post.CategoryColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(category.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.CategoryIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.CategoryTable, Columns: []string{post.CategoryColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(category.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.TagsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.TagsTable, Columns: post.TagsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedTagsIDs(); len(nodes) > 0 && !_u.mutation.TagsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.TagsTable, Columns: post.TagsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.TagsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.TagsTable, Columns: post.TagsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.RootCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.RootTable, Columns: []string{post.RootColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RootIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.RootTable, Columns: []string{post.RootColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.PostsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostsTable, Columns: []string{post.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedPostsIDs(); len(nodes) > 0 && !_u.mutation.PostsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostsTable, Columns: []string{post.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.PostsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostsTable, Columns: []string{post.PostsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.ReplyToCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.ReplyToTable, Columns: []string{post.ReplyToColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ReplyToIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.ReplyToTable, Columns: []string{post.ReplyToColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.RepliesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.RepliesTable, Columns: []string{post.RepliesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedRepliesIDs(); len(nodes) > 0 && !_u.mutation.RepliesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.RepliesTable, Columns: []string{post.RepliesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RepliesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.RepliesTable, Columns: []string{post.RepliesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.ReactsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.ReactsTable, Columns: []string{post.ReactsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(react.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedReactsIDs(); len(nodes) > 0 && !_u.mutation.ReactsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.ReactsTable, Columns: []string{post.ReactsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(react.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ReactsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.ReactsTable, Columns: []string{post.ReactsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(react.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.LikesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.LikesTable, Columns: []string{post.LikesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(likepost.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedLikesIDs(); len(nodes) > 0 && !_u.mutation.LikesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.LikesTable, Columns: []string{post.LikesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(likepost.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.LikesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.LikesTable, Columns: []string{post.LikesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(likepost.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.MentionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.MentionsTable, Columns: []string{post.MentionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(mentionprofile.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedMentionsIDs(); len(nodes) > 0 && !_u.mutation.MentionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.MentionsTable, Columns: []string{post.MentionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(mentionprofile.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.MentionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.MentionsTable, Columns: []string{post.MentionsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(mentionprofile.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.AssetsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: post.AssetsTable, Columns: post.AssetsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedAssetsIDs(); len(nodes) > 0 && !_u.mutation.AssetsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: post.AssetsTable, Columns: post.AssetsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.AssetsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, Table: post.AssetsTable, Columns: post.AssetsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.CollectionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.CollectionsTable, Columns: post.CollectionsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(collection.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedCollectionsIDs(); len(nodes) > 0 && !_u.mutation.CollectionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.CollectionsTable, Columns: post.CollectionsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(collection.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.CollectionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.CollectionsTable, Columns: post.CollectionsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(collection.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.LinkCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.LinkTable, Columns: []string{post.LinkColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(link.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.LinkIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: post.LinkTable, Columns: []string{post.LinkColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(link.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.ContentLinksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.ContentLinksTable, Columns: post.ContentLinksPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(link.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedContentLinksIDs(); len(nodes) > 0 && !_u.mutation.ContentLinksCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.ContentLinksTable, Columns: post.ContentLinksPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(link.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ContentLinksIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, Table: post.ContentLinksTable, Columns: post.ContentLinksPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(link.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.EventCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.EventTable, Columns: []string{post.EventColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedEventIDs(); len(nodes) > 0 && !_u.mutation.EventCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.EventTable, Columns: []string{post.EventColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.EventIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.EventTable, Columns: []string{post.EventColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(event.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.PostReadsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostReadsTable, Columns: []string{post.PostReadsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postread.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedPostReadsIDs(); len(nodes) > 0 && !_u.mutation.PostReadsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostReadsTable, Columns: []string{post.PostReadsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postread.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.PostReadsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: post.PostReadsTable, Columns: []string{post.PostReadsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(postread.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } _spec.AddModifiers(_u.modifiers...) _node = &Post{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{post.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } _u.mutation.done = true return _node, nil }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server