update delete action
This commit is contained in:
parent
1c4cbb1868
commit
d5d0979321
|
@ -2,6 +2,7 @@ package devicemngmt
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/Selly-Modules/logger"
|
||||
|
@ -18,6 +19,11 @@ func (s Service) DeleteByDeviceID(deviceID string) error {
|
|||
}
|
||||
)
|
||||
|
||||
total, _ := col.CountDocuments(ctx, cond)
|
||||
if total == 0 {
|
||||
return errors.New("deviceId not found")
|
||||
}
|
||||
|
||||
// Delete
|
||||
if _, err := col.DeleteOne(ctx, cond); err != nil {
|
||||
logger.Error("devicemngmt - deleteByDeviceID", logger.LogData{
|
||||
|
|
|
@ -2,6 +2,7 @@ package devicemngmt
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/Selly-Modules/logger"
|
||||
|
@ -30,6 +31,11 @@ func (s Service) UpdateByDeviceID(deviceID string, payload UpdateOptions) error
|
|||
}
|
||||
)
|
||||
|
||||
total, _ := col.CountDocuments(ctx, cond)
|
||||
if total == 0 {
|
||||
return errors.New("deviceId not found")
|
||||
}
|
||||
|
||||
// Validate payload
|
||||
err := payload.validate()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue