Skip to content

Commit

Permalink
Strip array if forced
Browse files Browse the repository at this point in the history
  • Loading branch information
10A7 committed Feb 10, 2018
1 parent bf59ba5 commit 9823019
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions controllers/base/CachingRedisBackedController.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ class CachingRedisBackedController {
this._getCachedData(redisKey,
(cacheData) => {
let results = JSON.parse(cacheData.data);
let forceArrayed = false;
if (!Array.isArray(results)) {
forceArrayed = true;
results = new Array(results);
}
let resultMap = results.map((result) => {
return this.JSONMapper.mapKeys(keyMapping, result)
});
let ret = { 'success': true };
if (forceArrayed) {
resultMap = resultMap[0];
}
ret[keyMapName] = resultMap;
cb(ret);
});
Expand Down

0 comments on commit 9823019

Please sign in to comment.