Store
The sdk.store
utility provides a simple key-value interface for storing and retrieving small pieces of data across server-side functions. Under the hood, it uses GridStudio’s custom collection infrastructure, but abstracts away the complexity for quick, ephemeral data storage.
This is ideal for temporarily storing context, tokens, flags, or other lightweight values that need to persist between function executions.
API
await sdk.store.setAsync(key, value, { scope })
Stores a value with the given key.
Parameter | Type | Description |
---|---|---|
key | string | The key to associate with the value. |
value | any | The data to be stored (JSON-serializable). |
scope | string | Optional. Default is "tenant" . |
await sdk.store.getAsync(key, { scope })
Retrieves a previously stored value by its key.
Parameter | Type | Description |
---|---|---|
key | string | The key to retrieve. |
scope | string | Optional. Default is "tenant" . |
Example
await sdk.store.setAsync('syncStatus', 'completed')
const status = await sdk.store.getAsync('syncStatus')
sdk.utils.logger.info('Last sync status:', status)
Notes
scope
can be used to isolate values by context (e.g.,tenant
,app
, or other custom scopes).- Values are stored in a special internal collection named
"store"
. - Useful for flags, statuses, or small objects shared across multiple server functions.