Package | com.memamsa.airdb |
Class | public class DB |
Use DB.initDB in your application startup code to name and initialize the database file.
Use Modeler
sub-classes as Object Relational Models with
base-class supported create, update, delete and query operations.
Use a Migrator
member within your models for schema
definition, and migrations.
Specify associations as class meta-data and add appropriate schema
support to get object relationships through the Associator
.
See also
Method | Defined by | ||
---|---|---|---|
execute(sql:String):SQLResult
[static]
Specify a SQL statement to be executed directly
| DB | ||
existsTable(name:String):Boolean
[static]
Check if the specified table exists
| DB | ||
fieldMap(fieldSpec:Array):String
[static]
Map a DB field as specified in migration directives into an appropriate
DB-specific CREATE statement clause after processing field type and
column options.
| DB | ||
getConnection(dbname:String = null):SQLConnection
[static]
Obtain and cache a connection to the database.
| DB | ||
getSchema(reloadSchema:Boolean = false):SQLSchemaResult
[static]
Get and cache the overall database schema.
| DB | ||
getTableSchema(name:String, refresh:Boolean = false):SQLTableSchema
[static]
Get the schema for the specified table.
| DB | ||
initDB(dbname:String):void
[static]
Initialize database for use within the application.
| DB | ||
mapForeignKey(klass:*):String
[static]
Map a class to its default foreign key name in another table.
| DB | ||
mapJoinTable(klass1:*, klass2:*):String
[static]
Map two classes into a join table name for representing the many-many
relationship between them.
| DB | ||
mapTable(klass:*):String
[static]
Map a class to a default table name through pluralized inflection.
| DB | ||
migrate(mobj:IMigratable):void
[static]
Request migration for a particular model.
| DB | ||
migrateAll():Boolean
[static]
Unsupported.
| DB | ||
sqlMap(value:Object):String
[static]
Map an object to its SQL representation appropriate for queries.
| DB |
Constant | Defined by | ||
---|---|---|---|
Field : Object [static]
| DB |
execute | () | method |
public static function execute(sql:String):SQLResult
Specify a SQL statement to be executed directly
Parameterssql:String — A valid SQL statement
|
SQLResult — A SQLResult
|
existsTable | () | method |
public static function existsTable(name:String):Boolean
Check if the specified table exists
Parametersname:String — The table name to check
|
Boolean — true if table exists, false otherwise
|
fieldMap | () | method |
public static function fieldMap(fieldSpec:Array):String
Map a DB field as specified in migration directives into an appropriate DB-specific CREATE statement clause after processing field type and column options.
ParametersfieldSpec:Array — An Array [name, type, options]
|
String — A SQL field clause for use in CREATE TABLE
|
getConnection | () | method |
public static function getConnection(dbname:String = null):SQLConnection
Obtain and cache a connection to the database. We use synchronous open.
Parametersdbname:String (default = null ) — (optional) The name for the database file
|
SQLConnection |
getSchema | () | method |
public static function getSchema(reloadSchema:Boolean = false):SQLSchemaResult
Get and cache the overall database schema.
ParametersreloadSchema:Boolean (default = false ) — (optional) Set to true to ignore the
cached schema and force a reload.
|
SQLSchemaResult — The SQL schema for the database.
|
getTableSchema | () | method |
public static function getTableSchema(name:String, refresh:Boolean = false):SQLTableSchema
Get the schema for the specified table.
Parametersname:String — The table name for which to get the schema
|
|
refresh:Boolean (default = false ) — If true force reload the DB schema.
|
SQLTableSchema — The SQL schema for the table. Returns null if the table does not
exist in the database.
|
initDB | () | method |
public static function initDB(dbname:String):void
Initialize database for use within the application. The database is stored in the AIR.File.applicationStorageDirectory
Parametersdbname:String — The name for the SQLite database file.
|
See also
mapForeignKey | () | method |
public static function mapForeignKey(klass:*):String
Map a class to its default foreign key name in another table.
Parametersklass:* — The model class (Class or Modeler)
|
String — The default foreign key name
|
mapForeignKey(Author); // ==> "author_id"
mapJoinTable | () | method |
public static function mapJoinTable(klass1:*, klass2:*):String
Map two classes into a join table name for representing the many-many relationship between them.
The table names are sorted alphabetically so as to ensure the same join table name for a given pair of classes, regardless of the parameter order during the function call.
Parametersklass1:* — One of the models (Class or Modeler)
|
|
klass2:* — The other model class
|
String — A default join table name
|
See also
mapJoinTable(Post, Category); // ==> "categories_posts"
mapTable | () | method |
public static function mapTable(klass:*):String
Map a class to a default table name through pluralized inflection.
Parametersklass:* — A Class or Modeler
|
String — The default table name mapping
|
See also
migrate | () | method |
public static function migrate(mobj:IMigratable):void
Request migration for a particular model. No external usage required.
Parametersmobj:IMigratable |
See also
migrateAll | () | method |
public static function migrateAll():Boolean
Unsupported. Do Not Use. Migrations are automatically carried out as and when required. Future Use: Force all migrations to run at once.
ReturnsBoolean |
sqlMap | () | method |
public static function sqlMap(value:Object):String
Map an object to its SQL representation appropriate for queries.
Deperecation Notice: This method will be removed when we switch to parameterized SQL operations.
Parametersvalue:Object — An Object (String or Date)
|
String |
Field | constant |
public static const Field:Object