GearsORM. Model.js

Contains GearsORM.Model a metaclass used to define models

License

MIT-style license.

Summary
GearsORM. Model.jsContains GearsORM.Model a metaclass used to define models
GearsORM. Modela metaclass to define models that represent database tables.
GearsORM. Model. modelrepresent a model instance
Functions
removeremove the instance from the database
save
updateupdate instance into database,use save instead.
insertinsert instance into database,use save instead.
_updateInsertdo the actual insert/update,used by insert and update methods.
refreshrefresh the model data from database.
_populateFromResultpopulate the instance from a ResultSet.
selectdo a SELECT on the model
removedo a DELETE on the model
createTablecreate the table for this model,creating triggers for forigenkeys and creating many-to-many tables if needed.
dropTabledrop the table and all associate triggers.
createTriggerscreate triggers to inforce forigenkeys.
dropTriggersdrop triggers related to the table.
loadload objects from a array to the database.

GearsORM. Model

a metaclass to define models that represent database tables. a metaclass is a class in which the instances are also classes.

Constructor

Parameters

optionsa object used to describe the model look like this: { name : “Name of the model table”, fields: { name_of_the_field:a_instance_of_GearsORM.Fields.* } }

GearsORM. Model. model

represent a model instance

Constructor

Parameters

valuesOrRowID(optional)a object used to initialize the model instance with values or it can be the id of the row,in that case it will do a select to retrive the model data.
Summary
Functions
removeremove the instance from the database
save
updateupdate instance into database,use save instead.
insertinsert instance into database,use save instead.
_updateInsertdo the actual insert/update,used by insert and update methods.
refreshrefresh the model data from database.
_populateFromResultpopulate the instance from a ResultSet.
selectdo a SELECT on the model
removedo a DELETE on the model
createTablecreate the table for this model,creating triggers for forigenkeys and creating many-to-many tables if needed.
dropTabledrop the table and all associate triggers.
createTriggerscreate triggers to inforce forigenkeys.
dropTriggersdrop triggers related to the table.
loadload objects from a array to the database.

Functions

remove

remove:function()

remove the instance from the database

save

save:function()
save the instance to the database,if the instance is not in the databaseit will be created. if it is already in the database it will be updated.

update

update:function()

update instance into database,use save instead.

insert

insert:function()

insert instance into database,use save instead.

_updateInsert

_updateInsert:function(update)

do the actual insert/update,used by insert and update methods.

refresh

refresh:function()

refresh the model data from database.

_populateFromResult

_populateFromResult:function(result)

populate the instance from a ResultSet.

Parameters

resulta ResultSet that used to populate the instance.

select

select:function(whereExpression,
params)

do a SELECT on the model

Parameters

whereExpressiona SQL expression to be used as the WHERE clause.
paramsbind parameters used in the SQL expression.

Returns

a new ResultIterator to iterate the ResultSet

remove

remove:function(whereExpression,
params)

do a DELETE on the model

Parameters

whereExpressiona SQL expression to be used as the WHERE clause.
paramsbind parameters used in the SQL expression.

createTable

createTable:function()

create the table for this model,creating triggers for forigenkeys and creating many-to-many tables if needed.

dropTable

dropTable:function()

drop the table and all associate triggers.

createTriggers

createTriggers:function()

create triggers to inforce forigenkeys.

dropTriggers

dropTriggers:function()

drop triggers related to the table.

load

load:function(objects,
save)

load objects from a array to the database.

Parameters

objectsa array of objects or one object to be saved in the database.
saveif set to true all the objects will be saved to the database.

Returns

return all the objects mapped using the model class.

remove:function()
remove the instance from the database
save:function()
update:function()
update instance into database,use save instead.
insert:function()
insert instance into database,use save instead.
_updateInsert:function(update)
do the actual insert/update,used by insert and update methods.
refresh:function()
refresh the model data from database.
_populateFromResult:function(result)
populate the instance from a ResultSet.
select:function(whereExpression,
params)
do a SELECT on the model
createTable:function()
create the table for this model,creating triggers for forigenkeys and creating many-to-many tables if needed.
dropTable:function()
drop the table and all associate triggers.
createTriggers:function()
create triggers to inforce forigenkeys.
dropTriggers:function()
drop triggers related to the table.
load:function(objects,
save)
load objects from a array to the database.