Schema and Datatypes

Datatypes

OptimaDB supports a wide range of Data Types from the basic Int, Float and Text to more advanced ones like UUID, Email and Password.
Here is a full list of the Types OptimaDB offers:

Types

Int

Float

Text

Boolean

Time

Email

UUID

Password

Array

Json

Typescript Type

number

number

string

boolean

Date

string

string

string

Array

Object

Type Checking

None

None

None

None

Compile Time

Run Time

Run Time

None

Compile Time

Compile Time

Options

notNulldefaultenumprimaryKeyuniquecheckautoIncrement

notNulldefaultenumprimaryKeyuniquecheck

notNulldefaultenumprimaryKeyuniquecheck

notNulldefaultcheck

notNulldefaultenumuniquecheck

notNulldefaultenumprimaryKeyuniquecheck

notNulldefaultenumprimaryKeycheck

notNullcheck

notNulldefaultenumuniquecheck

notNulldefaultenumuniquecheck

* Disclaimer: Types are subject to change and more will be added and improved

Type Examples

Int

Integer type for whole numbers (stored as INTEGER). Supports primary keys and autoincrement, making it ideal for IDs, counters, and any field where only whole numbers are valid. Ensures efficient storage and fast numeric operations.

typescript

typescript

1

2

3

4

5

Float

Floating point type for decimals (stored as REAL). Useful for prices, measurements, or any value that requires fractional precision. Does not support autoincrement, but allows for flexible numeric data with decimal points.

typescript

typescript

1

2

3

4

5

Text

String text (stored as TEXT). Can be marked as unique or checked with custom validators for length, format, or content. Suitable for names, descriptions, and any arbitrary string data. Supports flexible text storage and searching.

typescript

typescript

1

2

3

4

5

Boolean

Boolean true/false (stored as INTEGER 0/1). Enum is fixed to [false, true], ensuring strict type safety. Perfect for flags, toggles, and any field that represents a binary state. Integrates seamlessly with TypeScript's boolean type.

typescript

typescript

1

2

3

4

5

Time

Date/time (stored as ISO TEXT). Automatically formatted in/out to JavaScript Date objects, making it easy to work with timestamps, creation dates, or scheduling. Ensures consistent date handling and supports default values.

typescript

typescript

1

2

3

4

5

Email

Email string with runtime format validation. Ensures only valid email addresses are stored, and can be set as unique to prevent duplicates. Useful for user accounts, contact fields, and any scenario requiring verified email addresses.

typescript

typescript

1

2

3

4

5

UUID

UUID string (v1–v5) with built-in validation. Uniqueness defaults to true, making it ideal for distributed systems or public identifiers. Guarantees globally unique values for records, supporting both random and time-based UUIDs.

typescript

typescript

1

2

3

4

5

Password

Passwords are automatically hashed and salted for maximum security. OptimaDB handles secure storage and verification transparently, so you never store plain text passwords. Designed for user authentication and sensitive credentials.

typescript

typescript

1

2

3

4

5

Array

Array of values (stored as JSON TEXT). Automatically JSON-serialized/deserialized, allowing you to store lists of items, tags, or any collection of values. Supports flexible and dynamic data structures within a single field.

typescript

typescript

1

2

3

4

5

Json

Arbitrary JSON object (stored as JSON TEXT). Automatically serialized/deserialized, making it easy to store complex, nested data such as user preferences, settings, or metadata. Enables flexible schema design for evolving requirements.

typescript

typescript

1

2

3

4

5