Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis JSON SDK documentation fixes #398

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,14 @@
"redis/sdks/py/commands/json/del",
"redis/sdks/py/commands/json/forget",
"redis/sdks/py/commands/json/get",
"redis/sdks/py/commands/json/merge",
"redis/sdks/py/commands/json/mget",
"redis/sdks/py/commands/json/mset",
"redis/sdks/py/commands/json/numincrby",
"redis/sdks/py/commands/json/nummultby",
"redis/sdks/py/commands/json/objkeys",
"redis/sdks/py/commands/json/objlen",
"redis/sdks/py/commands/json/resp",
"redis/sdks/py/commands/json/set",
"redis/sdks/py/commands/json/strappend",
"redis/sdks/py/commands/json/strlen",
Expand Down
2 changes: 1 addition & 1 deletion redis/sdks/py/commands/json/arrappend.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To specify a string as an array value to append, wrap the quoted string with an

## Response

<ResponseField type="int" required>
<ResponseField type="List[int]" required>
The length of the array after the appending.
</ResponseField>

Expand Down
4 changes: 2 additions & 2 deletions redis/sdks/py/commands/json/arrindex.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Search for the first occurrence of a JSON value in an array.
<ParamField body="key" type="str" required>
The key of the json entry.
</ParamField>
<ParamField body="path" type="str" default="$">
<ParamField body="path" type="str" required>
The path of the array.
</ParamField>

Expand All @@ -26,7 +26,7 @@ description: Search for the first occurrence of a JSON value in an array.

## Response

<ResponseField type="int" required>
<ResponseField type="List[int]" required>
The index of the first occurrence of the value in the array, or -1 if not found.
</ResponseField>

Expand Down
4 changes: 2 additions & 2 deletions redis/sdks/py/commands/json/arrinsert.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Insert the json values into the array at path before the index (shi
<ParamField body="key" type="str" required>
The key of the json entry.
</ParamField>
<ParamField body="path" type="str" default="$">
<ParamField body="path" type="str" required>
The path of the array.
</ParamField>

Expand All @@ -23,7 +23,7 @@ description: Insert the json values into the array at path before the index (shi

## Response

<ResponseField type="int" required>
<ResponseField type="List[int]" required>
The length of the array after the insertion.
</ResponseField>

Expand Down
2 changes: 1 addition & 1 deletion redis/sdks/py/commands/json/arrlen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description: Report the length of the JSON array at `path` in `key`.

## Response

<ResponseField type="int" required>
<ResponseField type="List[int]" required>
The length of the array.
</ResponseField>

Expand Down
8 changes: 4 additions & 4 deletions redis/sdks/py/commands/json/arrpop.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Remove and return an element from the index in the array. By defaul
<ParamField body="key" type="str" required>
The key of the json entry.
</ParamField>
<ParamField body="path" type="str">
<ParamField body="path" type="str" default="$">
The path of the array.
</ParamField>

Expand All @@ -21,16 +21,16 @@ description: Remove and return an element from the index in the array. By defaul

## Response

<ResponseField type="TValue | null" required>
<ResponseField type="List[TValue | null]" required>
The popped element or null if the array is empty.
</ResponseField>

<RequestExample>
```py Example
element = redis.json("key", "$.path.to.array")
element = redis.json.arrpop("key", "$.path.to.array")
```

```py First
firstElement = redis.json("key", "$.path.to.array", 0)
firstElement = redis.json.arrpop("key", "$.path.to.array", 0)
```
</RequestExample>
4 changes: 2 additions & 2 deletions redis/sdks/py/commands/json/arrtrim.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Trim an array so that it contains only the specified inclusive rang
<ParamField body="key" type="str" required>
The key of the json entry.
</ParamField>
<ParamField body="path" type="str" default="$">
<ParamField body="path" type="str" required>
The path of the array.
</ParamField>

Expand All @@ -23,7 +23,7 @@ description: Trim an array so that it contains only the specified inclusive rang

## Response

<ResponseField type="int" required>
<ResponseField type="List[int]" required>
The length of the array after the trimming.
</ResponseField>

Expand Down
4 changes: 2 additions & 2 deletions redis/sdks/py/commands/json/clear.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ description: Clear container values (arrays/objects) and set numeric values to 0

## Response

<ResponseField type="int" required>
The length of the array after the appending.
<ResponseField type="List[int]" required>
How many keys cleared from the objects.
</ResponseField>

<RequestExample>
Expand Down
6 changes: 0 additions & 6 deletions redis/sdks/py/commands/json/del.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ description: Delete a key from a JSON document.
</ParamField>



<ParamField body="value" type="...TValue[]" required>
One or more values to append to the array.
</ParamField>


## Response

<ResponseField type="int" required>
Expand Down
6 changes: 0 additions & 6 deletions redis/sdks/py/commands/json/forget.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ description: Delete a key from a JSON document.
</ParamField>



<ParamField body="value" type="...TValue[]" required>
One or more values to append to the array.
</ParamField>


## Response

<ResponseField type="int" required>
Expand Down
28 changes: 1 addition & 27 deletions redis/sdks/py/commands/json/get.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,13 @@ description: Get a single value from a JSON document.
The key of the json entry.
</ParamField>

<ParamField body="options">
<Expandable>
<ParamField body="indent" type="str">
Sets the indentation string for nested levels.
</ParamField>

<ParamField body="newline" type="str">
Sets the string that's printed at the end of each line.
</ParamField>

<ParamField body="space" type="str">
Sets the string that is put between a key and a value.
</ParamField>

</Expandable>

</ParamField>

<ParamField body="paths" type="*List[str]" default="$">
One or more paths to retrieve from the JSON document.
</ParamField>

## Response

<ResponseField type="TValue | null" required>
<ResponseField type="List[TValue | null]" required>
The value at the specified path or `null` if the path does not exist.
</ResponseField>

Expand All @@ -42,12 +24,4 @@ description: Get a single value from a JSON document.
value = redis.json.get("key", "$.path.to.somewhere")
```

```py With Options
value = redis.json.get("key", {
indent: " ",
newline: "\n",
space: " ",
}, "$.path.to.somewhere")
```

</RequestExample>
32 changes: 32 additions & 0 deletions redis/sdks/py/commands/json/merge.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: JSON.MERGE
description: Merges the JSON value at path in key with the provided value.
---

## Arguments

<ParamField body="key" type="str" required>
The key of the json entry.
</ParamField>
<ParamField body="path" type="str" required>
The path of the value to set.
</ParamField>



<ParamField body="value" type="TValue" required>
The value to merge with.
</ParamField>


## Response

<ResponseField type="true" required>
Returns true if the merge was successful.
</ResponseField>

<RequestExample>
```py Example
redis.json.merge("key", "$.path.to.value", {"new": "value"})
```
</RequestExample>
6 changes: 3 additions & 3 deletions redis/sdks/py/commands/json/mget.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ description: Get the same path from multiple JSON documents.

## Arguments

<ParamField body="keys" type="*List[str]" required>
<ParamField body="keys" type="List[str]" required>
One or more keys of JSON documents.
</ParamField>

<ParamField body="path" type="str" default="$">
<ParamField body="path" type="str" required>
The path to get from the JSON document.
</ParamField>

## Response

<ResponseField type="TValue[]" required>
<ResponseField type="List[List[TValue]]" required>
The values at the specified path or `null` if the path does not exist.
</ResponseField>

Expand Down
22 changes: 22 additions & 0 deletions redis/sdks/py/commands/json/mset.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: JSON.MSET
description: Sets multiple JSON values at multiple paths in multiple keys.
---

## Arguments

<ParamField body="key_path_value_tuples" type="List[Tuple[string, string, TValue]" required>
A list of tuples where each tuple contains a key, a path, and a value.
</ParamField>

## Response

<ResponseField type="true" required>
Returns true if the operation was successful.
</ResponseField>

<RequestExample>
```py Example
redis.json.set([(key, "$.path", value), (key2, "$.path2", value2)])
```
</RequestExample>
8 changes: 4 additions & 4 deletions redis/sdks/py/commands/json/numincrby.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ description: Increment the number value stored at `path` by number.
<ParamField body="key" type="str" required>
The key of the json entry.
</ParamField>
<ParamField body="path" type="str" default="$">
The path of the array.
<ParamField body="path" type="str" required>
The path of the number.
</ParamField>


Expand All @@ -22,12 +22,12 @@ description: Increment the number value stored at `path` by number.

## Response

<ResponseField type="int" required>
<ResponseField type="List[int]" required>
The new value after incrementing
</ResponseField>

<RequestExample>
```py Example
newValue = redis.json.numincrby("key", "$.path.to.array", 2)
newValue = redis.json.numincrby("key", "$.path.to.value", 2)
```
</RequestExample>
8 changes: 4 additions & 4 deletions redis/sdks/py/commands/json/nummultby.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ description: Multiply the number value stored at `path` by number.
<ParamField body="key" type="str" required>
The key of the json entry.
</ParamField>
<ParamField body="path" type="str" default="$">
The path of the array.
<ParamField body="path" type="str" required>
The path of the number.
</ParamField>


Expand All @@ -22,12 +22,12 @@ description: Multiply the number value stored at `path` by number.

## Response

<ResponseField type="int" required>
<ResponseField type="List[int]" required>
The new value after multiplying
</ResponseField>

<RequestExample>
```py Example
newValue = redis.json.nummultby("key", "$.path.to.array", 2)
newValue = redis.json.nummultby("key", "$.path.to.value", 2)
```
</RequestExample>
4 changes: 2 additions & 2 deletions redis/sdks/py/commands/json/objkeys.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ description: Return the keys in the object that`s referenced by path.
The key of the json entry.
</ParamField>
<ParamField body="path" type="str" default="$">
The path of the array.
The path of the object.
</ParamField>



## Response

<ResponseField type="List[str]" required>
<ResponseField type="List[List[str]]" required>
The keys of the object at the path.
</ResponseField>

Expand Down
6 changes: 3 additions & 3 deletions redis/sdks/py/commands/json/objlen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ description: Report the number of keys in the JSON object at `path` in `key`.
The key of the json entry.
</ParamField>
<ParamField body="path" type="str" default="$">
The path of the array.
The path of the object.
</ParamField>



## Response

<ResponseField type="int[]" required>
The number of in the objects.
<ResponseField type="List[int]" required>
The number of keys in the objects.
</ResponseField>

<RequestExample>
Expand Down
27 changes: 27 additions & 0 deletions redis/sdks/py/commands/json/resp.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: JSON.RESP
description: Return the value at the path in Redis serialization protocol format.
---

## Arguments

<ParamField body="key" type="str" required>
The key of the json entry.
</ParamField>
<ParamField body="path" type="str" default="$">
The path of the object.
</ParamField>



## Response

<ResponseField type="TValue" required>
Return the value at the path in Redis serialization protocol format.
</ResponseField>

<RequestExample>
```py Example
resp = redis.json.resp("key", "$.path")
```
</RequestExample>
Loading