Skip to content

Commit 4b32ca7

Browse files
committed
(docs) json: add jsdocs
1 parent 6bdb5e7 commit 4b32ca7

24 files changed

+227
-0
lines changed

packages/json/lib/commands/ARRAPPEND.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ import { RedisArgument, NumberReply, ArrayReply, NullReply, Command } from '@red
44

55
export default {
66
IS_READ_ONLY: false,
7+
/**
8+
* Appends one or more values to the end of an array in a JSON document.
9+
* Returns the new array length after append, or null if the path does not exist.
10+
*
11+
* @param parser - The Redis command parser
12+
* @param key - The key to append to
13+
* @param path - Path to the array in the JSON document
14+
* @param json - The first value to append
15+
* @param jsons - Additional values to append
16+
*/
717
parseCommand(
818
parser: CommandParser,
919
key: RedisArgument,

packages/json/lib/commands/ARRINDEX.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ export interface JsonArrIndexOptions {
1111

1212
export default {
1313
IS_READ_ONLY: true,
14+
/**
15+
* Returns the index of the first occurrence of a value in a JSON array.
16+
* If the specified value is not found, it returns -1, or null if the path does not exist.
17+
*
18+
* @param parser - The Redis command parser
19+
* @param key - The key containing the array
20+
* @param path - Path to the array in the JSON document
21+
* @param json - The value to search for
22+
* @param options - Optional range parameters for the search
23+
* @param options.range.start - Starting index for the search
24+
* @param options.range.stop - Optional ending index for the search
25+
*/
1426
parseCommand(
1527
parser: CommandParser,
1628
key: RedisArgument,

packages/json/lib/commands/ARRINSERT.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ import { RedisJSON, transformRedisJsonArgument } from './helpers';
44

55
export default {
66
IS_READ_ONLY: false,
7+
/**
8+
* Inserts one or more values into an array at the specified index.
9+
* Returns the new array length after insert, or null if the path does not exist.
10+
*
11+
* @param parser - The Redis command parser
12+
* @param key - The key containing the array
13+
* @param path - Path to the array in the JSON document
14+
* @param index - The position where to insert the values
15+
* @param json - The first value to insert
16+
* @param jsons - Additional values to insert
17+
*/
718
parseCommand(
819
parser: CommandParser,
920
key: RedisArgument,

packages/json/lib/commands/ARRLEN.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ export interface JsonArrLenOptions {
77

88
export default {
99
IS_READ_ONLY: true,
10+
/**
11+
* Returns the length of an array in a JSON document.
12+
* Returns null if the path does not exist or the value is not an array.
13+
*
14+
* @param parser - The Redis command parser
15+
* @param key - The key containing the array
16+
* @param options - Optional parameters
17+
* @param options.path - Path to the array in the JSON document
18+
*/
1019
parseCommand(parser: CommandParser, key: RedisArgument, options?: JsonArrLenOptions) {
1120
parser.push('JSON.ARRLEN');
1221
parser.pushKey(key);

packages/json/lib/commands/ARRPOP.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ export interface RedisArrPopOptions {
1010

1111
export default {
1212
IS_READ_ONLY: false,
13+
/**
14+
* Removes and returns an element from an array in a JSON document.
15+
* Returns null if the path does not exist or the value is not an array.
16+
*
17+
* @param parser - The Redis command parser
18+
* @param key - The key containing the array
19+
* @param options - Optional parameters
20+
* @param options.path - Path to the array in the JSON document
21+
* @param options.index - Optional index to pop from. Default is -1 (last element)
22+
*/
1323
parseCommand(parser: CommandParser, key: RedisArgument, options?: RedisArrPopOptions) {
1424
parser.push('JSON.ARRPOP');
1525
parser.pushKey(key);

packages/json/lib/commands/ARRTRIM.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ import { RedisArgument, ArrayReply, NumberReply, NullReply, Command } from '@red
33

44
export default {
55
IS_READ_ONLY: false,
6+
/**
7+
* Trims an array in a JSON document to include only elements within the specified range.
8+
* Returns the new array length after trimming, or null if the path does not exist.
9+
*
10+
* @param parser - The Redis command parser
11+
* @param key - The key containing the array
12+
* @param path - Path to the array in the JSON document
13+
* @param start - Starting index (inclusive)
14+
* @param stop - Ending index (inclusive)
15+
*/
616
parseCommand(parser: CommandParser, key: RedisArgument, path: RedisArgument, start: number, stop: number) {
717
parser.push('JSON.ARRTRIM');
818
parser.pushKey(key);

packages/json/lib/commands/CLEAR.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ export interface JsonClearOptions {
77

88
export default {
99
IS_READ_ONLY: false,
10+
/**
11+
* Clears container values (arrays/objects) in a JSON document.
12+
* Returns the number of values cleared (0 or 1), or null if the path does not exist.
13+
*
14+
* @param parser - The Redis command parser
15+
* @param key - The key containing the JSON document
16+
* @param options - Optional parameters
17+
* @param options.path - Path to the container to clear
18+
*/
1019
parseCommand(parser: CommandParser, key: RedisArgument, options?: JsonClearOptions) {
1120
parser.push('JSON.CLEAR');
1221
parser.pushKey(key);

packages/json/lib/commands/DEBUG_MEMORY.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ export interface JsonDebugMemoryOptions {
77

88
export default {
99
IS_READ_ONLY: false,
10+
/**
11+
* Reports memory usage details for a JSON document value.
12+
* Returns size in bytes of the value, or null if the key or path does not exist.
13+
*
14+
* @param parser - The Redis command parser
15+
* @param key - The key containing the JSON document
16+
* @param options - Optional parameters
17+
* @param options.path - Path to the value to examine
18+
*/
1019
parseCommand(parser: CommandParser, key: RedisArgument, options?: JsonDebugMemoryOptions) {
1120
parser.push('JSON.DEBUG', 'MEMORY');
1221
parser.pushKey(key);

packages/json/lib/commands/DEL.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ export interface JsonDelOptions {
77

88
export default {
99
IS_READ_ONLY: false,
10+
/**
11+
* Deletes a value from a JSON document.
12+
* Returns the number of paths deleted (0 or 1), or null if the key does not exist.
13+
*
14+
* @param parser - The Redis command parser
15+
* @param key - The key containing the JSON document
16+
* @param options - Optional parameters
17+
* @param options.path - Path to the value to delete
18+
*/
1019
parseCommand(parser: CommandParser, key: RedisArgument, options?: JsonDelOptions) {
1120
parser.push('JSON.DEL');
1221
parser.pushKey(key);

packages/json/lib/commands/FORGET.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ export interface JsonForgetOptions {
77

88
export default {
99
IS_READ_ONLY: false,
10+
/**
11+
* Alias for JSON.DEL - Deletes a value from a JSON document.
12+
* Returns the number of paths deleted (0 or 1), or null if the key does not exist.
13+
*
14+
* @param parser - The Redis command parser
15+
* @param key - The key containing the JSON document
16+
* @param options - Optional parameters
17+
* @param options.path - Path to the value to delete
18+
*/
1019
parseCommand(parser: CommandParser, key: RedisArgument, options?: JsonForgetOptions) {
1120
parser.push('JSON.FORGET');
1221
parser.pushKey(key);

0 commit comments

Comments
 (0)