import { type Deno } from "https://deno.land/x/deno@v2.0.4/cli/tsc/dts/lib.deno.unstable.d.ts";
const { KvMutation } = Deno;
UNSTABLE: New API, yet to be vetted.
A mutation to a key in a Deno.Kv
. A mutation is a
combination of a key, a value, and a type. The type determines how the
mutation is applied to the key.
set
- Sets the value of the key to the given value, overwriting any existing value. Optionally anexpireIn
option can be specified to set a time-to-live (TTL) for the key. The TTL is specified in milliseconds, and the key will be deleted from the database at earliest after the specified number of milliseconds have elapsed. Once the specified duration has passed, the key may still be visible for some additional time. If theexpireIn
option is not specified, the key will not expire.delete
- Deletes the key from the database. The mutation is a no-op if the key does not exist.sum
- Adds the given value to the existing value of the key. Both the value specified in the mutation, and any existing value must be of typeDeno.KvU64
. If the key does not exist, the value is set to the given value (summed with 0). If the result of the sum overflows an unsigned 64-bit integer, the result is wrapped around.max
- Sets the value of the key to the maximum of the existing value and the given value. Both the value specified in the mutation, and any existing value must be of typeDeno.KvU64
. If the key does not exist, the value is set to the given value.min
- Sets the value of the key to the minimum of the existing value and the given value. Both the value specified in the mutation, and any existing value must be of typeDeno.KvU64
. If the key does not exist, the value is set to the given value.