Skip to content

Commit

Permalink
Add SavePost method to Post struct
Browse files Browse the repository at this point in the history
  • Loading branch information
JonyBepary committed Oct 18, 2023
1 parent 0b246e6 commit 39dc83d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions internal/model/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ func (p *Post) SavePost() error {
Author VARCHAR(128),
Parent INT,
Rank INT,
Children VARCHAR(128),
Tags VARCHAR(128),
Mentions VARCHAR(128),
IsSensitive bool,
IsNsfw bool,
IsDeleted bool,
Expand All @@ -51,7 +48,7 @@ func (p *Post) SavePost() error {
panic(err)
}
str2 := `
INSERT INTO Post (Id,Community,Content,CreatedAt,UpdatedAt,DeletedAt,Likes,Shares,Comments,Author,Parent,Rank,Children,Tags,Mentions,IsSensitive,IsNsfw,IsDeleted,IsPinned,IsEdited,IsLiked,IsShared,IsCommented,IsSubscribed,IsBookmarked,IsReblogged,IsMentioned,IsPoll,IsPollVoted,IsPollExpired,IsPollClosed,IsPollMultiple,IsPollHideTotals) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
INSERT INTO Post (Id,Community,Content,CreatedAt,UpdatedAt,DeletedAt,Likes,Shares,Comments,Author,Parent,Rank,IsSensitive,IsNsfw,IsDeleted,IsPinned,IsEdited,IsLiked,IsShared,IsCommented,IsSubscribed,IsBookmarked,IsReblogged,IsMentioned,IsPoll,IsPollVoted,IsPollExpired,IsPollClosed,IsPollMultiple,IsPollHideTotals) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
`
statement, err := db.Prepare(str2)
if err != nil {
Expand All @@ -69,9 +66,6 @@ INSERT INTO Post (Id,Community,Content,CreatedAt,UpdatedAt,DeletedAt,Likes,Share
p.Author,
p.Parent,
p.Rank,
p.Children[0],
p.Tags[0],
p.Mentions[0],
p.IsSensitive,
p.IsNsfw,
p.IsDeleted,
Expand All @@ -90,7 +84,7 @@ INSERT INTO Post (Id,Community,Content,CreatedAt,UpdatedAt,DeletedAt,Likes,Share
p.IsPollClosed,
p.IsPollMultiple,
p.IsPollHideTotals,
p.IsPollHideTotals
p.IsPollHideTotals,
)
if err != nil {
panic(err)
Expand Down

0 comments on commit 39dc83d

Please sign in to comment.