update IsDeviceIDExisted
This commit is contained in:
parent
2a9870b3d4
commit
1c4cbb1868
|
@ -9,17 +9,17 @@ import (
|
||||||
|
|
||||||
func (s Service) IsDeviceIDExisted(deviceID string) bool {
|
func (s Service) IsDeviceIDExisted(deviceID string) bool {
|
||||||
var (
|
var (
|
||||||
col = s.getDeviceCollection()
|
col = s.getDeviceCollection()
|
||||||
device = Device{}
|
ctx = context.Background()
|
||||||
ctx = context.Background()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if err := col.FindOne(ctx, bson.M{"deviceId": deviceID}).Decode(&device); err != nil {
|
total, err := col.CountDocuments(ctx, bson.M{"deviceId": deviceID})
|
||||||
logger.Error("devicemngmt - findByDeviceID", logger.LogData{
|
if err != nil {
|
||||||
|
logger.Error("devicemngmt - isDeviceIDExisted", logger.LogData{
|
||||||
"deviceId": deviceID,
|
"deviceId": deviceID,
|
||||||
"err": err.Error(),
|
"err": err.Error(),
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return !device.ID.IsZero()
|
return total != 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue