Skip to content

Data Types

OstrichDB supports a rich set of data types for storing various kinds of information. Each record must specify a type when created, and the database enforces type consistency.

Text data stored as UTF-8 encoded strings.

Usage:

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/name?type=STRING&value=John Doe"

JSON representation:

{
"name": "name",
"type": "STRING",
"value": "John Doe"
}

64-bit signed integers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

Usage:

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/age?type=INTEGER&value=42"

JSON representation:

{
"name": "age",
"type": "INTEGER",
"value": 42
}

64-bit floating-point numbers (IEEE 754 double precision).

Usage:

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/price?type=FLOAT&value=19.99"

JSON representation:

{
"name": "price",
"type": "FLOAT",
"value": 19.99
}

True or false values.

Usage:

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/active?type=BOOLEAN&value=true"

JSON representation:

{
"name": "active",
"type": "BOOLEAN",
"value": true
}

Date values in YYYY-MM-DD format.

Usage:

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/birth_date?type=DATE&value=1990-05-15"

JSON representation:

{
"name": "birth_date",
"type": "DATE",
"value": "1990-05-15"
}

Time values in HH:MM:SS format (24-hour).

Usage:

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/meeting_time?type=TIME&value=14:30:00"

JSON representation:

{
"name": "meeting_time",
"type": "TIME",
"value": "14:30:00"
}

Combined date and time in ISO 8601 format.

Usage:

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/created_at?type=DATETIME&value=2024-01-15T10:30:00Z"

JSON representation:

{
"name": "created_at",
"type": "DATETIME",
"value": "2024-01-15T10:30:00Z"
}

Universally Unique Identifiers in standard UUID format.

Usage:

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/session_id?type=UUID&value=550e8400-e29b-41d4-a716-446655440000"

JSON representation:

{
"name": "session_id",
"type": "UUID",
"value": "550e8400-e29b-41d4-a716-446655440000"
}

Represents null or empty values.

Usage:

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/optional_field?type=NULL&value=null"

JSON representation:

{
"name": "optional_field",
"type": "NULL",
"value": null
}

Encrypted credential storage for sensitive data like passwords or API keys.

Usage:

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/api_key?type=CREDENTIAL&value=secret-api-key"

JSON representation:

{
"name": "api_key",
"type": "CREDENTIAL",
"value": "[ENCRYPTED]"
}

All basic types can be stored as arrays by prefixing with [].

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/tags?type=[]STRING&value=[\"admin\",\"user\",\"active\"]"
Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/scores?type=[]INTEGER&value=[85,92,78,96]"
Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/prices?type=[]FLOAT&value=[19.99,24.50,12.75]"
Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/permissions?type=[]BOOLEAN&value=[true,false,true]"
Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/important_dates?type=[]DATE&value=[\"2024-01-01\",\"2024-06-15\",\"2024-12-31\"]"
Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/schedule?type=[]TIME&value=[\"09:00:00\",\"13:00:00\",\"17:00:00\"]"
Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/events?type=[]DATETIME&value=[\"2024-01-15T10:00:00Z\",\"2024-01-15T14:00:00Z\"]"
Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/session_ids?type=[]UUID&value=[\"550e8400-e29b-41d4-a716-446655440000\",\"6ba7b810-9dad-11d1-80b4-00c04fd430c8\"]"

OstrichDB automatically validates data types when creating or updating records:

  • Format validation: Ensures data matches expected format
  • Range validation: Checks numeric values are within valid ranges
  • Structure validation: Validates array structures and nested data

Valid date:

Terminal window
# ✅ Correct format
curl -X POST "...?type=DATE&value=2024-01-15"

Invalid date:

Terminal window
# ❌ Invalid format
curl -X POST "...?type=DATE&value=01/15/2024"
# Returns validation error

Valid array:

Terminal window
# ✅ Proper JSON array
curl -X POST "...?type=[]STRING&value=[\"item1\",\"item2\"]"

Invalid array:

Terminal window
# ❌ Not a JSON array
curl -X POST "...?type=[]STRING&value=item1,item2"
# Returns validation error

Some types allow automatic conversion:

  • String to Number: “42” → 42 (for INTEGER/FLOAT types)
  • Number to String: 42 → “42” (for STRING type)
  • Boolean conversion: “true”/“false” → true/false

Always specify the intended type explicitly to avoid ambiguity:

Terminal window
# Store as string
curl -X POST "...?type=STRING&value=42"
# Store as integer
curl -X POST "...?type=INTEGER&value=42"

Create arrays using JSON array syntax:

Terminal window
curl -X POST "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/items?type=[]STRING&value=[\"apple\",\"banana\",\"orange\"]"

Update arrays by replacing the entire array:

Terminal window
curl -X PUT "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records/items?value=[\"apple\",\"banana\",\"grape\"]"

Search for records containing specific array elements:

Terminal window
curl "http://localhost:8042/api/v1/projects/demo/collections/test/clusters/data/records?valueContains=apple"
  • Use STRING for text data and identifiers
  • Use INTEGER for whole numbers and counts
  • Use FLOAT for decimal numbers and measurements
  • Use BOOLEAN for true/false flags
  • Use DATE/TIME/DATETIME for temporal data
  • Use UUID for unique identifiers
  • Use CREDENTIAL for sensitive data
  • Use arrays for lists of homogeneous data
  • Be consistent with type usage across similar records
  • Use the same type for the same kind of data
  • Document your type choices for team members
  • Choose the most specific type possible
  • Use INTEGER instead of STRING for numeric data
  • Use DATE instead of STRING for date data
  • Consider array types for related list data
  • Use CREDENTIAL type for sensitive data
  • Ensure encrypted collections for confidential information
  • Validate data types to prevent injection attacks
TypeDescriptionExample Value
STRINGText data”Hello World”
INTEGERWhole numbers42
FLOATDecimal numbers3.14159
BOOLEANTrue/falsetrue
DATEDate only”2024-01-15”
TIMETime only”14:30:00”
DATETIMEDate and time”2024-01-15T14:30:00Z”
UUIDUnique identifier”550e8400-e29b-41d4-a716-446655440000”
NULLNull valuenull
CREDENTIALEncrypted data”[ENCRYPTED]”
[]TYPEArray of type[“item1”, “item2”]