import type { CommandOptions } from "./command"; import { Command } from "./command"; /** * @see https://redis.io/commands/json.set * @see node_modules/@upstash/redis/docs/commands/json/set.mdx */ export class JsonSetCommand< TData extends | number | string | boolean | Record | (number | string | boolean | Record)[], > extends Command<"OK" | null, "OK" | null> { constructor( cmd: [ key: string, path: string, value: TData, opts?: { nx: true; xx?: never } | { nx?: never; xx: true }, ], opts?: CommandOptions<"OK" | null, "OK" | null> ) { const command = ["JSON.SET", cmd[0], cmd[1], cmd[2]]; if (cmd[3]) { if (cmd[3].nx) { command.push("NX"); } else if (cmd[3].xx) { command.push("XX"); } } super(command, opts); } }