From 4d255acfc6a0294760e8fb6a6d2c918cd8514f97 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Thu, 18 May 2017 14:15:15 -0700 Subject: [PATCH] Consider all object params as keys if none exists --- lib/local-cache.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/local-cache.js b/lib/local-cache.js index 168ab3f..198c605 100644 --- a/lib/local-cache.js +++ b/lib/local-cache.js @@ -100,6 +100,13 @@ function refresh(callback) { return counter = 0; } + // If no keys are defined, consider all parameters as keys to keep the + // same behavior from v1.0 + for (let obj of objects) { + if (!obj["_keys"] || !obj["_keys"].length) + obj["_keys"] = Object.keys(obj).filter(k => !k.startsWith("_")); + } + res.sort((a, b) => { if (a.weight === b.weight) return a._id > b._id;