Class Index | File Index

## Classes

- _Association
- _global_
- Dataset
- ManyToMany
- ManyToOne
- MayToOne
- Migrations
- Model
- moose
- moose.adapters
- moose.adapters.client.Client
- moose.adapters.client.ConnectionPool
- moose.adapters.client.mysql.ConnectionPool
- moose.adapters.client.mysql.Query
- moose.adapters.client.mysql.TransactionQuery
- moose.adapters.mysql
- moose.adapters.mysql.types
- moose.plugins
- moose.plugins.AssociationPlugin
- moose.plugins.CachePlugin
- moose.plugins.QueryPlugin
- moose.plugins.TimeStampPlugin
- moose.Table
- OneToMany
- SQL
- Type

# Class Type

Represents a mysql datatype. This Class should not be instantiated directly!
Defined in: index.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| Type()

Field Summary
Field Attributes | Field Name and Description
--- | ---
| sql the column definition of this Type.

Method Summary
Method Attributes | Method Name and Description
--- | ---
| check(value) Checks a value against this Type column definition.
| fromSql(val) Convert an SQL value to the javascript equivalent.
| isPrimaryKey() Is this Type a primary key.
| set(name, value) Set a property on this Type, such as isNull, unique, default etc.
| toSql(val) Converts a javacript value to the corresponding sql equivalent.

Class Detail
Type()
Field Detail
{String} sql
the column definition of this Type.
Method Detail
{Boolean} check(value)
Checks a value against this Type column definition.

Parameters:
{*} value
  the value to check.

Returns:
  {Boolean} true if the value is valid.

{*} fromSql(val)
Convert an SQL value to the javascript equivalent. This method will do a type check after the conversionn.

Parameters:
{String} val
  the sql string to convert.

Returns:
  {*} the javascript value.

{Boolean} isPrimaryKey()
Is this Type a primary key.

Returns:
  {Boolean} true if this Type is a primary key.

set(name, value)
Set a property on this Type, such as isNull, unique, default etc...

Parameters:
{String} name
  the name of the property.
{*} value
  the value to set it to.

{String} toSql(val)
Converts a javacript value to the corresponding sql equivalent. This function does a type check on the value before conversion, if it is not the right type an error is thrown.

Parameters:
{*} val
  the javacript value to convert

Returns:
  {String} the sql value.

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