JSONGetString, JSONGetInt64 리턴 타입 변경

This commit is contained in:
2023-08-10 15:25:40 +09:00
parent b32858cb88
commit e4ac505928

View File

@ -191,12 +191,26 @@ func (rh *RedisonHandler) JSONGet(key, path string, opts ...RedisonGetOption) (r
return rh.Do(rh.ctx, args...).Result()
}
func (rh *RedisonHandler) JSONGetString(key, path string) ([]string, error) {
return respToArray[string](rh.JSONResp(key, path))
func (rh *RedisonHandler) JSONGetString(key, path string) (string, error) {
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) {
return respToArray[int64](rh.JSONResp(key, path))
func (rh *RedisonHandler) JSONGetInt64(key, path string) (int64, error) {
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) {