client-key-value-storage
Reactive icon

Client Key Value Storage

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 16 October 2022
 by 
5.0
 (1 rating)
client-key-value-storage

Client Key Value Storage

Documentation
1.0.0

Overview

eSpace Name

ClientStorage_Lib

Description

The library allows interaction with the browser's WebStorage API ( known as localstorage and sessionstorage) through the use of client actions.


Data

Structures


KVStoragePartitionRows

Structure to handle the rows inside partition.

Attribute:

  • RowKey (Text) : The key of row
  • Payload (Text) : The content of row


Static Entities


KVClientStorageMode

Static entities for the storage mode

Values:

  • 0 – Local
  • 1 - Session


KVClientStorageScope

Static entity for the storage scope

Values:

  • 0 – Global
  • 1 – Application
  • 2 – Module
  • 3 - Screen




Implementation ( All Client Actions )

Note on “ExpireInSeconds”, the clients actions delegated for add/insert operation has a optional parameter that allow to set an expire date for the storage item. If the parameter has default value ( 0 ) the item expire after one year.


Session Storage Folder


InitSessionStorage

Init js object to handle session storage

Input parameters

Name

Description

DataType

Mandatory

Scope

The data separation scope.

KVClientStorageScope Identifier

Yes


Output parameters

Name

Description

DataType

StorageObject

The client object that handle session storage operations.

Object

 


SessionClear

Clear all session storage item based on js object scope configuration.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle session storage operations.

Object

Yes

 


SessionItemAdd

Add item session storage item based on js object scope configuration.

WARNING : This method insert new item only if the key not exist in the storage. If you need to insert always a value use SessionItemInsertOrUpdate

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle session storage operations.

Object

Yes

Key

The key of item in session storage

Text

Yes

Payload

The data to save

Text

Yes

ExpireInSeconds

The lifespan of item in seconds

Integer

NO

 


SessionItemExist

Check if an item with given key exists in storage, based on js object scope configuration.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle session storage operations.

Object

Yes

Key

The key of item in session storage

Text

Yes


Output parameters

Name

Description

DataType

Exist

Check if item exist

Boolean


SessionItemInserOrUpdate

Insert a new item or update existing one in session storage based on scope configuration.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle session storage operations.

Object

Yes

Key

The key of item in session storage

Text

Yes

Payload

The data to save

Text

Yes

ExpireInSeconds

The lifespan of item in seconds

Integer

NO


SessionItemRead

Retrieve item with given key in session storage based on scope configuration.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle session storage operations.

Object

Yes

Key

The key of item in session storage

Text

Yes


Output parameters

Name

Description

DataType

Payload

The content of item in session storage

Text


SessionItemRemove

Remove the item with given key in session storage based on scope configuration.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle session storage operations.

Object

Yes

Key

The key of item in session storage

Text

Yes




Local Storage Folder


InitLocalStorage

Init js object to handle local storage

Input parameters

Name

Description

DataType

Mandatory

Scope

The data separation scope.

KVClientStorageScope Identifier

Yes


Output parameters

Name

Description

DataType

StorageObject

The client object that handle local storage operations.

Object

 

LocalClear

Clear all local storage item based on js object scope configuration.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle local storage operations.

Object

Yes

 


LocalItemAdd

Add item local storage item based on js object scope configuration.

WARNING : This method insert new item only if the key not exist in the storage. If you need to insert always a value use LocalItemInsertOrUpdate

Add item session storage item based on js object scope configuration.

WARNING : This method insert new item only if the key not exist in the storage. If you need to insert always a value use SessionItemInsertOrUpdate

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle local storage operations.

Object

Yes

Key

The key of item in local storage

Text

Yes

Payload

The data to save

Text

Yes

ExpireInSeconds

The lifespan of item in seconds

Integer

NO

 


LocalItemExist

Check if an item with given key exists in storage, based on js object scope configuration.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle local storage operations.

Object

Yes

Key

The key of item in local storage

Text

Yes


Output parameters

Name

Description

DataType

Exist

Check if item exist

Boolean



LocalItemInserOrUpdate

Insert a new item or update existing one in local storage based on scope configuration.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle local storage operations.

Object

Yes

Key

The key of item in local storage

Text

Yes

Payload

The data to save

Text

Yes

ExpireInSeconds

The lifespan of item in seconds

Integer

NO



LocalItemRead

Retrieve item with given key in local storage based on scope configuration.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle local storage operations.

Object

Yes

Key

The key of item in local storage

Text

Yes


Output parameters

Name

Description

DataType

Payload

The content of item in local storage

Text


LocalItemRemove

Remove the item with given key in local storage based on scope configuration.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle local storage operations.

Object

Yes

Key

The key of item in local storage

Text

Yes




KeyValue Storage Folder


InitKeyValueStorage

Init js object to handle keyvalue storage

Input parameters

Name

Description

DataType

Mandatory

Mode

The target storage

KVClientStorageMode Identifier

Yes

Scope

The data separation scope

KVClientStorageScope Identifier

Yes

              


Output parameters


Name

Description

DataType

StorageObject

The client object that handle partitions and rows.

Object


StorageObject   The client object that handle partitions and rows.           Object


PartitionClear

Clear the values inside a partition

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle partitions and rows.

Object

Yes

PartitionKey

The key/name of partition

Text

Yes

 



PartitionRemove

Clear a specific partition

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle partitions and rows.

Object

Yes

PartitionKey

The key/name of partition

Text

Yes

              



PartitionsEnumerateAll

Retrieve all partiations names

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle partitions and rows.

Object

Yes


Output parameters

Name

Description

DataType

PartitionKeysList

The list of partitions

Text List


PartitionsRemoveAll

Remove All Partitions

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle partitions and rows.

Object

Yes



RowAdd

Add a row inside a partition

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle partitions and rows.

Object

Yes

PartitionKey

The key of partition

Text

Yes

RowKey

The key of the row

Text

Yes

Payload

The data to save

Text

Yes

ExpireInSeconds

The lifespan of row in seconds

Integer

No

 


RowDelete

Delete a row inside a partition

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle partitions and rows.

Object

Yes

PartitionKey

The key of partition

Text

Yes

RowKey

The key of the row

Text

Yes

 

RowExist

Check if the row with given key exist

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle partitions and rows.

Object

Yes

PartitionKey

The key of partition

Text

Yes

RowKey

The key of the row

Text

Yes

              


Output parameters

Name

Description

DataType

Exist

Check if the the row exist

Boolean


RowInsertOrUpdate

Insert a new row or update an existing one in a specific partition.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle partitions and rows.

Object

Yes

PartitionKey

The key of partition

Text

Yes

RowKey

The key of the row

Text

Yes

Payload

The data to save

Text

Yes

ExpireInSeconds

The lifespan of row in seconds

Integer

No


RowRead

Read a row in a partition.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle partitions and rows.

Object

Yes

PartitionKey

The key of partition

Text

Yes

RowKey

The key of the row

Text

Yes


Output parameters

Name

Description

DataType

Payload

               The data to retrieve

Text


RowsReadAllByPartition

Read all rows inside a partition.

Input parameters

Name

Description

DataType

Mandatory

StorageObject

The client object that handle partitions and rows.

Object

Yes

PartitionKey

The key of partition

Text

Yes


Output parameters

Name

Description

DataType

Rows    

The rows inside the partition

KVStoragePartitionRows List