The "deleteValues" action takes one or more keys and deletes their previously stored values. The server looks up each key you specify. A key is case sensitive and must exactly match the key you used to store the value.
If the action returns without error, it guarantees all specified keys do not exist.
When the action finds a key and cannot delete it, it rolls back all other deletes and returns an error. It either deletes all specified keys or none.
The action returns each deleted key-value pair in case you want to undo the delete. It also includes keys it could not find in the "unmatchedKeys" property. It cannot delete these keys because they do not exist. The action does not return an error when it does not find specified keys.
How to use "deleteValues"
Use the required "keyStore" property to specify the keystore from which keys are deleted. In the required "keys" property, include one or more key strings.
When using the "role" keystore, you must set the "roleName" property to the name of the role that owns the key-value pair. The action returns an error when the current user does not have the specified role. An administrator account may set and get values for any role.
When using the "user" keystore, the action uses the session's username to identify the user's keys. When an administrator account runs the action, it can optionally use the "username" property to specify the user that owns the keys. This allows an elevated account to delete keys for other accounts.
If the response contains "errorCode": 0, then the request succeeded. The "keyValuePairs" property in the response contains an array of key-value pair objects: one for each matching key. The "unmatchedKeys" property in the response contains an array of key strings: one for each unmatched key.
Request examples
Global keystore
{
"api": "db",
"action": "deleteValues",
"params": {
"keyStore": "global",
"keys": [
"myKey"
]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Role keystore
The action uses the specified role and returns an error if the current session's account does not have that role. An administrator account may delete values for any role.
{
"api": "db",
"action": "deleteValues",
"params": {
"keyStore": "role",
"roleName": "operator",
"keys": [
"myKey"
]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
User keystore
The action automatically uses the session's username.
{
"api": "db",
"action": "deleteValues",
"params": {
"keyStore": "user",
"keys": [
"nonExistentKey"
]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
User keystore request using elevated privileges
When an administrator account runs the action, it can optionally use the "username" property to specify the account of the key-value pair. This allows an elevated account to delete key-value pairs for other accounts.
{
"api": "db",
"action": "deleteValues",
"params": {
"keyStore": "user",
"username": "someone_else",
"keys": [
"myKey"
]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
Response examples
Global keystore
{
"result": {
"keyStore": "global",
"keyValuePairs": [
{
"key": "myKey",
"value": {"my": "value"}
}
],
"unmatchedKeys": []
},
"authToken": "replaceWithAuthTokenFromCreateSession",
"errorCode": 0,
"errorMessage": ""
}
Role keystore
{
"result": {
"keyStore": "role",
"roleName": "operator",
"keyValuePairs": [
{
"key": "myKey",
"value": 1
}
],
"unmatchedKeys": []
},
"authToken": "replaceWithAuthTokenFromCreateSession",
"errorCode": 0,
"errorMessage": ""
}
User keystore
When the requested key does not exist, "keyValuePairs" is empty, but "unmatchedKeys" contains it.
{
"result": {
"keyStore": "user",
"username": "me",
"keyValuePairs": [],
"unmatchedKeys": [
"nonExistentKey"
]
},
"authToken": "replaceWithAuthTokenFromCreateSession",
"errorCode": 0,
"errorMessage": ""
}
User keystore response using elevated privileges
{
"result": {
"keyStore": "user",
"username": "someone_else",
"keyValuePairs": [
{
"key": "myKey",
"value": "someone_else_value"
}
],
"unmatchedKeys": []
},
"authToken": "replaceWithAuthTokenFromCreateSession",
"errorCode": 0,
"errorMessage": ""
}
Properties
Request properties ("params")
| Property | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
keys |
The "keys" property contains an array of keys for an action to work on and return, such as [ "key1", "key2" ]. |
Required - No default value | array of strings | one or more key strings |
keyStore |
The
|
Required - No default value | string enum |
|
roleName |
The
|
Required when "keystore": "role"
|
string | 1 to 64 bytes |
username |
The
In
In Key-Value actions, the
|
Required - No default value
Optional with default of the account name of the currently logged-in user for Key-Value actions
|
string | 1 to 64 bytes |
Response properties ("result")
| Property | Description | Type | Limits (inclusive) |
|---|---|---|---|
keyStore |
The
|
string enum |
|
keyValuePairs |
The "keyValuePairs" property contains an array of objects. Each object represents a key-value pair and contains "key" and "value" properties, such as { "key": "k1", "value": 1 }. |
array of key-value objects | |
|
keyValuePairs .key |
The "key" property is part of an optional key-value object that is defined in an array in the "userProperties" property. It is a user-defined string value. |
string | 1 to 128 bytes |
|
keyValuePairs .value |
The
When you use the
In Key-Value actions, the |
JSON | 0 to 65,500 bytes |
roleName |
The
|
string | 1 to 64 bytes |
unmatchedKeys |
The
|
array of strings | zero or more key strings |
username |
The It is required by the All API actions are performed in the context of the account identified by In JSON DB API and JSON Hub API, use the Unlike other property names, such as A zero-length username is invalid.
In Key-Value actions, the
|
string
|
1 to 64 bytes |