Class Index | File Index

Classes


Class Model


Extends comb.plugins.Middleware, moose.plugins.AssociationPlugin, moose.plugins.QueryPlugin.

Defined in: model.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Model(columnValues)
Base class for all models.
Field Summary
Field Attributes Field Name and Description
 
true if the model has been changed and not saved.
 
true if this model is new and does not exist in the database.
<static>  
Model.moose
moose - read only
 
moose - read only
 
the value of this models primaryKey
<static>  
Model.table
The table that this Model represents.
 
The table this model represent
 
The database type such as mysql
Method Summary
Method Attributes Method Name and Description
<static>  
Model.create(values)
Create a new model initialized with the specified values.
 
isValid(options)
Validate values against the model moose.Table#validate
<static>  
Model.isValid(options)
Validate values against the Model moose.Table#validate
<static>  
Model.load(values)
Create a new model instance from sql values.
 
Convert this model to JSON, containing column, value pairs.
 
Convert this model to an object, containing column, value pairs.
Methods borrowed from class moose.plugins.QueryPlugin:
reload, remove, save, toSql, update
Class Detail
Model(columnValues)
Base class for all models.

This is used through moose.addModel, NOT directly.

Parameters:
{Object} columnValues
values of each column to be used by this Model.
Field Detail
{Boolean} isChanged
true if the model has been changed and not saved.

{Boolean} isNew
true if this model is new and does not exist in the database.

<static> {moose} Model.moose
moose - read only

{moose} moose
moose - read only

{*} primaryKeyValue
the value of this models primaryKey

<static> Model.table
The table that this Model represents.

{moose.Table} table
The table this model represent

type
The database type such as mysql
Method Detail
<static> {Model} Model.create(values)
Create a new model initialized with the specified values.
Parameters:
{Object} values
the values to initialize the model with.
Returns:
{Model} instantiated model initialized with the values passed in.

{Boolean} isValid(options)
Validate values against the model moose.Table#validate
Parameters:
options
Returns:
{Boolean} true if the values are valid

<static> {Boolean} Model.isValid(options)
Validate values against the Model moose.Table#validate
Parameters:
options
Returns:
{Boolean} true if the values are valid

<static> {Model} Model.load(values)
Create a new model instance from sql values.
var myModel = Model.load({
   myDate : "1999-01-01",
   intValue : "1"
});

//intValue is converted to a number.
myModel.intValue => 1,
//mydate is converted to a date
myModel.myDate => new Date(1999,01,01);
Parameters:
{Object} values
object containing the values to initialize the model with.
Returns:
{Model} instantiated model initialized with the values passed in.

{JSON} toJson()
Convert this model to JSON, containing column, value pairs.
Returns:
{JSON} the JSON version of this model.

{Object} toObject()
Convert this model to an object, containing column, value pairs.
Returns:
{Object} the object version of this model.

Documentation generated by JsDoc Toolkit 2.4.0 on Sat Jun 11 2011 03:16:39 GMT-0500 (CDT)