Skip to content
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kuzzle-sdk",
"version": "5.0.1",
"version": "5.0.2",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that package.json should be updated by the release PR, not there ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but as I stated last week, I plan to merge this PR directly on master once it is merged on 5.x, and to rewrite the tag to make the 5.x version of this SDK start at 5.0.2 instead of 5.0.0.
So I won't use the release tool and I want to merge this PR as-is, without modifying it before reaching master.

The idea is to avoid major versions jumps, as the 5.x version has to be released before Kuzzle RC10. It is currently unusable anyway, until RC10 is released.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

"description": "Official Javascript SDK for Kuzzle",
"author": "The Kuzzle Team <[email protected]>",
"repository": {
Expand Down
40 changes: 38 additions & 2 deletions src/MemoryStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ var
getIdField = {getter: true, required: ['_id', 'field']},
getKeys = {getter: true, required: ['keys']},
getMember = {getter: true, required: ['_id', 'member']},
getxScan = {getter: true, required: ['_id', 'cursor'], opts: ['match', 'count']},
getxScan = {
getter: true,
required: ['_id', 'cursor'],
opts: ['match', 'count'],
mapResults: mapScanResults
},
getZrange = {
getter: true,
required: ['_id', 'start', 'stop'],
Expand Down Expand Up @@ -112,7 +117,7 @@ var
rpush: {required: ['_id', 'values']},
rpushx: setIdValue,
sadd: {required: ['_id', 'members']},
scan: {getter: true, required: ['cursor'], opts: ['match', 'count']},
scan: {getter: true, required: ['cursor'], opts: ['match', 'count'], mapResults: mapScanResults},
scard: getId,
sdiff: {getter: true, required: ['_id', 'keys']},
sdiffstore: {required: ['_id', 'keys', 'destination']},
Expand Down Expand Up @@ -490,4 +495,35 @@ function mapZrangeResults(results) {
return mapped;
}

/**
* Map *scan calls results, from:
* [
* "<cursor>",
* [
* "value1",
* "value2",
* "..."
* ]
* ]
*
* To:
* {
* cursor: <cursor>,
* values: [
* "value1",
* "value2",
* "..."
* ]
* }
*
* @param {array.<string|array>} results
* @return {object}
*/
function mapScanResults(results) {
return {
cursor: results[0],
values: results[1]
};
}

module.exports = MemoryStorage;
8 changes: 4 additions & 4 deletions test/MemoryStorage/methods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ describe('MemoryStorage methods', function () {
{_id: 'key', cursor: 0},
{count: 42, match: 'foo*'},
[42, ['bar', 'baz', 'qux']],
[42, ['bar', 'baz', 'qux']]
{cursor: 42, values: ['bar', 'baz', 'qux']}
);
});

Expand Down Expand Up @@ -966,7 +966,7 @@ describe('MemoryStorage methods', function () {
{cursor: 0},
{count: 42, match: 'foo*'},
[42, ['bar', 'baz', 'qux']],
[42, ['bar', 'baz', 'qux']]
{cursor: 42, values: ['bar', 'baz', 'qux']}
);
});

Expand Down Expand Up @@ -1158,7 +1158,7 @@ describe('MemoryStorage methods', function () {
{_id: 'key', cursor: 0},
{count: 42, match: 'foo*'},
[42, ['bar', 'baz', 'qux']],
[42, ['bar', 'baz', 'qux']]
{cursor: 42, values: ['bar', 'baz', 'qux']}
);
});

Expand Down Expand Up @@ -1472,7 +1472,7 @@ describe('MemoryStorage methods', function () {
{_id: 'key', cursor: 0},
{count: 42, match: 'foo*'},
[42, ['bar', 'baz', 'qux']],
[42, ['bar', 'baz', 'qux']]
{cursor: 42, values: ['bar', 'baz', 'qux']}
);
});

Expand Down