JSONGetString, JSONGetInt64 리턴 타입 변경
This commit is contained in:
22
redis.go
22
redis.go
@ -191,12 +191,26 @@ func (rh *RedisonHandler) JSONGet(key, path string, opts ...RedisonGetOption) (r
|
|||||||
return rh.Do(rh.ctx, args...).Result()
|
return rh.Do(rh.ctx, args...).Result()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rh *RedisonHandler) JSONGetString(key, path string) ([]string, error) {
|
func (rh *RedisonHandler) JSONGetString(key, path string) (string, error) {
|
||||||
return respToArray[string](rh.JSONResp(key, path))
|
arr, err := respToArray[string](rh.JSONResp(key, path))
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if len(arr) > 0 {
|
||||||
|
return arr[0], nil
|
||||||
|
}
|
||||||
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rh *RedisonHandler) JSONGetInt64(key, path string) ([]int64, error) {
|
func (rh *RedisonHandler) JSONGetInt64(key, path string) (int64, error) {
|
||||||
return respToArray[int64](rh.JSONResp(key, path))
|
arr, err := respToArray[int64](rh.JSONResp(key, path))
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
if len(arr) > 0 {
|
||||||
|
return arr[0], nil
|
||||||
|
}
|
||||||
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rh *RedisonHandler) JSONMGet(path string, keys ...string) (res any, err error) {
|
func (rh *RedisonHandler) JSONMGet(path string, keys ...string) (res any, err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user