Class Index | File Index

Classes


Class M.WebSqlProvider


Extends M.DataProvider.
Encapsulates access to WebSQL (in-browser sqlite storage). All CRUD operations are asynchronous. That means that onSuccess and onError callbacks have to be passed to the function calls to have the result returned when operation finished.
Defined in: web_sql.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Field Summary
Field Attributes Field Name and Description
 
Configuration object
 
Is set when database "opened".
 
Saves the internal callback function.
 
Is set to YES when initialization ran successfully, means when M.WebSqlProvider#init was called, db and table created.
 
The type of this object.
 
Object containing all rules for mapping JavaScript data types to SQLite data types.
Method Summary
Method Attributes Method Name and Description
 
configure(obj)
Creates a new data provider instance with the passed configuration parameters
 
del(obj)
Prepares delete query for a model record.
 
find(obj)
Finds model records in the database.
 
queryDbForId(model)
Queries the WebSQL storage for the maximum db ID that was provided for a table that is defined by model.name.
 
save(obj)
Saves a model in the database.
Methods borrowed from class M.DataProvider:
check
Methods borrowed from class M.Object:
bindToCaller, create, destroy, extend, get, include, set
Class Detail
M.WebSqlProvider()
Field Detail
{Object} config
Configuration object

{Object} dbHandler
Is set when database "opened". Acts as handler for all db operations => transactions, queries, etc.

{Function} internalCallback
Saves the internal callback function. Is needed when provider/db is not initialized and init() must be executed first to have the return point again after initialization.

{Boolean} isInitialized
Is set to YES when initialization ran successfully, means when M.WebSqlProvider#init was called, db and table created.

{String} type
The type of this object.

{Object} typeMapping
Object containing all rules for mapping JavaScript data types to SQLite data types.
Method Detail
configure(obj)
Creates a new data provider instance with the passed configuration parameters
Parameters:
{Object} obj
Includes dbName

del(obj)
Prepares delete query for a model record. Operation itself is performed by M.WebSqlProvider#performOp. Tuple is identified by ID (not the internal model id, but the ID provided by the DB in record).
Parameters:
{Object} obj
The param obj, includes: * onSuccess callback * onError callback * the model

find(obj)
Finds model records in the database. If a constraint is given, result is filtered.
Parameters:
{Object} obj
The param object. Includes: * model: the model blueprint * onSuccess: * onError: * columns: Array of strings naming the properties to be selected: ['name', 'age'] => SELECT name, age FROM... * constraint: Object containing itself two properties: * statement: a string with the statement, e.g. 'WHERE ID = ?' * parameters: array of strings with the parameters, length array must be the same as the number of ? in statement => ? are substituted with the parameters * order: String with the ORDER expression: e.g. 'ORDER BY price ASC' * limit: Number defining the number of max. result items

queryDbForId(model)
Queries the WebSQL storage for the maximum db ID that was provided for a table that is defined by model.name. Delegates to M.WebSqlProvider#setDbIdOfModel.
Parameters:
{Object} model
The table's model

save(obj)
Saves a model in the database. Constructs the sql query from the model record. Prepares an INSERT or UPDATE depending on the state of the model. If M.STATE_NEW then prepares an INSERT, if M.STATE_VALID then prepares an UPDATE. The operation itself is done by M.WebSqlProvider#performOp that is called
Parameters:
{Object} obj
The param obj, includes: * onSuccess callback * onError callback * the model

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 08 2010 15:07:35 GMT+0100 (MEZ)