This object unfortunately evaluates as truthy and therefore requires the user to check if keys are present in the object to determine whether the hash actually existed.
This appears to differ from the current behavior of both get and hget.
Example
const foo = await context.redis.hgetall('foo'); // no hash actually exists at key 'foo'
if (foo) {
console.log('foo is true'); // this will be output
}
console.log(foo); // [Object object]
Info
If a given key does not exist,
hgetall
returns an empty object rather thanundefined
as the typehint suggests.https://github.com/reddit/devvit/blob/fb29ce4fb63b82bc0d8b91f9a6c0c76688d6ae02/packages/public-api/src/types/redis.ts#L511
This object unfortunately evaluates as truthy and therefore requires the user to check if keys are present in the object to determine whether the hash actually existed.
This appears to differ from the current behavior of both
get
andhget
.Example