-
Notifications
You must be signed in to change notification settings - Fork 35
Add path defaults to all commands #12
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
Open
daTokenizer
wants to merge
12
commits into
RedisJSON:master
Choose a base branch
from
daTokenizer:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
23ca197
add path defaults to all commands
daTokenizer f81a9ce
Test Defaults
daTokenizer ca168c5
fix copypasta error :facepalm:
daTokenizer 31f03af
fix set Bug
daTokenizer c109b69
use defaults correctly
daTokenizer 52b0432
init default before first usage
daTokenizer 2e32b9b
use mget correctly
daTokenizer cf502b3
add jsonmgetl
daTokenizer 27f4cdc
mark index as such and test jsonmgetl
daTokenizer 9be918b
again the issue with path and args being inverted :|
daTokenizer 945b449
fix typo
daTokenizer 7bf76ea
add jsonmgetl's API
daTokenizer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,15 +120,26 @@ def jsonmget(self, path, *args): | |
""" | ||
pieces = [] | ||
pieces.extend(args) | ||
if not path: | ||
path=Path.rootPath() | ||
pieces.append(str_path(path)) | ||
return self.execute_command('JSON.MGET', *pieces) | ||
|
||
def jsonmgetl(self, keys=[], path=Path.rootPath()): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Separate PR - |
||
""" | ||
Gets the objects stored as a JSON values under ``path`` from | ||
key list ``keys`` | ||
""" | ||
return self.jsonmget(path, *keys) | ||
|
||
def jsonset(self, name, path, obj, nx=False, xx=False): | ||
""" | ||
Set the JSON value at key ``name`` under the ``path`` to ``obj`` | ||
``nx`` if set to True, set ``value`` only if it does not exist | ||
``xx`` if set to True, set ``value`` only if it exists | ||
""" | ||
if not path: | ||
path=Path.rootPath() | ||
pieces = [name, str_path(path), self._encode(obj)] | ||
|
||
# Handle existential modifiers | ||
|
@@ -152,13 +163,17 @@ def jsonnumincrby(self, name, path, number): | |
Increments the numeric (integer or floating point) JSON value under | ||
``path`` at key ``name`` by the provided ``number`` | ||
""" | ||
if not path: | ||
path=Path.rootPath() | ||
return self.execute_command('JSON.NUMINCRBY', name, str_path(path), self._encode(number)) | ||
|
||
def jsonnummultby(self, name, path, number): | ||
""" | ||
Multiplies the numeric (integer or floating point) JSON value under | ||
``path`` at key ``name`` with the provided ``number`` | ||
""" | ||
if not path: | ||
path=Path.rootPath() | ||
return self.execute_command('JSON.NUMMULTBY', name, str_path(path), self._encode(number)) | ||
|
||
def jsonstrappend(self, name, string, path=Path.rootPath()): | ||
|
@@ -175,11 +190,13 @@ def jsonstrlen(self, name, path=Path.rootPath()): | |
""" | ||
return self.execute_command('JSON.STRLEN', name, str_path(path)) | ||
|
||
def jsonarrappend(self, name, path=Path.rootPath(), *args): | ||
def jsonarrappend(self, name, path, *args): | ||
""" | ||
Appends the objects ``args`` to the array under the ``path` in key | ||
``name`` | ||
""" | ||
if not path: | ||
path=Path.rootPath() | ||
pieces = [name, str_path(path)] | ||
for o in args: | ||
pieces.append(self._encode(o)) | ||
|
@@ -191,13 +208,17 @@ def jsonarrindex(self, name, path, scalar, start=0, stop=-1): | |
``name``. The search can be limited using the optional inclusive | ||
``start`` and exclusive ``stop`` indices. | ||
""" | ||
if not path: | ||
path=Path.rootPath() | ||
return self.execute_command('JSON.ARRINDEX', name, str_path(path), self._encode(scalar), start, stop) | ||
|
||
def jsonarrinsert(self, name, path, index, *args): | ||
""" | ||
Inserts the objects ``args`` to the array at index ``index`` under the | ||
``path` in key ``name`` | ||
""" | ||
if not path: | ||
path=Path.rootPath() | ||
pieces = [name, str_path(path), index] | ||
for o in args: | ||
pieces.append(self._encode(o)) | ||
|
@@ -222,6 +243,8 @@ def jsonarrtrim(self, name, path, start, stop): | |
Trim the array JSON value under ``path`` at key ``name`` to the | ||
inclusive range given by ``start`` and ``stop`` | ||
""" | ||
if not path: | ||
path=Path.rootPath() | ||
return self.execute_command('JSON.ARRTRIM', name, str_path(path), start, stop) | ||
|
||
def jsonobjkeys(self, name, path=Path.rootPath()): | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate PR