mirror of
https://github.com/sigmasternchen/threadule
synced 2025-03-15 08:09:01 +00:00
feat: added old tweets on thread update
This commit is contained in:
parent
76cfef10f2
commit
2687d439b3
1 changed files with 14 additions and 4 deletions
|
@ -2,16 +2,26 @@ package data
|
|||
|
||||
import (
|
||||
uuid "github.com/satori/go.uuid"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"threadule/backend/internal/data/models"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (d *Data) UpdateThread(thread *models.Thread) error {
|
||||
return d.db.
|
||||
Omit("Account").
|
||||
Save(thread).
|
||||
Error
|
||||
return d.db.Transaction(func(tx *gorm.DB) error {
|
||||
err := tx.
|
||||
Delete(&models.Tweet{}, "thread_id = ?", thread.ID).
|
||||
Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.
|
||||
Omit("Account").
|
||||
Save(thread).
|
||||
Error
|
||||
})
|
||||
}
|
||||
|
||||
func (d *Data) UpdateThreadWithoutTweets(thread *models.Thread) error {
|
||||
|
|
Loading…
Reference in a new issue