Classes
- BaseType ⇐
AbstractType - NumericType ⇐
BaseType - StringType ⇐
BaseType - ForeignKey ⇐
Reference - One ⇐
Reference - Many ⇐
One
Mixins
Types
Kind: global mixin
- Types
- .Bit ⇒
BaseType - .Tinyint ⇒
NumericType - .Smallint ⇒
NumericType - .Mediumint ⇒
NumericType - .Int ⇒
NumericType - .Integer ⇒
NumericType - .Bigint ⇒
NumericType - .Double ⇒
NumericType - .Real ⇒
NumericType - .Decimal ⇒
NumericType - .Numeric ⇒
NumericType - .Float ⇒
NumericType - .Date ⇒
BaseType - .Time ⇒
BaseType - .Timestamp ⇒
BaseType - .Datetime ⇒
BaseType - .Char ⇒
StringType - .Varchar ⇒
StringType - .Binary ⇒
BaseType - .Varbinary ⇒
BaseType - .Tinyblob ⇒
BaseType - .Blob ⇒
BaseType - .Mediumblob ⇒
BaseType - .Longblob ⇒
BaseType - .Tinytext ⇒
StringType - .Text ⇒
StringType - .Mediumtext ⇒
StringType - .Longtext ⇒
StringType - .Enum ⇒
StringType - .Set ⇒
StringType - .One ⇒
One - .Many ⇒
Many - .ForeignKey ⇒
ForeignKey - .Boolean ⇒
NumericType - .String ⇒
StringType - .NOW() ⇒
function - .Id() ⇒
NumericType
Types.Bit ⇒ BaseType
A bit-field type
Kind: static property of Types
| Param | Type | Default | Description |
|---|---|---|---|
| [M] | Number |
1 |
The number of bits per value, from 1 to 64 |
Types.Tinyint ⇒ NumericType
A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
The maximum display width |
Types.Smallint ⇒ NumericType
A small integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535.
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
The maximum display width |
Types.Mediumint ⇒ NumericType
A medium-sized integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
The maximum display width |
Types.Int ⇒ NumericType
A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
The maximum display width |
Types.Integer ⇒ NumericType
Synonym for INT
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
The maximum display width |
Types.Bigint ⇒ NumericType
A large integer. The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615.
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
The maximum display width |
Types.Double ⇒ NumericType
A normal-size (double-precision) floating-point number. Permissible values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308.
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
The total number of digits |
| [D] | Number |
The number of digits following the decimal point |
Types.Real ⇒ NumericType
Synonym for Double
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
The total number of digits |
| [D] | Number |
The number of digits following the decimal point |
Types.Decimal ⇒ NumericType
A packed "exact" fixed-point number.
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
The total number of digits (the precision) |
| [D] | Number |
The number of digits after the decimal point (the scale) |
Types.Numeric ⇒ NumericType
Synonym for Decimal
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
The total number of digits (the precision) |
| [D] | Number |
The number of digits after the decimal point (the scale) |
Types.Float ⇒ NumericType
A small (single-precision) floating-point number. Permissible values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38.
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
The total number of digits |
| [D] | Number |
The number of digits after the decimal point |
Types.Date ⇒ BaseType
A date
Kind: static property of Types
Types.Time ⇒ BaseType
A time
Kind: static property of Types
Types.Timestamp ⇒ BaseType
A timestamp
Kind: static property of Types
Types.Datetime ⇒ BaseType
A date and time combination
Kind: static property of Types
Types.Char ⇒ StringType
A fixed-length string that is always right-padded with spaces to the specified length when stored.
Kind: static property of Types
| Param | Type | Default | Description |
|---|---|---|---|
| [M] | Number |
1 |
The column length in characters |
Types.Varchar ⇒ StringType
A variable-length string.
Kind: static property of Types
| Param | Type | Default | Description |
|---|---|---|---|
| [M] | Number |
255 |
The column length in characters |
Types.Binary ⇒ BaseType
Similar to the CHAR type, but stores binary byte strings rather than nonbinary character strings.
Kind: static property of Types
| Param | Type | Default | Description |
|---|---|---|---|
| [M] | Number |
1 |
The column length in characters |
Types.Varbinary ⇒ BaseType
Similar to the VARCHAR type, but stores binary byte strings rather than nonbinary character strings.
Kind: static property of Types
| Param | Type | Default | Description |
|---|---|---|---|
| [M] | Number |
255 |
The column length in characters |
Types.Tinyblob ⇒ BaseType
A BLOB column with a maximum length of 255 bytes
Kind: static property of Types
Types.Blob ⇒ BaseType
A BLOB column with a maximum length of 65,535 bytes
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| [M] | Number |
A maximum length of bytes |
Types.Mediumblob ⇒ BaseType
A BLOB column with a maximum length of 16,777,215 bytes
Kind: static property of Types
Types.Longblob ⇒ BaseType
A BLOB column with a maximum length of 4GB
Kind: static property of Types
Types.Tinytext ⇒ StringType
A TEXT column with a maximum length of 255 characters
Kind: static property of Types
Types.Text ⇒ StringType
A TEXT column with a maximum length of 65,535 characters
Kind: static property of Types
Types.Mediumtext ⇒ StringType
A TEXT column with a maximum length of 16,777,215 characters
Kind: static property of Types
Types.Longtext ⇒ StringType
A TEXT column with a maximum length of 4GB characters
Kind: static property of Types
Types.Enum ⇒ StringType
An enumeration. A string object that can have only one value, chosen from the list of values
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| ...values | string |
The list of values |
Types.Set ⇒ StringType
A set. A string object that can have zero or more values, each of which must be chosen from the list of values
Kind: static property of Types
| Param | Type | Description |
|---|---|---|
| ...values | string |
The list of values |
Types.One ⇒ One
A reference to one other Model. This create a foreign key in the target Model matching the primary key of the source model. This reference is retrieved as a Model Instance.
Kind: static property of Types
| Param | Type |
|---|---|
| target | string | Model |
Types.Many ⇒ Many
A reference to multiple other Models. This create a foreign key in the target Model matching the primary key of the source model. This reference is retrieved as an Array of Model Instances.
Kind: static property of Types
| Param | Type |
|---|---|
| target | string | Model |
Types.ForeignKey ⇒ ForeignKey
A foreign key matching the primary key of the target Model
Kind: static property of Types
| Param | Type |
|---|---|
| target | string | Model |
Types.Boolean ⇒ NumericType
Synonym for Tinyint(1)
Kind: static property of Types
Types.String ⇒ StringType
Synonym for Varchar
Kind: static property of Types
| Param | Type | Default | Description |
|---|---|---|---|
| [M] | Number |
255 |
The column length in characters |
Types.NOW() ⇒ function
The current date, this is mainly used when you want to set a default new date
Kind: static method of Types
Example
var User = ziti.define('User', {
signup_date: ziti.Datetime().default(ziti.NOW)
});
Types.Id() ⇒ NumericType
A shortcut for ziti.Int().primaryKey().autoIncrement().notNull()
Kind: static method of Types
BaseType ⇐ AbstractType
Kind: global class
Extends: AbstractType
- BaseType ⇐
AbstractType - .primaryKey() ↩︎
- .unique([name]) ↩︎
- .autoIncrement() ↩︎
- .notNull() ↩︎
- .default(value) ↩︎
- .get(fn) ↩︎
- .set(fn) ↩︎
- .$(scope) ↩︎
baseType.primaryKey() ↩︎
Set this field as primary key
Kind: instance method of BaseType
Chainable
baseType.unique([name]) ↩︎
Set this field as unique
Kind: instance method of BaseType
Chainable
| Param | Type | Description |
|---|---|---|
| [name] | string |
Name of a unique constraint |
baseType.autoIncrement() ↩︎
Set this field as auto increment
Kind: instance method of BaseType
Chainable
baseType.notNull() ↩︎
Set this field as not null
Kind: instance method of BaseType
Chainable
baseType.default(value) ↩︎
Set a default value for this field If the value is a function, it's evaluated during the insertion
Kind: instance method of BaseType
Chainable
| Param | Type |
|---|---|
| value | string | Number | function |
baseType.get(fn) ↩︎
Set a getter
Kind: instance method of BaseType
Chainable
| Param | Type |
|---|---|
| fn | function |
baseType.set(fn) ↩︎
Set a setter
Kind: instance method of BaseType
Chainable
| Param | Type |
|---|---|
| fn | function |
baseType.$(scope) ↩︎
Add this field to a scope or multiple scopes
Kind: instance method of BaseType
Chainable
| Param | Type |
|---|---|
| scope | string | Array.<string> |
NumericType ⇐ BaseType
Kind: global class
Extends: BaseType
- NumericType ⇐
BaseType - .zerofill() ↩︎
- .unsigned() ↩︎
- .primaryKey() ↩︎
- .unique([name]) ↩︎
- .autoIncrement() ↩︎
- .notNull() ↩︎
- .default(value) ↩︎
- .get(fn) ↩︎
- .set(fn) ↩︎
- .$(scope) ↩︎
numericType.zerofill() ↩︎
Set this field as zerofill
Kind: instance method of NumericType
Chainable
numericType.unsigned() ↩︎
Set this field as unsigned
Kind: instance method of NumericType
Chainable
numericType.primaryKey() ↩︎
Set this field as primary key
Kind: instance method of NumericType
Chainable
numericType.unique([name]) ↩︎
Set this field as unique
Kind: instance method of NumericType
Chainable
| Param | Type | Description |
|---|---|---|
| [name] | string |
Name of a unique constraint |
numericType.autoIncrement() ↩︎
Set this field as auto increment
Kind: instance method of NumericType
Chainable
numericType.notNull() ↩︎
Set this field as not null
Kind: instance method of NumericType
Chainable
numericType.default(value) ↩︎
Set a default value for this field If the value is a function, it's evaluated during the insertion
Kind: instance method of NumericType
Chainable
| Param | Type |
|---|---|
| value | string | Number | function |
numericType.get(fn) ↩︎
Set a getter
Kind: instance method of NumericType
Chainable
| Param | Type |
|---|---|
| fn | function |
numericType.set(fn) ↩︎
Set a setter
Kind: instance method of NumericType
Chainable
| Param | Type |
|---|---|
| fn | function |
numericType.$(scope) ↩︎
Add this field to a scope or multiple scopes
Kind: instance method of NumericType
Chainable
| Param | Type |
|---|---|
| scope | string | Array.<string> |
StringType ⇐ BaseType
Kind: global class
Extends: BaseType
- StringType ⇐
BaseType - .charset() ↩︎
- .collate() ↩︎
- .primaryKey() ↩︎
- .unique([name]) ↩︎
- .autoIncrement() ↩︎
- .notNull() ↩︎
- .default(value) ↩︎
- .get(fn) ↩︎
- .set(fn) ↩︎
- .$(scope) ↩︎
stringType.charset() ↩︎
Set this field charset
Kind: instance method of StringType
Chainable
stringType.collate() ↩︎
Set this field a collation name
Kind: instance method of StringType
Chainable
stringType.primaryKey() ↩︎
Set this field as primary key
Kind: instance method of StringType
Chainable
stringType.unique([name]) ↩︎
Set this field as unique
Kind: instance method of StringType
Chainable
| Param | Type | Description |
|---|---|---|
| [name] | string |
Name of a unique constraint |
stringType.autoIncrement() ↩︎
Set this field as auto increment
Kind: instance method of StringType
Chainable
stringType.notNull() ↩︎
Set this field as not null
Kind: instance method of StringType
Chainable
stringType.default(value) ↩︎
Set a default value for this field If the value is a function, it's evaluated during the insertion
Kind: instance method of StringType
Chainable
| Param | Type |
|---|---|
| value | string | Number | function |
stringType.get(fn) ↩︎
Set a getter
Kind: instance method of StringType
Chainable
| Param | Type |
|---|---|
| fn | function |
stringType.set(fn) ↩︎
Set a setter
Kind: instance method of StringType
Chainable
| Param | Type |
|---|---|
| fn | function |
stringType.$(scope) ↩︎
Add this field to a scope or multiple scopes
Kind: instance method of StringType
Chainable
| Param | Type |
|---|---|
| scope | string | Array.<string> |
ForeignKey ⇐ Reference
Kind: global class
Extends: Reference
- ForeignKey ⇐
Reference - new ForeignKey(target)
- .on(link) ↩︎
- .joinType(type) ↩︎
- .primaryKey() ↩︎
- .unique([name]) ↩︎
- .autoIncrement() ↩︎
- .notNull() ↩︎
- .default(value) ↩︎
- .get(fn) ↩︎
- .set(fn) ↩︎
- .$(scope) ↩︎
new ForeignKey(target)
One to one association
| Param | Type |
|---|---|
| target | string | Model |
foreignKey.on(link) ↩︎
Set a link between source and target in the form:
{ leftField1: rightField1, leftField2: rightField2 }
Kind: instance method of ForeignKey
Chainable
| Param | Type |
|---|---|
| link | Object |
foreignKey.joinType(type) ↩︎
Override the join type which is 'LEFT JOIN' by default
Kind: instance method of ForeignKey
Chainable
| Param | Type |
|---|---|
| type | string |
foreignKey.primaryKey() ↩︎
Set this field as primary key
Kind: instance method of ForeignKey
Chainable
foreignKey.unique([name]) ↩︎
Set this field as unique
Kind: instance method of ForeignKey
Chainable
| Param | Type | Description |
|---|---|---|
| [name] | string |
Name of a unique constraint |
foreignKey.autoIncrement() ↩︎
Set this field as auto increment
Kind: instance method of ForeignKey
Chainable
foreignKey.notNull() ↩︎
Set this field as not null
Kind: instance method of ForeignKey
Chainable
foreignKey.default(value) ↩︎
Set a default value for this field If the value is a function, it's evaluated during the insertion
Kind: instance method of ForeignKey
Chainable
| Param | Type |
|---|---|
| value | string | Number | function |
foreignKey.get(fn) ↩︎
Set a getter
Kind: instance method of ForeignKey
Chainable
| Param | Type |
|---|---|
| fn | function |
foreignKey.set(fn) ↩︎
Set a setter
Kind: instance method of ForeignKey
Chainable
| Param | Type |
|---|---|
| fn | function |
foreignKey.$(scope) ↩︎
Add this field to a scope or multiple scopes
Kind: instance method of ForeignKey
Chainable
| Param | Type |
|---|---|
| scope | string | Array.<string> |
One ⇐ Reference
Kind: global class
Extends: Reference
- One ⇐
Reference - new One(target)
- .relatedName(name) ↩︎
- .on(link) ↩︎
- .joinType(type) ↩︎
- .primaryKey() ↩︎
- .unique([name]) ↩︎
- .autoIncrement() ↩︎
- .notNull() ↩︎
- .default(value) ↩︎
- .get(fn) ↩︎
- .set(fn) ↩︎
- .$(scope) ↩︎
new One(target)
One to one association
| Param | Type |
|---|---|
| target | string | Model |
one.relatedName(name) ↩︎
The name to use for the back reference in the target This is useful when setting a One attribute in the source related to an existing ForeignKey attribute in the target
Kind: instance method of One
Chainable
| Param | Type | Description |
|---|---|---|
| name | string |
Name of the attribute |
one.on(link) ↩︎
Set a link between source and target in the form:
{ leftField1: rightField1, leftField2: rightField2 }
Kind: instance method of One
Chainable
| Param | Type |
|---|---|
| link | Object |
one.joinType(type) ↩︎
Override the join type which is 'LEFT JOIN' by default
Kind: instance method of One
Chainable
| Param | Type |
|---|---|
| type | string |
one.primaryKey() ↩︎
Set this field as primary key
Kind: instance method of One
Chainable
one.unique([name]) ↩︎
Set this field as unique
Kind: instance method of One
Chainable
| Param | Type | Description |
|---|---|---|
| [name] | string |
Name of a unique constraint |
one.autoIncrement() ↩︎
Set this field as auto increment
Kind: instance method of One
Chainable
one.notNull() ↩︎
Set this field as not null
Kind: instance method of One
Chainable
one.default(value) ↩︎
Set a default value for this field If the value is a function, it's evaluated during the insertion
Kind: instance method of One
Chainable
| Param | Type |
|---|---|
| value | string | Number | function |
one.get(fn) ↩︎
Set a getter
Kind: instance method of One
Chainable
| Param | Type |
|---|---|
| fn | function |
one.set(fn) ↩︎
Set a setter
Kind: instance method of One
Chainable
| Param | Type |
|---|---|
| fn | function |
one.$(scope) ↩︎
Add this field to a scope or multiple scopes
Kind: instance method of One
Chainable
| Param | Type |
|---|---|
| scope | string | Array.<string> |
Many ⇐ One
Kind: global class
Extends: One
- Many ⇐
One - new Many(target)
- .through(target) ↩︎
- .relatedName(name) ↩︎
- .on(link) ↩︎
- .joinType(type) ↩︎
- .primaryKey() ↩︎
- .unique([name]) ↩︎
- .autoIncrement() ↩︎
- .notNull() ↩︎
- .default(value) ↩︎
- .get(fn) ↩︎
- .set(fn) ↩︎
- .$(scope) ↩︎
new Many(target)
(One|many) to many association
| Param | Type | Description |
|---|---|---|
| target | string | Model |
The referenced model |
many.through(target) ↩︎
Set an intermediary target when using a many to many association
Kind: instance method of Many
Chainable
| Param | Type | Description |
|---|---|---|
| target | string | Model |
The intermediary model |
many.relatedName(name) ↩︎
The name to use for the back reference in the target This is useful when setting a Many attribute in the source related to an existing ForeignKey attribute in the target Note that if it is used after through, it refers to the intermediary target
Kind: instance method of Many
Chainable
Overrides: relatedName
| Param | Type | Description |
|---|---|---|
| name | string |
Name of the attribute |
Example
var UserLanguage = ziti.define('UserLanguage', {
lang: ziti.ForeignKey('Language'),
speaker: ziti.ForeignKey('User')
});
var Language = ziti.define('Language', {
name: ziti.String,
users: ziti.Many('User')
.relatedName('lang')
.through(UserLanguage)
.relatedName('speaker')
});
var User = ziti.define('User', {
nickname: ziti.String,
langs: ziti.Many(Language)
.relatedName('speaker')
.through(UserLanguage)
.relatedName('lang')
});
many.on(link) ↩︎
Set a link between source and target in the form:
{ leftField1: rightField1, leftField2: rightField2 }
Kind: instance method of Many
Chainable
| Param | Type |
|---|---|
| link | Object |
many.joinType(type) ↩︎
Override the join type which is 'LEFT JOIN' by default
Kind: instance method of Many
Chainable
| Param | Type |
|---|---|
| type | string |
many.primaryKey() ↩︎
Set this field as primary key
Kind: instance method of Many
Chainable
many.unique([name]) ↩︎
Set this field as unique
Kind: instance method of Many
Chainable
| Param | Type | Description |
|---|---|---|
| [name] | string |
Name of a unique constraint |
many.autoIncrement() ↩︎
Set this field as auto increment
Kind: instance method of Many
Chainable
many.notNull() ↩︎
Set this field as not null
Kind: instance method of Many
Chainable
many.default(value) ↩︎
Set a default value for this field If the value is a function, it's evaluated during the insertion
Kind: instance method of Many
Chainable
| Param | Type |
|---|---|
| value | string | Number | function |
many.get(fn) ↩︎
Set a getter
Kind: instance method of Many
Chainable
| Param | Type |
|---|---|
| fn | function |
many.set(fn) ↩︎
Set a setter
Kind: instance method of Many
Chainable
| Param | Type |
|---|---|
| fn | function |
many.$(scope) ↩︎
Add this field to a scope or multiple scopes
Kind: instance method of Many
Chainable
| Param | Type |
|---|---|
| scope | string | Array.<string> |