Skip to main content

Data Types

Cocobase supports all standard JSON data types plus additional type conversion utilities for strongly-typed applications.

Primitive Types

String

Text data of any length.

Number

Integers and floating-point numbers.
Numbers are stored as IEEE 754 double-precision floating-point. Maximum safe integer: 2^53 - 1 (9,007,199,254,740,991)

Boolean

True or false values.

Null

Represents absence of a value.

Complex Types

Object

Nested JSON objects for structured data.
Nesting limit: 100 levels deep

Array

Ordered collections of any type.
Maximum length: 100,000 elements

Date and Time

Dates are stored as ISO 8601 strings.

Type Conversion (Flutter/Dart)

Flutter SDK provides type converters for type-safe operations.

Defining Converters

Registering Converters

TypeScript Type Definitions

Define interfaces for compile-time type safety:

Special Data Types

File References

Store file URLs or references to uploaded files:
See File Storage for details.

Document References

Store references to other documents:
Use population to fetch referenced documents.

Geolocation

Store coordinates as nested objects:
Query with range filters:

Type Validation

While Cocobase is schema-less, you can implement validation in your application:

Using Zod

Type Coercion

Cocobase automatically handles some type conversions:
Automatic coercion is not guaranteed. Always store data in the correct type to avoid unexpected behavior.

Best Practices

Keep field types consistent across documents:
Always use ISO 8601 format for dates:
Use arrays when order matters, objects when it doesn’t:
Always define interfaces for your data models:

Type Limits

Next Steps

Collections

Learn about organizing data in collections

Flutter SDK

Type-safe Flutter development

CRUD Operations

Work with your typed data

Relationships

Connect documents with references