Class R.storage.BrowserStorage
Extends
R.storage.AbstractDBStorage.
R.storage.BrowserStorage is a generalized class for browser-based
storage mechanisms. Either of the browser storage objects can be accessed using
a SQL-like syntax, with table creation and data manipulation, or using simple
keys and values.
Defined in: browserstorage.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.storage.BrowserStorage(name)
Generalized base storage class for browser storage objects.
|
Method Attributes | Method Name and Description |
---|---|
createTable(name, columns, types)
Create a new table to store data in.
|
|
dropTable(name)
Drop a table by its given name
|
|
execSql(sqlString, bindings)
Execute SQL on the storage object, which may be one of SELECT,
UPDATE, INSERT, or DELETE.
|
|
Get the class name of this object
|
|
getKeys()
Get all of the keys associated with this storage object.
|
|
getTableData(name)
Get the data object, for the given table.
|
|
getTableDef(name)
Get the schema object, for the given table.
|
|
getTableSize(name)
Get the size of a table's data in bytes.
|
|
getTableUID(name)
A unique identifier for the table name.
|
|
load(key, defaultValue)
Get the value associated with the key from the browser storage object.
|
|
save(key, value)
Save a value to the browser storage object.
|
|
setTableData(name, data)
Set the data, for the given table, in the persistent storage.
|
|
tableExists(name)
Returns true if the table with the given name exists
|
- Methods borrowed from class R.storage.AbstractDBStorage:
- flush, getSchema, setSchema
- Methods borrowed from class R.storage.AbstractStorage:
- destroy, getStorageObject, initStorageObject, loadData, release, saveData, setStorageObject
- Methods borrowed from class R.engine.PooledObject:
- clearObjectDataModel, getId, getName, getObjectDataModel, getProperties, isDestroyed, setName, setObjectDataModel, toString, toXML
Class Detail
R.storage.BrowserStorage(name)
Generalized base storage class for browser storage objects.
- Parameters:
- name
- {String} The name of the object
Method Detail
{Boolean}
createTable(name, columns, types)
Create a new table to store data in.
- Parameters:
- name
- {String} The name of the table
- columns
- {Array} An array of case-sensitive column names
- types
- {Array} An array of the columns types. The types are 1:1 for the column names. If you omit types, all columns will be assumed type "String".
- Returns:
- {Boolean}
true
if the table was created.false
if the table already exists or couldn't be created for another reason.
dropTable(name)
Drop a table by its given name
- Parameters:
- name
- {String} The name of the table to drop
{Object}
execSql(sqlString, bindings)
Execute SQL on the storage object, which may be one of SELECT,
UPDATE, INSERT, or DELETE. This mechanism allows for
joining of data, querying across multiple tables, and more.
- Parameters:
- sqlString
- {String} The SQL to execute
- bindings
- {Array} An optional array of bindings
- Returns:
- {Object} If the SQL is a SELECT, the object will be the result of the statement, otherwise the result will be a Boolean if the statement was successful.
{String}
getClassName()
Get the class name of this object
- Returns:
- {String} "R.storage.BrowserStorage"
{Array}
getKeys()
Get all of the keys associated with this storage object.
- Returns:
- {Array} An array of key names
{Object}
getTableData(name)
Get the data object, for the given table.
- Parameters:
- name
- {String} The name of the table
- Returns:
- {Object} The data object, or null if no table with the given name exists
{Object}
getTableDef(name)
Get the schema object, for the given table.
- Parameters:
- name
- {String} The name of the table
- Returns:
- {Object} The data object, or null if no table with the given name exists
{Number}
getTableSize(name)
Get the size of a table's data in bytes.
- Parameters:
- name
- {String} The name of the table
- Returns:
- {Number} The size of the table
{String}
getTableUID(name)
A unique identifier for the table name.
- Parameters:
- name
- {String} The table name
- Returns:
- {String} A unique identifier
{Object}
load(key, defaultValue)
Get the value associated with the key from the browser storage object.
- Parameters:
- key
- {String} The key to retrieve data for
- defaultValue Optional
- {Object} If the value isn't found in storage, use this default value
- Returns:
- {Object} The value that was stored with the key, or null
save(key, value)
Save a value to the browser storage object.
- Parameters:
- key
- {String} The key to store the data with
- value
- {Object} The value to store with the key
{Number}
setTableData(name, data)
Set the data, for the given table, in the persistent storage.
- Parameters:
- name
- {String} The name of the table
- data
- {Object} The table data to store
- Returns:
- {Number} 1 if the data was stored, or 0 if the table doesn't exist
{Boolean}
tableExists(name)
Returns true if the table with the given name exists
- Parameters:
- name
- {String} The name of the table
- Returns:
- {Boolean}