Client.hDel

最近更新时间:2024-11-29 11:04:52

我的收藏
hDel 方法用于删除一个或多个哈希表字段。
hDel(key: string, ...fields: string[]): number

参数

参数
类型
描述
key
string
键名
...fields
string[]
字段名

返回

类型
描述
number
成功时,返回被删除条目的数量

样例

import redis from "pts/redis";

let client = new redis.Client("redis://:<password>@<host>:6379/0");

export default function main() {
let hSetResp = client.hSet("hash", "k", 1, "k1", 2);
console.log(`redis hSet ${hSetResp}`); // 2
let hDelResp = client.hDel("hash", "k");
console.log(`redis hDel ${hDelResp}`); // 1
}