Soft delete device
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user