niki/repository/redis/redis_otp/exist_phone_number.go

22 lines
466 B
Go
Raw Permalink Normal View History

package redisotp
import (
"context"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
func (d DB) IsExistPhoneNumber(ctx context.Context, phoneNumber string) (bool, error) {
const op = "redisotp.IsExistPhoneNumber"
isExist, err := d.adapter.Client().Exists(ctx, phoneNumber).Result()
if err != nil {
return false, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
}
if isExist == 0 {
return false, nil
}
return true, nil
}