Class Index | File Index

## Classes

- _global_
- M
- M.ActionSheetDialogView
- M.AlertDialogView
- M.Application
- M.Base64
- M.ButtonGroupView
- M.ButtonView
- M.ConfirmDialogView
- M.ContainerView
- M.Controller
- M.Cypher
- M.DataProvider
- M.Date
- M.DateValidator
- M.EmailValidator
- M.Environment
- M.EventDispatcher
- M.FormView
- M.GridView
- M.I18N
- M.ImageView
- M.LabelView
- M.ListItemView
- M.ListView
- M.LoaderView
- M.LocalStorageProvider
- M.Logger
- M.Math
- M.Model
- M.ModelAttribute
- M.ModelRegistry
- M.NotMinusValidator
- M.NumberValidator
- M.Object
- M.Observable
- M.PageView
- M.PhoneValidator
- M.PresenceValidator
- M.RecordManager
- M.RemoteStorageProvider
- M.Request
- M.ScrollView
- M.SearchBarView
- M.SelectionListItemView
- M.SelectionListView
- M.SHA256
- M.TabBarItemView
- M.TabBarView
- M.TextFieldView
- M.ToggleView
- M.ToolbarView
- M.UrlValidator
- M.Validator
- M.View
- M.ViewManager
- M.WebSqlProvider

# 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
--- | ---
| M.WebSqlProvider()

Field Summary
Field Attributes | Field Name and Description
--- | ---
| config Configuration object
| dbHandler Is set when database "opened".
| internalCallback Saves the internal callback function.
| isInitialized Is set to YES when initialization ran successfully, means when M.WebSqlProvider#init was called, db and table created.
| type The type of this object.
| typeMapping 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)