keyv.transform
0.000005

Transforms the value of a key.

Arguments
procrequired
The proc used to transform the value.
bucketrequired
The bucket the key is stored under.
key
The key to transform the value for.
type
The type of value from the resulting transform.
set
The value to set if the key does not exist.
Return Value
true if the key was transformed, otherwise false.

keyv.transform transforms the value of a key, optionally setting an initial value prior to transforming if the key does not exist. If the key is updated or deleted during the transform, the transform will be aborted.

something went wrong :(
Transforming the value of a key
Setup
authorization=PROCAUTH
require "proc"

client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
client.keyv.set.call(
  bucket: "w00e4ea4", value: "foo"
)

client.keyv.transform.call(bucket: "w00e4ea4") {
  client.type.string.reverse
}
client.keyv.set.call(
  undefined, w00e4ea4
);

client.keyv.transform.call(undefined, w00e4ea4, () => {
  return client.type.string.reverse;
});
curl "https://proc.run/keyv/set?bucket=w00e4ea4" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: text/plain" \
--data "foo"

curl "https://proc.run/keyv/transform?bucket=w00e4ea4" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: application/vnd.proc+json" \
--header "accept: text/plain" \
--data '[["$$", "bucket", ["%%", "w00e4ea4", ["()", "type.string.reverse"]]]]'
 

true

There's a lot more to the key-value store, including expiries and value types—learn more in the docs.


Stuck? Want to chat about an idea? Join the community on Discord.