fix: redis hget

'node_redis: The HGET command contains a invalid argument type.\n' +
'Only strings, dates and buffers are accepted. Please update your code to use valid argument types.'
v1.18.x
Barış Soner Uşaklı 4 years ago
parent e98285dbbb
commit b2ff1594b8

@ -75,7 +75,7 @@ module.exports = function (module) {
if (cachedData[key]) { if (cachedData[key]) {
return cachedData[key].hasOwnProperty(field) ? cachedData[key][field] : null; return cachedData[key].hasOwnProperty(field) ? cachedData[key][field] : null;
} }
return await module.client.async.hget(key, field); return await module.client.async.hget(key, String(field));
}; };
module.getObjectFields = async function (key, fields) { module.getObjectFields = async function (key, fields) {

@ -211,6 +211,11 @@ describe('Hash methods', function () {
done(); done();
}); });
}); });
it('should return null and not error', async () => {
const data = await db.getObjectField('hashTestObject', ['field1', 'field2']);
assert.strictEqual(data, null);
});
}); });
describe('getObjectFields()', function () { describe('getObjectFields()', function () {

Loading…
Cancel
Save