WLJSONStore
This class is the public WLJSONStore API for React-Native applications.
Method Summary
Public Methods | ||
public |
async changePassword(username: string, oldPassword: string, newPassword: string, pbkdf2Iterations: number): Promise<string, JSON> Change the password for the given user. |
|
public |
Locks access to all the collections until the init method is called. |
|
public |
async commitTransaction(): Promise<string, JSON> Commit a transaction. |
|
public |
Permanently deletes all data for all users, clears security artifacts, and removes accessors. |
|
public |
async getFileInfo(): Promise<Array, JSON> Returns an array of objects with information about all the stores in the device. |
|
public |
async openCollections(collections: array, options: JSONStoreInitOptions): Promise<string, JSON> Provides access to the collections that are inside the store, and creates them if they do not already exist. |
|
public |
async rollbackTransaction(): Promise<boolean, JSON> Roll back a transaction. |
|
public |
setAnalyticsEnabled(isAnalyticsEnabled: boolean) Enable or disable the collection of analytic data for JSONStore. |
|
public |
async startTransaction(): Promise<string, JSON> Start a transaction. |
Public Methods
public async changePassword(username: string, oldPassword: string, newPassword: string, pbkdf2Iterations: number): Promise<string, JSON> source
Change the password for the given user.
Return:
Promise<string, JSON> | This function returns an empty string in case of success and it returns a JSON in case of any error. |
Example:
- If the promise is rejected, an error JSON in the following format is available with more information.
{
errorMsg: "Error adding data to collection: favourites",
reason: "Collection is not initialized."
}
public async closeAll(): Promise<string, JSON> source
Locks access to all the collections until the init method is called.
Return:
Promise<string, JSON> | This function returns an empty string in case of success and it returns a JSON in case of any error |
Example:
- If the promise is rejected, an error JSON in the following format is available with more information.
{
errorMsg: "Error adding data to collection: favourites",
reason: "Collection is not initialized."
}
public async commitTransaction(): Promise<string, JSON> source
Commit a transaction.
Return:
Promise<string, JSON> | This function returns an empty string in case of success and it returns a JSON in case of any error |
Example:
- If the promise is rejected, an error JSON in the following format is available with more information.
{
errorMsg: "Error adding data to collection: favourites",
reason: "Collection is not initialized."
}
public async destroy(username: string): Promise<string, JSON> source
Permanently deletes all data for all users, clears security artifacts, and removes accessors.
Params:
Name | Type | Attribute | Description |
username | string |
|
The user name. |
Return:
Promise<string, JSON> | This function returns an empty string in case of success and it returns a JSON in case of any error |
Example:
- If the promise is rejected, an error JSON in the following format is available with more information.
{
errorMsg: "Error adding data to collection: favourites",
reason: "Collection is not initialized."
}
public async getFileInfo(): Promise<Array, JSON> source
Returns an array of objects with information about all the stores in the device.
Return:
Promise<Array, JSON> | This function returns an Array of JSON Objects in case of success, representing the details of the JSONStore info, and it returns a JSON in case of any error |
Example:
- This is how a sample response will look like:
[
{
encrypted:false,
fileSize:7168,
username:"com.worklight.jsonstore"
}
]
public async openCollections(collections: array, options: JSONStoreInitOptions): Promise<string, JSON> source
Provides access to the collections that are inside the store, and creates them if they do not already exist.
Params:
Name | Type | Attribute | Description |
collections | array | An array of collection definitions (JSONStoreCollection objects) that are to be initialized (either reopened or created). |
|
options | JSONStoreInitOptions |
|
An object of class JSONStoreInitOptions. This is a specific set of options to initialize the collection with (such as security credentials). |
Return:
Promise<string, JSON> | This function returns an empty string in case of success and it returns a JSON in case of any error |
Example:
- If the promise is rejected, an error JSON in the following format is available with more information.
{
errorMsg: "Error adding data to collection: favourites",
reason: "Collection is not initialized."
}
public async rollbackTransaction(): Promise<boolean, JSON> source
Roll back a transaction.
Return:
Promise<boolean, JSON> | This returns a boolean value on completion - true for success, false for failure. |
Example:
- If the promise is rejected, an error JSON in the following format is available with more information.
{
errorMsg: "Error adding data to collection: favourites",
reason: "Collection is not initialized."
}
public setAnalyticsEnabled(isAnalyticsEnabled: boolean) source
Enable or disable the collection of analytic data for JSONStore.
Params:
Name | Type | Attribute | Description |
isAnalyticsEnabled | boolean | ture: to collect Analytics data, false: otherwise |
public async startTransaction(): Promise<string, JSON> source
Start a transaction.
Return:
Promise<string, JSON> | This returns an empty string on success, and a JSON in case of any error. |
Example:
- If the promise is rejected, an error JSON in the following format is available with more information.
{
errorMsg: "Error adding data to collection: favourites",
reason: "Collection is not initialized."
}