puter.kv.update()Update one or more paths within the value stored at a key. You can update nested fields without overwriting the entire value.
puter.kv.update(key, pathAndValueMap)
puter.kv.update(key, pathAndValueMap, ttlSeconds)
key (String) (required)
The key to update.
pathAndValueMap (Object) (required)
An object where each key is a dot-separated path (for example, "profile.name") and each value is the new value for that path.
ttlSeconds (Number) (optional)
Time-to-live for the key, in seconds.
Returns a Promise that resolves to the updated value stored at key.
Update nested fields and refresh the TTL
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
(async () => {
await puter.kv.set('profile', { name: 'Puter', stats: { score: 10 } });
const updated = await puter.kv.update(
'profile',
{ 'stats.score': 11, 'name': 'Puter Smith' },
3600
);
puter.print(`Updated profile: ${JSON.stringify(updated)}`);
})();
</script>
</body>
</html>