Class Type
Represents a mysql datatype. This Class should not be instantiated directly!
Defined in: index.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Type()
|
Field Attributes | Field Name and Description |
---|---|
the column definition of this Type.
|
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.
|
|
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.
|
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.