---
sidebar_position: 7
---

# Structure

Defines a new Table structure.

## Methods

### constructor()
&rarr; (`tableDescription`? = __Array__\<[ColumnStructure](../typedefs/column-structure)\>) &rarr; `this`

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- |
| `tableDescription` __optional__ | __Array__\<[ColumnStructure](../typedefs/column-structure)\> | An array holding a list of column structure objects to define columns with.<br/><br/>You can get a `tableDescription` from a structure with the [get()](#get) method, store it and load it again by creating a [Structure](#structure) with it in this constructor. |

**Returns**

&rarr; `this`

***

### get()
&rarr; () &rarr; __Array__\<[ColumnStructure](../typedefs/column-structure)\>

Returns an array containing all defined columns in the [ColumnStructure](../typedefs/column-structure) object.

With this you can save the structure and load it again by passing it to the [constructor](#constructor) of a new [Structure](#structure).

**Returns**

&rarr; __Array__\<[ColumnStructure](../typedefs/column-structure)\>

***

### drop()
&rarr; (`name` = __String__) &rarr; `this`

Drops (removes) a column from this structure.

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- |
| `name` | __String__ | The column name to drop |

**Returns**

&rarr; `this`

***

### char()
&rarr; (`name` = __String__, `size`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'char' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of characters to store in this column. <br/><br/>- _Min_: 0<br/>- _Max_: 255<br/>- _Default_: 1 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### varchar()
&rarr; (`name` = __String__, `size`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'varchar' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of characters to store in this column. <br/><br/>- _Min_: 0<br/>- _Max_: 255<br/>- _Default_: 1 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### binary()
&rarr; (`name` = __String__, `size`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'binary' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of data. <br/><br/>- _Min_: 1<br/>- _Default_: 1 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### varbinary()
&rarr; (`name` = __String__, `size`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'varbinary' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of data. <br/><br/>- _Min_: 0<br/>- _Default_: 1 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### tinyblob()
&rarr; (`name` = __String__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'tinyblob' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### tinytext()
&rarr; (`name` = __String__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'tinytext' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### text()
&rarr; (`name` = __String__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'text' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### blob()
&rarr; (`name` = __String__, `size`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'blob' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of characters to store in this column. <br/><br/>- _Min_: 0<br/>- _Max_: 65535<br/>- _Default_: 65535 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### mediumtext()
&rarr; (`name` = __String__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'mediumtext' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### longtext()
&rarr; (`name` = __String__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'longtext' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### longblob()
&rarr; (`name` = __String__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'longblob' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### enum()
&rarr; (`name` = __String__, `vals`? = __Array__\<__String__\>, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'enum' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `vals` | __Array__\<__String__\> | Array of possible values for this column. |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### set()
&rarr; (`name` = __String__, `vals`? = __Array__\<__String__\>, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'enum' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `vals` | __Array__\<__String__\> | Array of possible values for this column. |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### bit()
&rarr; (`name` = __String__, `size`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'bit' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of data. <br/><br/>- _Min_: 1<br/>- _Max_: 64<br/>- _Default_: 1 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### tinyint()
&rarr; (`name` = __String__, `size`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'tinyint' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of data. <br/><br/>- _Min_: 1<br/>- _Max_: 255<br/>- _Default_: 255 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### bool()
&rarr; (`name` = __String__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'bool' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### smallint()
&rarr; (`name` = __String__, `size`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'smallint' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of data. <br/><br/>- _Min_: 1<br/>- _Max_: 255<br/>- _Default_: 255 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### mediumint()
&rarr; (`name` = __String__, `size`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'mediumint' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of data. <br/><br/>- _Min_: 1<br/>- _Max_: 255<br/>- _Default_: 255 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### int()
&rarr; (`name` = __String__, `size`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'int' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of data. <br/><br/>- _Min_: 1<br/>- _Max_: 255<br/>- _Default_: 255 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### bigint()
&rarr; (`name` = __String__, `size`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'bigint' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of data. <br/><br/>- _Min_: 1<br/>- _Max_: 255<br/>- _Default_: 255 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### float()
&rarr; (`name` = __String__, `p`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'float' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `p` __optional__ | __Number__ | Precision. <br/><br/>- _Min_: 1<br/>- _Max_: 53<br/>- _Default_: 25 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### double()
&rarr; (`name` = __String__, `size`? = __Number__, `d`? = __Number__ `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'double' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of data. <br/><br/>- _Min_: 1<br/>- _Default_: 16 |
| `d` __optional__ | __Number__ | Double precision. <br/><br/>- _Min_: 1<br/>- _Default_: 8 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### decimal()
&rarr; (`name` = __String__, `size`? = __Number__, `d`? = __Number__ `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'decimal' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `size` __optional__ | __Number__ | Maximum length of data. <br/><br/>- _Min_: 1<br/>- _Default_: 16 |
| `d` __optional__ | __Number__ | Double precision. <br/><br/>- _Min_: 1<br/>- _Default_: 8 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### date()
&rarr; (`name` = __String__,`options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'date' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### datetime()
&rarr; (`name` = __String__, `fsp`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'datetime' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `fsp` __optional__ | __Number__ | Fractional second precision. <br/><br/>- _Min_: 0<br/>- _Max_: 6<br/>- _Default_: 0 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### timestamp()
&rarr; (`name` = __String__, `fsp`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'timestamp' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `fsp` __optional__ | __Number__ | Fractional second precision. <br/><br/>- _Min_: 0<br/>- _Max_: 6<br/>- _Default_: 0 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### time()
&rarr; (`name` = __String__, `fsp`? = __Number__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'time' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `fsp` __optional__ | __Number__ | Fractional second precision. <br/><br/>- _Min_: 0<br/>- _Max_: 6<br/>- _Default_: 0 |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***

### year()
&rarr; (`name` = __String__, `options`? = [ConstraintOptions](../typedefs/constraint-options)) &rarr; `this`

Adds a new column of data type 'year' to this structure

**Parameters**

| Parameter | Type | Description |
| -- | -- | -- | 
| `name` | __String__ | Name of the column |
| `options` __optional__ | [ConstraintOptions](../typedefs/constraint-options) | Additional constraint options |

**Returns**

&rarr; `this`

***