# Class: ObjectType

## ObjectType

Base class representing a type of Ignite object.

The class has no public constructor. Only subclasses may be instantiated.

There are two groups of Ignite object types:

- Primitive (simple) types. To fully describe such a type it is enough to specify Ignite type code ObjectType.PRIMITIVE_TYPE only.

- Non-primitive (composite) types. To fully describe such a type Ignite type code ObjectType.COMPOSITE_TYPE with additional information should be specified. Eg. a kind of map or a kind of collection.

This class helps the Ignite client to make a mapping between JavaScript types and types used by Ignite.

In many methods the Ignite client does not require to directly specify a type of Ignite object. In this case the Ignite client tries to make automatic mapping between JavaScript types and Ignite object types according to the following mapping tables:

DEFAULT MAPPING FROM JavaScript type TO Ignite type code.

This mapping is used when an application does not explicitly specify an Ignite type for a field and is writing data to that field.

    | JavaScript type           | Ignite type code      |
    | ------------------------- | ----------------------|
    | number                    | DOUBLE                |
    | boolean                   | BOOLEAN               |
    | string                    | STRING                |
    | Date                      | DATE                  |
    | Timestamp*                | TIMESTAMP             |
    | EnumItem*                 | ENUM                  |
    | Decimal**                 | DECIMAL               |
    | BinaryObject*             | COMPLEX_OBJECT        |
    | Array of number           | DOUBLE_ARRAY          |
    | Array of boolean          | BOOLEAN_ARRAY         |
    | Array of string           | STRING_ARRAY          |
    | Array of Date             | DATE_ARRAY            |
    | Array of Timestamp*       | TIMESTAMP_ARRAY       |
    | Array of EnumItem*        | ENUM_ARRAY            |
    | Array of Decimal**        | DECIMAL_ARRAY         |
    | Array of BinaryObject*    | OBJECT_ARRAY          |
    | Array of any other Object | OBJECT_ARRAY          |
    | Set                       | COLLECTION (HASH_SET) |
    | Map                       | MAP (HASH_MAP)        |
    | any other Object          | COMPLEX_OBJECT        |

Type of an array content is determined by the type of the first element of the array. Empty array has no default mapping.

All other JavaScript types have no default mapping.

DEFAULT MAPPING FROM Ignite type code TO JavaScript type.

This mapping is used when an application does not explicitly specify an Ignite type for a field and is reading data from that field.

    | Ignite type code             | JavaScript type                       |
    | ---------------------------- | --------------------------------------|
    | BYTE                         | number                                |
    | SHORT                        | number                                |
    | INTEGER                      | number                                |
    | LONG                         | number                                |
    | FLOAT                        | number                                |
    | DOUBLE                       | number                                |
    | DECIMAL                      | Decimal**                             |
    | BOOLEAN                      | boolean                               |
    | STRING                       | string                                |
    | CHAR                         | string (one character)                |
    | UUID                         | Array of number (16 numbers)          |
    | DATE                         | Date                                  |
    | TIME                         | Date                                  |
    | TIMESTAMP                    | Timestamp*                            |
    | ENUM                         | EnumItem*                             |
    | COMPLEX_OBJECT               | BinaryObject*                         |
    | BYTE_ARRAY                   | Array of number                       |
    | SHORT_ARRAY                  | Array of number                       |
    | INTEGER_ARRAY                | Array of number                       |
    | LONG_ARRAY                   | Array of number                       |
    | FLOAT_ARRAY                  | Array of number                       |
    | DOUBLE_ARRAY                 | Array of number                       |
    | DECIMAL_ARRAY                | Array of Decimal**                    |
    | BOOLEAN_ARRAY                | Array of boolean                      |
    | STRING_ARRAY                 | Array of string                       |
    | CHAR_ARRAY                   | Array of string (one character)       |
    | UUID_ARRAY                   | Array of Array of number (16 numbers) |
    | DATE_ARRAY                   | Array of Date                         |
    | TIME_ARRAY                   | Array of Date                         |
    | TIMESTAMP_ARRAY              | Array of Timestamp*                   |
    | ENUM_ARRAY                   | Array of EnumItem*                    |
    | OBJECT_ARRAY                 | Array                                 |
    | COLLECTION (USER_COL)        | Array                                 |
    | COLLECTION (ARR_LIST)        | Array                                 |
    | COLLECTION (LINKED_LIST)     | Array                                 |
    | COLLECTION (SINGLETON_LIST)  | Array                                 |
    | COLLECTION (HASH_SET)        | Set                                   |
    | COLLECTION (LINKED_HASH_SET) | Set                                   |
    | COLLECTION (USER_SET)        | Set                                   |
    | MAP (HASH_MAP)               | Map                                   |
    | MAP (LINKED_HASH_MAP)        | Map                                   |
    | NULL                         | null                                  |

RETURNED JavaScript types WHEN READING DATA OF THE SPECIFIED Ignite type code.

When an application explicitly specifies an Ignite type for a field and is reading data from that field - the following JavaScript types are returned for every concrete Ignite type code -

SEE THE PREVIOUS TABLE with the following additional comments:

- for COMPLEX_OBJECT the Ignite Client returns a JavaScript Object which is defined by the specified ComplexObjectType.

- the returned Map for MAP is defined by the specified MapObjectType.

- the returned Set or Array for COLLECTION is defined by the specified CollectionObjectType.

- the returned Array for OBJECT_ARRAY is defined by the specified ObjectArrayType.

- NULL cannot be specified as a type of a field but JavaScript null may be returned as a value of a field.

ALLOWED JavaScript types WHEN WRITING DATA OF THE SPECIFIED Ignite type code.

When an application explicitly specifies an Ignite type for a field and is writing data to that field - the following JavaScript types are allowed for every concrete Ignite type code -

SEE THE PREVIOUS TABLE with the following additional comments:

- for COMPLEX_OBJECT the Ignite Client allows a JavaScript Object which is defined by the specified ComplexObjectType.

- the allowed Map for MAP is defined by the specified MapObjectType.

- the allowed Set or Array for COLLECTION is defined by the specified CollectionObjectType.

- the allowed Array for OBJECT_ARRAY is defined by the specified ObjectArrayType.

- NULL cannot be specified as a type of a field but JavaScript null is allowed as value of a field (but not as a key/value in a cache) or as a value of Array/Set/Map element for all Ignite types, except BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE, CHAR, BOOLEAN.

- for all *_ARRAY Ignite types an empty JavaScript Array is allowed.

COMMENTS TO ALL TABLES

JavaScript type - is a JavaScript primitive or a JavaScript Object (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures)

(*) Timestamp, EnumItem and BinaryObject - are JavaScript Objects introduced by the Ignite client.

(**) Decimal - is an external JavaScript Object exported into the Ignite client (https://github.com/MikeMcl/decimal.js)

Ignite type code - is the type code of an Ignite primitive type (ObjectType.PRIMITIVE_TYPE) or an Ignite composite type (ObjectType.COMPOSITE_TYPE).

Source:
  - ObjectType.js, line 291

### Members

#### (static, readonly) COMPOSITE_TYPE

Supported Ignite type codes for non-primitive (composite) types.

##### Properties:

Name | Type | Description
--- | --- | ---
`OBJECT_ARRAY` |  | 23
`COLLECTION` |  | 24
`MAP` |  | 25
`NULL` |  | 101
`COMPLEX_OBJECT` |  | 103

Source:
  - ObjectType.js, line 93

#### (static, readonly) PRIMITIVE_TYPE

Supported Ignite type codes for primitive (simple) types.

##### Properties:

Name | Type | Description
--- | --- | ---
`BYTE` |  | 1
`SHORT` |  | 2
`INTEGER` |  | 3
`LONG` |  | 4
`FLOAT` |  | 5
`DOUBLE` |  | 6
`CHAR` |  | 7
`BOOLEAN` |  | 8
`STRING` |  | 9
`UUID` |  | 10
`DATE` |  | 11
`BYTE_ARRAY` |  | 12
`SHORT_ARRAY` |  | 13
`INTEGER_ARRAY` |  | 14
`LONG_ARRAY` |  | 15
`FLOAT_ARRAY` |  | 16
`DOUBLE_ARRAY` |  | 17
`CHAR_ARRAY` |  | 18
`BOOLEAN_ARRAY` |  | 19
`STRING_ARRAY` |  | 20
`UUID_ARRAY` |  | 21
`DATE_ARRAY` |  | 22
`ENUM` |  | 28
`ENUM_ARRAY` |  | 29
`DECIMAL` |  | 30
`DECIMAL_ARRAY` |  | 31
`TIMESTAMP` |  | 33
`TIMESTAMP_ARRAY` |  | 34
`TIME` |  | 36
`TIME_ARRAY` |  | 37

Source:
  - ObjectType.js, line 24