Soft delete device

This commit is contained in:
Nedim
2023-09-14 18:33:27 +02:00
parent dc728c4183
commit 56bb362e51
5 changed files with 52 additions and 30 deletions

View File

@@ -1,6 +1,8 @@
package models
import "github.com/jinzhu/gorm"
import (
"github.com/jinzhu/gorm"
)
type Device struct {
gorm.Model
@@ -18,6 +20,12 @@ func (Device) Update() (bool, error) {
func (Device) Create() (bool, error) {
return false, nil
}
func (Device) Delete() (bool, error) {
return false, nil
func (d *Device) Delete(db *gorm.DB) (bool, error) {
// Soft delete the device record.
if err := db.Delete(d).Error; err != nil {
return false, err
}
return true, nil
}