niki/repository/redis/redis_otp/exist_phone_number.go

21 lines
465 B
Go
Raw 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
}