Skip to content

Commit dcf34b4

Browse files
committed
RI-4985 use new jsonpath syntax
1 parent 975f2b9 commit dcf34b4

File tree

19 files changed

+304
-215
lines changed

19 files changed

+304
-215
lines changed

redisinsight/api/src/__mocks__/databases.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ export const mockDatabaseModules = [
7979
semanticVersion: '1.2.5',
8080
},
8181
];
82+
83+
export const mockDatabaseWithModules = Object.assign(new Database(), {
84+
...mockDatabase,
85+
modules: mockDatabaseModules,
86+
});
87+
8288
export const mockDatabaseWithCloudDetails = Object.assign(new Database(), {
8389
...mockDatabase,
8490
cloudDetails: mockCloudDatabaseDetails,

redisinsight/api/src/modules/browser/keys/key-info/strategies/rejson-rl.key-info.strategy.spec.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ describe('RejsonRlKeyInfoStrategy', () => {
3535

3636
describe('getInfo', () => {
3737
const key = getKeyInfoResponse.name;
38-
const path = '.';
3938
beforeEach(() => {
4039
when(mockStandaloneRedisClient.sendPipeline)
4140
.calledWith([
@@ -48,13 +47,13 @@ describe('RejsonRlKeyInfoStrategy', () => {
4847
]);
4948
when(mockStandaloneRedisClient.sendCommand)
5049
.calledWith(
51-
[BrowserToolRejsonRlCommands.JsonType, key, path],
50+
[BrowserToolRejsonRlCommands.JsonType, key],
5251
{ replyEncoding: 'utf8' },
5352
)
5453
.mockResolvedValue('object');
5554
when(mockStandaloneRedisClient.sendCommand)
5655
.calledWith(
57-
[BrowserToolRejsonRlCommands.JsonObjLen, key, path],
56+
[BrowserToolRejsonRlCommands.JsonObjLen, key],
5857
{ replyEncoding: 'utf8' },
5958
)
6059
.mockResolvedValue(10);
@@ -71,13 +70,13 @@ describe('RejsonRlKeyInfoStrategy', () => {
7170
it('should return appropriate value for key that store string', async () => {
7271
when(mockStandaloneRedisClient.sendCommand)
7372
.calledWith(
74-
[BrowserToolRejsonRlCommands.JsonType, key, path],
73+
[BrowserToolRejsonRlCommands.JsonType, key],
7574
{ replyEncoding: 'utf8' },
7675
)
7776
.mockResolvedValue('string');
7877
when(mockStandaloneRedisClient.sendCommand)
7978
.calledWith(
80-
[BrowserToolRejsonRlCommands.JsonStrLen, key, path],
79+
[BrowserToolRejsonRlCommands.JsonStrLen, key],
8180
{ replyEncoding: 'utf8' },
8281
)
8382
.mockResolvedValue(10);
@@ -93,13 +92,13 @@ describe('RejsonRlKeyInfoStrategy', () => {
9392
it('should return appropriate value for key that store array', async () => {
9493
when(mockStandaloneRedisClient.sendCommand)
9594
.calledWith(
96-
[BrowserToolRejsonRlCommands.JsonType, key, path],
95+
[BrowserToolRejsonRlCommands.JsonType, key],
9796
{ replyEncoding: 'utf8' },
9897
)
9998
.mockResolvedValue('array');
10099
when(mockStandaloneRedisClient.sendCommand)
101100
.calledWith(
102-
[BrowserToolRejsonRlCommands.JsonArrLen, key, path],
101+
[BrowserToolRejsonRlCommands.JsonArrLen, key],
103102
{ replyEncoding: 'utf8' },
104103
)
105104
.mockResolvedValue(10);
@@ -115,7 +114,7 @@ describe('RejsonRlKeyInfoStrategy', () => {
115114
it('should return appropriate value for key that store not iterable type', async () => {
116115
when(mockStandaloneRedisClient.sendCommand)
117116
.calledWith(
118-
[BrowserToolRejsonRlCommands.JsonType, key, path],
117+
[BrowserToolRejsonRlCommands.JsonType, key],
119118
{ replyEncoding: 'utf8' },
120119
)
121120
.mockResolvedValue('boolean');

redisinsight/api/src/modules/browser/keys/key-info/strategies/rejson-rl.key-info.strategy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,24 @@ export class RejsonRlKeyInfoStrategy extends KeyInfoStrategy {
3636
private async getLength(client: RedisClient, key: RedisString): Promise<number> {
3737
try {
3838
const objectKeyType = await client.sendCommand(
39-
[BrowserToolRejsonRlCommands.JsonType, key, '.'],
39+
[BrowserToolRejsonRlCommands.JsonType, key],
4040
{ replyEncoding: 'utf8' },
4141
);
4242

4343
switch (objectKeyType) {
4444
case 'object':
4545
return await client.sendCommand(
46-
[BrowserToolRejsonRlCommands.JsonObjLen, key, '.'],
46+
[BrowserToolRejsonRlCommands.JsonObjLen, key],
4747
{ replyEncoding: 'utf8' },
4848
) as number;
4949
case 'array':
5050
return await client.sendCommand(
51-
[BrowserToolRejsonRlCommands.JsonArrLen, key, '.'],
51+
[BrowserToolRejsonRlCommands.JsonArrLen, key],
5252
{ replyEncoding: 'utf8' },
5353
) as number;
5454
case 'string':
5555
return await client.sendCommand(
56-
[BrowserToolRejsonRlCommands.JsonStrLen, key, '.'],
56+
[BrowserToolRejsonRlCommands.JsonStrLen, key],
5757
{ replyEncoding: 'utf8' },
5858
) as number;
5959
default:

redisinsight/api/src/modules/browser/rejson-rl/dto/get.rejson-rl.dto.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ export class GetRejsonRlDto extends KeyDto {
66
@ApiPropertyOptional({
77
type: String,
88
description: 'Path to look for data',
9-
})
9+
})
1010
@IsString()
1111
@IsNotEmpty()
12-
path?: string = '.';
12+
path?: string = '$';
1313

1414
@ApiPropertyOptional({
1515
type: Boolean,
1616
description:
17-
"Don't check for json size and return whole json in path when enabled",
18-
})
17+
"Don't check for json size and return whole json in path when enabled",
18+
})
1919
@IsBoolean()
2020
forceRetrieve?: boolean;
2121
}

0 commit comments

Comments
 (0)