Key-value Data Store
Data in a key-value data store is stored and retrieved using a key that uniquely identifies the record.
API
The data storage API is available in WebApps and RESTApps.
put(key, data) [@since 5.2]
Stores data associated with a key.
Returns current data stored on the key.
Argument | Description |
---|---|
| A key to uniquely identify the record |
| JSON data to store |
const config = {
name: 'Foo',
title: 'Bar'
};
try {
keyValueStore.put('config', config);
} catch (e) {
// [Error handling](https://developer.sitevision.se/docs/data-storage/error-handling)
}
If a property is set to null
, the property will be removed
get(key) [@since 5.2]
Returns data associated with a key.
Argument | Description |
---|---|
| A key to retrieve data from |
try {
config = keyValueStore.get('config');
} catch (e) {
// [Error handling](https://developer.sitevision.se/docs/data-storage/error-handling)
}
remove(key) [@since 5.2]
Removes data associated with a key.
Returns the removed data.
Argument | Description |
---|---|
| A key to identify data to remove |
try {
keyValueStore.remove('config');
} catch (e) {
// [Error handling](https://developer.sitevision.se/docs/data-storage/error-handling)
}