Function Signature
Parameters
The Orama database instance to serialize.
Return Value
A serialized representation of the entire database state that can be stored, transmitted, or loaded into another Orama instance.
Examples
Basic Usage
Saving to File
Saving and Loading for Persistence
Periodic Snapshots
Transferring Between Environments
Saving with Vector Indexes
Conditional Saving
Important Notes
- The returned
RawDataobject is a plain JavaScript object and can be serialized to JSON - Schema information is not included in the saved data - you must recreate the database with the same schema when loading
- All plugin state is not serialized - plugins must be re-initialized when loading
- The save operation is synchronous and creates a complete snapshot
- Vector indexes and all associated data structures are included in the serialization
- The language setting is preserved and will override the language specified during
load()
Related Functions
Performance Considerations
- The
save()operation is synchronous and may take time for large databases - Memory usage spikes during serialization as the entire state is duplicated
- Consider compressing the serialized data for storage or transmission
- For very large databases, consider partial snapshots or incremental backups
- The serialized size is proportional to the number of documents and index complexity
Serialization Format
The returned data structure is opaque and should be treated as a black box. The internal format may change between Orama versions, so:- Always use the same version of Orama for saving and loading
- Test compatibility when upgrading Orama versions
- Consider versioning your saved data for migration purposes