Skip to content

Remove Data


Delete key/value pairs

Delete a entry (a value) assigned to a key named "nickname"

await db.key("nickname").delete();
curl -s -b cookies.txt -H "X-Authorization: Token $KEY" \
  -G https://prefsdb.com/api/v1/delete/ -d "nickname="
# {"status":"success","success":true,"affectedCount":1,...}

Delete an entry (a value) under a key nickname but only if it contains a substring "foobar":

await db.key("nickname").match("%foobar%").delete();
curl -s -b cookies.txt -H "X-Authorization: Token $KEY" \
  -G https://prefsdb.com/api/v1/delete/ -d "nickname=" --data-urlencode "__filter=%foobar%"

Delete several keys at once:

await db.keys(["theme", "font", "layout"]).delete();
curl -s -b cookies.txt -H "X-Authorization: Token $KEY" \
  -G https://prefsdb.com/api/v1/delete/ -d "theme=" -d "font=" -d "layout="

Delete values from a list

Lists are collections of values. Lists typically do not have keys. To remove an item from a list, we do it by-value.

Remove a value from a list named "mylist".

// match() without % wildcards matches the whole value exactly
await db.list("mylist").match("value").delete();
curl -s -b cookies.txt -H "X-Authorization: Token $KEY" \
  -G https://prefsdb.com/api/v1/delete/ -d list=mylist -d "*=" --data-urlencode "__filter=value"

Remove all values from a list named "mylist" that begin with 2025.

await db.list("mylist").match("2025%").delete();
curl -s -b cookies.txt -H "X-Authorization: Token $KEY" \
  -G https://prefsdb.com/api/v1/delete/ -d list=mylist -d "*=" --data-urlencode "__filter=2025%"

Reset a list. Removes all items from a list, effectively deleting that list. This would delete all entries from a list named "mylist"

await db.list("mylist").delete();
curl -s -b cookies.txt -H "X-Authorization: Token $KEY" \
  -G https://prefsdb.com/api/v1/delete/ -d list=mylist -d "*="

Delete files

A file uploaded with .putObject() stays stored until it's deleted. Use the same project/domain/subdomain/list as the upload.

await db.domain("uploads").deleteObject(fileId);
curl -s -b cookies.txt -H "X-Authorization: Token $KEY" \
  -G https://prefsdb.com/api/v1/deleteobject/ -d file=$FILE_ID -d domain=uploads

Time-To-Live (TTL)

Values are kept until you delete them, unless they're given a time-to-live (TTL): a number of days after which they're deleted automatically. Set it for a value when you write it, with .ttl(days) (&ttl=[days]), or for every value already stored in a scope with .expire(days), e.g. db.project("my-app").expire(30).

Deleting data

To erase data right away, use .delete() (see above) rather than a TTL. A TTL of 0 (or less) doesn't delete anything: it means the value never expires.

await db.key("mydata").delete();

You can pass a Time-To-Live directive with each .write() call, which will cause saved values to be purged - as in permanently deleted - after N number of days. The countdown starts when the value is written, and reading the value doesn't reset it. Writing the value again with a TTL restarts it; writing it again without one keeps the TTL it had.

ttl=<number-of-days>

Example: the 'theme' setting for user janedoe will be erased after 15 days. Any other values associated with that key will not be affected - unless they also were set with an explicit ttl value.

const user = document.getElementById("inputbox").value;
const pass = document.getElementById("password").value;

const db = await PrefsDB.getkey("my_key", [user, pass]);
await db.key("theme").ttl(15).write({ theme: "default-dark" });
curl -s -b cookies.txt -H "X-Authorization: Token $KEY" -G https://prefsdb.com/api/v1/write/ \
  --data-urlencode 'theme={"theme":"default-dark"}' -d ttl=15


IMPORTANT: TTL parameter is enforced at a value level, meaning it only affects key/value pair, an object , or any piece of data it was assigned to and does not apply to other values associated with your key. To set a TTL on many existing values at once, use .expire(days) on a scope: db.project("my-app").expire(30) covers everything under project my-app, and db.project("my-app").domain("active-users").expire(1) only what's under both.

await db.project("my-app").expire(30);                        // everything under my-app
await db.project("my-app").domain("active-users").expire(1);  // only my-app + active-users
await db.project("my-app").expire(0);                         // remove the expiry again
curl -s -b cookies.txt -H "X-Authorization: Token $KEY" \
  -G https://prefsdb.com/api/v1/expire/ -d project=my-app -d days=30
# {"success":true,"status":"success","ttl":30,"updated":{"pairs":4,"lists":1},...}

curl -s -b cookies.txt -H "X-Authorization: Token $KEY" \
  -G https://prefsdb.com/api/v1/expire/ -d project=my-app -d domain=active-users -d days=1