Data Types
NuoDB supports a rich set of data types. However, with Node.js having only a few fundamental data types, data type mapping must occur from SQL types to types available in Node.js. Due to the overloading of types in Node, there are rules with which appropriate SQL types are chosen during inserts.
ECMAScript to SQL Mapping
Boolean
The Boolean type in ES is represented as a SQL BOOLEAN. True and false have the following aliases:
Value | Aliases |
---|---|
true |
1, ‘True’ |
false |
0, ‘False’ |
Number
The Number type in ES is used to represent all numeric types in ECMAScript. They are represented as IEEE Double Precision numbers. The limitation of this approach chosen in ECMAScript is that only 53 bits are usable for representing integer numbers; there is NO support in ECMAScript for 64-bit integers.
Inserts of Number types into the database uses the shortest permissible representation:
Kind | Range | Mapped SQL Type |
---|---|---|
Floating Point |
per IEEE 32-bit Floating Point |
FLOAT |
Floating Point |
per IEEE 64-bit Floating Point |
DOUBLE |
Integer |
-32,768 to 32,767 |
SMALLINT |
Integer |
-2,147,483,648 to 2,147,483,647 |
INT |
Integer |
-9007199254740990 to 9007199254740990 |
BIGINT |
Integer |
-9223372036854775808 to 9223372036854775807 |
VARCHAR |
String
The String type in ES is a Unicode string, and is directly representable in SQL as a string type, or equivalent aliases. ES has no support for single character primitives. ES String is represented as VARCHAR SQL types.
Date
The Date type in ES is used to represent all forms including: date, time, and datetime. ES has no support for distinct types for each form, whereas other languages, including SQL, do. Because of conflated concepts for date/time/datetime in ES, the only possible representation for the SQL wire protocol is VARCHAR. All Date objects are converted to VARCHAR before values are sent to the database. The types used in the database, however, may be DATE, TIME, or TIMESTAMP; however, it is the responsibility of the user to make sure that the appropriate values are passed to the Driver according to the following rules:
-
Time should be represented with an Epoch Date
-
Date should be represented with hours, minutes, seconds, set to zero.
NuoDB supports timestamps with 9 digits of precision (nanoseconds), but ECMAScript only supports 3 digits of precision (milliseconds). |