Custom AIR controller that allows performing arbitrary operations (as
opposed to CRUD on models) against local SQLite database.
protected var connection:SQLConnection
public var initialized:Boolean
indicates if the local database has been set up and is ready to be modified/queried
protected var queue:Array
public function AuxAIRController(optsOrOnResult:Object = null, onFault:Function = null, dbFile:File = null)
Parameters
| optsOrOnResult:Object (default = null ) — can be either an anonymous object of options or a result handler
function.
|
|
| onFault:Function (default = null ) — function to call if there was an error or if unmarshalling fails
|
|
| dbFile:File (default = null ) — to use (defaults to Rx.airDatabaseName)
|
protected function checkConditions(source:Object, conditions:Object):Boolean
Parameters
| source:Object |
|
| conditions:Object |
Returns
protected function defaultFaultHandler(info:Object, token:Object = null):void
Parameters
| info:Object |
|
| token:Object (default = null )
|
protected function defaultResultHandler(event:Object, token:Object = null):void
Parameters
| event:Object |
|
| token:Object (default = null )
|
protected function execute(fqn:String, statement:SQLStatement, includes:Array = null, unmarshall:Boolean = false, cacheBy:String = null):void
Parameters
| fqn:String |
|
| statement:SQLStatement |
|
| includes:Array (default = null )
|
|
| unmarshall:Boolean (default = false )
|
|
| cacheBy:String (default = null )
|
public function executeAnySQL(optsOrClazz:Class, sql:String, includes:Array = null, unmarshall:Boolean = false, cacheBy:String = null):void
This simply executes any SQL that you pass into it optionally allowing you to unmarshall and cache
the result
Parameters
| optsOrClazz:Class — RxModel clazz to execute the query on or the options object
|
|
| sql:String — the SQL query to run
|
|
| includes:Array (default = null ) — boolean indiciating if the result should be unmarshalled into RxModel instances
|
|
| unmarshall:Boolean (default = false ) — RESTful cache method to simulate
|
|
| cacheBy:String (default = null )
|
public function executeAnySQLInBulk(optsOrClazz:Object, statements:Array):void
This executes any sequence of SQL statements within a trasaction
Parameters
| optsOrClazz:Object — RxModel clazz to execute the query on or the options object
|
|
| statements:Array — the array of SQL queries to run
|
protected function executePendingSQLStatements():void
protected function executeSQLStatement(statement:SQLStatement):void
Parameters
public function findAll(optsOrClazz:Object, conditions:Array = null, includes:Array = null, unmarshall:Boolean = true, cacheBy:String = "index"):void
If you find Rx.models.index in combination with Rx.filter and/or metadata not sufficiently
expressive you can perform finds against local SQLite database in a samilar manner to
ActiveRecord's find(:all) with conditions. You can optially unmarshall the result and
simulate one of:
- index
- create
- update
- destroy
- show
The motivation for this is quite similar to Rx.http(AuxHTTPController) with the big
difference in that works against local SQLite instead of an arbitrary HTTP service.
You can basically use this to perform non-RESTful finds against local SQLite DB
when necessary.
Parameters
| optsOrClazz:Object — RxModel clazz to do the find on or the options object
|
|
| conditions:Array (default = null ) — list of conditions
|
|
| includes:Array (default = null ) — additional relationships to bring into scope
|
|
| unmarshall:Boolean (default = true ) — boolean indiciating if the result should be unmarshalled into RxModel instances
|
|
| cacheBy:String (default = "index ") — RESTful cache method to simulate
|
Example
Find projects
var controller:AuxAIRController = new AuxAIRController(onResult);
controller.findAll(SimpleProperty, ["name LIKE :name AND available = true", {":name": "%2%"}]);
Find projects (Alternative Syntax)
XRx.air(onresult).findAll(SimpleProperty, ["name LIKE :name AND available = true", {":name": "%2%"}]);
public function findAllBySQL(optsOrClazz:Object, sql:String, includes:Array = null, unmarshall:Boolean = true, cacheBy:String = "index"):void
If you don't want to bother with formatting conditions you can default to writing SQL for SQLite
queries yourself.
Parameters
| optsOrClazz:Object — RxModel clazz to do the find on or the options object
|
|
| sql:String — the SQL query to run
|
|
| includes:Array (default = null ) — list of conditions
|
|
| unmarshall:Boolean (default = true ) — boolean indiciating if the result should be unmarshalled into RxModel instances
|
|
| cacheBy:String (default = "index ") — RESTful cache method to simulate
|
See also
protected function getSQLStatement(statement:String):SQLStatement
Parameters
Returns
protected function initializeConnection(databaseFile:File):void
Parameters
protected function invokeResponderResult(responder:IResponder, result:Object):void
Parameters
| responder:IResponder |
|
| result:Object |
protected function processIncludedRelationships(relationships:Array, fqn:String, data:Array, responder:IResponder = null):void
Parameters
| relationships:Array |
|
| fqn:String |
|
| data:Array |
|
| responder:IResponder (default = null )
|
protected function queueSQLStatement(statement:SQLStatement):void
Parameters
protected function unmarshall(event:ResultEvent):Object
Parameters
Returns
protected function unmarshallAndCacheResultHandler(event:Object, token:Object = null):void
Parameters
| event:Object |
|
| token:Object (default = null )
|
protected function unmarshallResultHandler(event:Object, token:Object = null):void
Parameters
| event:Object |
|
| token:Object (default = null )
|