monday.storage
Storage API
The monday apps infrastructure includes a persistent, key-value database storage that developers can leverage to store data without having to create their own backend and maintain their own database. You can use the software development kit (SDK) monday.storage
method to interact with it.
The database currently offers instance-level storage only, meaning that each application instance (i.e. a single board view or a dashboard widget) maintains its own storage. Apps cannot share storage across accounts or even across apps installed in the same location.
When interacting with the database, it is important to take note of the following limits:
- Key length limit: 256
- Storage limit per key: 6MB
Methods
Method | Description |
---|---|
monday.storage.instance.getItem(key) | Returns a stored value from the database under key . |
monday.storage.instance.deleteItem(key) | Deletes a stored value from the database under key . |
monday.storage.instance.setItem(key, value) | Stores value under key in the database. |
Returns
All methods return a Promise
which will be resolved
to the Storage API's response.
Versioning
You may face cases where multiple monday.com users will be working on the same app instance and writing to the same key in an unsynchronized fashion. If you're storing a compound data structure (like JSON) in that key, such operations may overwrite each other.
The getItem()
and setItem()
each return a version identifier which can be used to identify which value is currently stored in a key. Whenever a write that changes the value occurs, the version identifier in the database changes. This allows you to identify whether a value was already changed from another location and prevent that from being overwritten.
Examples
Versioning
monday.storage.instance.getItem('serialKey').then(res => {
const { value, version } = res.data;
sleep(10000); // someone may overwrite serialKey during this time
monday.storage.instance.setItem('serialKey', { previous_version: version }).then(res => {
console.log(res);
}
});
// => '{ "success": false, "reason": "version_conflict" }'
Get a value in the database
monday.storage.instance.getItem('mykey').then(res => {
console.log(res.data.value);
});
// => 'Lorem Ipsum'
Set a new value in the database
monday.storage.instance.setItem('mykey', 'Lorem Ipsum').then(res => {
console.log(res);
});
// => { "success": true }
Delete an item in the database
monday.storage.instance.deleteItem('mykey').then(res => {
console.log(res.data);
}
// => { "success": true, "value": null }
Updated about 2 months ago