Determine the type of value stored at key
The TYPE command returns the string representation of the type of the value stored at key. The different types that can be returned are: string, list, set, zset, hash and stream.
method
Determine the type of value stored at key
The TYPE command returns the string representation of the type of the value stored at key. The different types that can be returned are: string, list, set, zset, hash and stream.
The key to check
Promise that resolves with the type of value stored at key, or "none" if the key doesn't exist
await redis.set("mykey", "Hello");
console.log(await redis.type("mykey")); // "string"
await redis.lpush("mylist", "value");
console.log(await redis.type("mylist")); // "list"
await redis.sadd("myset", "value");
console.log(await redis.type("myset")); // "set"
await redis.hset("myhash", "field", "value");
console.log(await redis.type("myhash")); // "hash"
console.log(await redis.type("nonexistent")); // "none"