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: "ubb31a29", value: "foo"
)

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

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

curl "https://proc.run/keyv/transform?bucket=ubb31a29" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: application/vnd.proc+json" \
--header "accept: text/plain" \
--data '[["$$", "bucket", ["%%", "ubb31a29", ["()", "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.