diff --git a/action_check_exists.go b/action_check_exists.go index 14ae682..bc807f5 100644 --- a/action_check_exists.go +++ b/action_check_exists.go @@ -7,10 +7,11 @@ import ( "go.mongodb.org/mongo-driver/bson" ) -func (s Service) IsDeviceIDExisted(ctx context.Context, deviceID string) bool { +func (s Service) IsDeviceIDExisted(deviceID string) bool { var ( col = s.getDeviceCollection() device = Device{} + ctx = context.Background() ) if err := col.FindOne(ctx, bson.M{"deviceId": deviceID}).Decode(&device); err != nil { diff --git a/action_create.go b/action_create.go index 79a9663..832ae1e 100644 --- a/action_create.go +++ b/action_create.go @@ -40,7 +40,7 @@ func (s Service) Create(payload CreateOptions) error { deviceData := payload.newDevice() // Find deviceID existed or not - if s.IsDeviceIDExisted(ctx, deviceData.DeviceID) { + if s.IsDeviceIDExisted(deviceData.DeviceID) { return errors.New("this device is already existed") }