Namespace RapidContext.Storage

Storage

Provides functions for accessing the server storage (BETA).

Method Summary
(static)
Returns the storage path for an object.
(static)
Reads an object on a storage path.
(static)
Updates an object with properties from a partial object.
(static)
Writes an object to a storage path.

Methods

(static) path(obj) → {string}

Returns the storage path for an object. The object must have both the 'type' and 'id' properties set.

Parameters:
Name Type Description
obj {Object} the object to store
Returns:
{string} the storage path, or null if not available
Source:
RapidContext_Storage.js, line 53

(static) read(pathOrObj) → {Promise}

Reads an object on a storage path. Note that this will return a JSON representation of the object, regardless of the actual object type.

Parameters:
Name Type Description
pathOrObj {string|Object} the path or object to read
Returns:
{Promise} a RapidContext.Async promise that will resolve with the object data
Source:
RapidContext_Storage.js, line 70

(static) update(pathOrObj, dataopt) → {Promise}

Updates an object with properties from a partial object. The properties in the partial object will overwrite any previous properties with the same name in the destination object. No merging of property values will be performed.

Parameters:
Name Type Attributes Description
pathOrObj {string|Object} the path or object to write
data {Object} <optional>
the partial object (changes) to write
Returns:
{Promise} a RapidContext.Async promise that will resolve with the updated data object on success
Source:
RapidContext_Storage.js, line 114

(static) write(pathOrObj, dataopt) → {Promise}

Writes an object to a storage path. Any previous object on the specified path will be removed. If a path is specified without data, only the removal is performed.

Parameters:
Name Type Attributes Description
pathOrObj {string|Object} the path or object to write
data {Object} <optional>
the object to write (if path was string)
Returns:
{Promise} a RapidContext.Async promise that will resolve when the object has been written
Source:
RapidContext_Storage.js, line 89