mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
chore: ignore duplicate heartbeat conflicts while inserting
This commit is contained in:
parent
82e9244cdc
commit
242928aba5
@ -3,6 +3,7 @@ package repositories
|
||||
import (
|
||||
"github.com/muety/wakapi/models"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -15,7 +16,11 @@ func NewHeartbeatRepository(db *gorm.DB) *HeartbeatRepository {
|
||||
}
|
||||
|
||||
func (r *HeartbeatRepository) InsertBatch(heartbeats []*models.Heartbeat) error {
|
||||
if err := r.db.Create(&heartbeats).Error; err != nil {
|
||||
if err := r.db.
|
||||
Clauses(clause.OnConflict{
|
||||
DoNothing: true,
|
||||
}).
|
||||
Create(&heartbeats).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -1 +1 @@
|
||||
1.22.3
|
||||
1.22.4
|
Loading…
Reference in New Issue
Block a user