Skip to content

Commit

Permalink
migration: json.forget, json.del, json.nummultby, json.numincrby, jso…
Browse files Browse the repository at this point in the history
…n.toggle commands refactor and migeation
  • Loading branch information
vpsinghg committed Oct 23, 2024
1 parent 7385874 commit 3060bb2
Show file tree
Hide file tree
Showing 7 changed files with 877 additions and 558 deletions.
3 changes: 2 additions & 1 deletion internal/errors/migrated_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ var (
ErrAborted = errors.New("server received ABORT command")
ErrEmptyCommand = errors.New("empty command")
ErrInvalidIPAddress = errors.New("invalid IP address")

ErrWrongKeyType = errors.New("ERR Existing key has wrong Dice type")
ErrKeyDoesNotExist = errors.New("ERR could not perform this operation on a key that doesn't exist")
// Error generation functions for specific error messages with dynamic parameters.
ErrWrongArgumentCount = func(command string) error {
return fmt.Errorf("ERR wrong number of arguments for '%s' command", strings.ToLower(command)) // Indicates an incorrect number of arguments for a given command.
Expand Down
39 changes: 22 additions & 17 deletions internal/eval/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ var (
1.String ("true"/"false") that represents the resulting Boolean value.
2.NONEXISTENT if the document key does not exist.
3.WRONGTYPE error if the value at the path is not a Boolean value.`,
Eval: evalJSONTOGGLE,
Arity: 2,
KeySpecs: KeySpecs{BeginIndex: 1},
Arity: 2,
KeySpecs: KeySpecs{BeginIndex: 1},
IsMigrated: true,
NewEval: evalJSONTOGGLE,
}
jsontypeCmdMeta = DiceCmdMeta{
Name: "JSON.TYPE",
Expand Down Expand Up @@ -187,9 +188,10 @@ var (
Returns an integer reply specified as the number of paths deleted (0 or more).
Returns RespZero if the key doesn't exist or key is expired.
Error reply: If the number of arguments is incorrect.`,
Eval: evalJSONDEL,
Arity: -2,
KeySpecs: KeySpecs{BeginIndex: 1},
Arity: -2,
KeySpecs: KeySpecs{BeginIndex: 1},
IsMigrated: true,
NewEval: evalJSONDEL,
}
jsonarrappendCmdMeta = DiceCmdMeta{
Name: "JSON.ARRAPPEND",
Expand All @@ -205,9 +207,10 @@ var (
Returns an integer reply specified as the number of paths deleted (0 or more).
Returns RespZero if the key doesn't exist or key is expired.
Error reply: If the number of arguments is incorrect.`,
Eval: evalJSONFORGET,
Arity: -2,
KeySpecs: KeySpecs{BeginIndex: 1},
Arity: -2,
KeySpecs: KeySpecs{BeginIndex: 1},
IsMigrated: true,
NewEval: evalJSONFORGET,
}
jsonarrlenCmdMeta = DiceCmdMeta{
Name: "JSON.ARRLEN",
Expand All @@ -223,9 +226,10 @@ var (
Name: "JSON.NUMMULTBY",
Info: `JSON.NUMMULTBY key path value
Multiply the number value stored at the specified path by a value.`,
Eval: evalJSONNUMMULTBY,
Arity: 3,
KeySpecs: KeySpecs{BeginIndex: 1},
Arity: 3,
KeySpecs: KeySpecs{BeginIndex: 1},
IsMigrated: true,
NewEval: evalJSONNUMMULTBY,
}
jsonobjlenCmdMeta = DiceCmdMeta{
Name: "JSON.OBJLEN",
Expand Down Expand Up @@ -949,11 +953,12 @@ var (
Arity: 1,
}
jsonnumincrbyCmdMeta = DiceCmdMeta{
Name: "JSON.NUMINCRBY",
Info: `Increment the number value stored at path by number.`,
Eval: evalJSONNUMINCRBY,
Arity: 3,
KeySpecs: KeySpecs{BeginIndex: 1},
Name: "JSON.NUMINCRBY",
Info: `Increment the number value stored at path by number.`,
Arity: 3,
KeySpecs: KeySpecs{BeginIndex: 1},
IsMigrated: true,
NewEval: evalJSONNUMINCRBY,
}
dumpkeyCMmdMeta = DiceCmdMeta{
Name: "DUMP",
Expand Down
Loading

0 comments on commit 3060bb2

Please sign in to comment.