Skip to content

# Storage

## storage : `object`

Get and set data.

Kind: global namespace

- storage : `object`
  - .getSmall(key, defaultValue) ⇒ `*`
  - .setSmall(key, value)
  - .getBig(key, defaultValue)
  - .setBig(key, value)
  - .getDB(key, defaultValue) ⇒ `Promise.<*>`
  - .setDB(key, value) ⇒ `Promise`

### storage.getSmall(key, defaultValue) ⇒ `*`

Get a value from the small data storage, using localStorage or a similar mechanism (may change in the future).

Kind: static method of `storage`

Param | Type | Description
--- | --- | ---
key | `string` | Storage item key/ID
defaultValue | `*` | Value to return if the item key doesn't have a stored value.

### storage.setSmall(key, value)

Set a value in the small data storage, using localStorage or a similar mechanism (may change in the future).

Kind: static method of `storage`

Param | Type | Description
--- | --- | ---
key | `string` | Storage item key/ID
value | `*` | Value to store.

### storage.getBig(key, defaultValue)

Get a value in the large data storage. Unserialized from a JSON file on disk.

Kind: static method of `storage`

Param | Type | Description
--- | --- | ---
key | `string` | Storage item key/ID
defaultValue | `*` | Value to return if the item key doesn't have a stored value.

### storage.setBig(key, value)

Set a value in the large data storage. Serialized to JSON and stored on disk as a file.

Kind: static method of `storage`

Param | Type | Description
--- | --- | ---
key | `string` | Storage item key/ID
value | `*` | Value to store.

### storage.getDB(key, defaultValue) ⇒ `Promise.<*>`

Get a value from the database storage. Unlike other storage types, values in the database are available on all PostalPoint installations in a single location.

Kind: static method of `storage`

Param | Type | Description
--- | --- | ---
key | `string` | Storage item key/ID
defaultValue | `*` | Value to return if the item key doesn't have a stored value.

### storage.setDB(key, value) ⇒ `Promise`

Set a value in the database storage. Non-string values are serialized to JSON. Unlike other storage types, values in the database are available on all PostalPoint installations in a single location.

Kind: static method of `storage`

Param | Type | Description
--- | --- | ---
key | `string` | Storage item key/ID
value | `*` | Value to store.