1
0
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:
Ferdinand Mütsch 2021-02-06 00:33:20 +01:00
parent 82e9244cdc
commit 242928aba5
2 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -1 +1 @@
1.22.3
1.22.4