Tostore
Fast distributed AI vector database and persistent local storage engine. High-performance key-value store supporting SQL, NoSQL, offline cache and encrypted data.
Install / Use
/learn @tocreator/TostoreREADME
Quick Navigation
- Why ToStore? | Features | Installation | Quick Start
- Schema Definition | Mobile/Desktop Integration | Server-side Integration
- Vectors & ANN Search | Table-level TTL | Query & Pagination | Foreign Keys | Query Operators
- Distributed Architecture | Primary Keys | Atomic Expressions | Transactions | Error Handling | Log Callback and Database Diagnostics
- Security Config | Performance | More Resources
<a id="why-tostore"></a>
Why Choose ToStore?
ToStore is a modern data engine designed for the AGI era and edge intelligence scenarios. It natively supports distributed systems, multi-modal fusion, relational structured data, high-dimensional vectors, and unstructured data storage. Based on a neural-network-like underlying architecture, nodes possess high autonomy and elastic horizontal scalability, building a flexible data topology network for seamless edge-cloud cross-platform collaboration. It features ACID transactions, complex relational queries (JOIN, cascading foreign keys), table-level TTL, and aggregate computations. It includes multiple distributed primary key algorithms, atomic expressions, schema change identification, encryption protection, multi-space data isolation, resource-aware intelligent load scheduling, and disaster/crash self-healing recovery.
As computing continues to shift toward edge intelligence, various terminals such as agents and sensors are no longer mere "content displays" but intelligent nodes responsible for local generation, environmental perception, real-time decision-making, and data collaboration. Traditional database solutions, limited by their underlying architecture and "plug-in" extensions, struggle to meet the low-latency and stability requirements of edge-cloud intelligent applications when facing high-concurrency writes, massive data, vector retrieval, and collaborative generation.
ToStore empowers the edge with distributed capabilities sufficient to support massive data, complex local AI generation, and large-scale data flow. Deep intelligent collaboration between edge and cloud nodes provides a reliable data foundation for scenarios such as immersive AR/VR fusion, multi-modal interaction, semantic vectors, and spatial modeling.
<a id="key-features"></a>
Key Features
-
🌐 Unified Cross-Platform Data Engine
- Unified API for Mobile, Desktop, Web, and Server.
- Supports relational structured data, high-dimensional vectors, and unstructured data storage.
- Ideal for data lifecycles from local storage to edge-cloud collaboration.
-
🧠 Neural-Network-Like Distributed Architecture
- High node autonomy; interconnected collaboration builds flexible data topologies.
- Supports node collaboration and elastic horizontal scalability.
- Deep interconnection between edge intelligent nodes and the cloud.
-
⚡ Parallel Execution & Resource Scheduling
- Resource-aware intelligent load scheduling with high availability.
- Multi-node parallel collaborative computing and task decomposition.
-
🔍 Structured Query & Vector Retrieval
- Supports complex condition queries, JOINs, aggregate computations, and table-level TTL.
- Supports vector fields, vector indexes, and Approximate Nearest Neighbor (ANN) search.
- Structured and vector data can be used collaboratively within the same engine.
-
🔑 Primary Keys, Indexing & Schema Evolution
- Built-in Sequential Increment, Timestamp, Date-Prefix, and Short Code PK algorithms.
- Supports unique indexes, composite indexes, vector indexes, and foreign key constraints.
- Intelligently identifies schema changes and automates data migration.
-
🛡️ Transactions, Security & Recovery
- Provides ACID transactions, atomic expression updates, and cascading foreign keys.
- Supports crash recovery, persistent flush, and data consistency guarantees.
- Supports ChaCha20-Poly1305 and AES-256-GCM encryption.
-
🔄 Multi-Space & Data Workflow
- Supports data isolation via Spaces with configurable global sharing.
- Real-time query listeners, multi-level intelligent caching, and cursor pagination.
- Perfect for multi-user, local-first, and offline-collaborative applications.
<a id="installation"></a>
Installation
[!IMPORTANT] Upgrading from v2.x? Please read the v3.x Upgrade Guide for critical migration steps and breaking changes.
Add tostore as a dependency in your pubspec.yaml:
dependencies:
tostore: any # Please use the latest version
<a id="quick-start"></a>
Quick Start
[!IMPORTANT] Defining table schema is the first step: You must define the table schema before performing CRUD operations (unless using only KV storage). The specific definition method depends on your scenario:
- See Schema Definition for details on definitions and constraints.
- Mobile/Desktop: Pass
schemaswhen initializing the instance; see Frequent Startup Integration.- Server-side: Use
createTablesat runtime; see Server-side Integration.
// 1. Initialize the database
final db = await ToStore.open();
// 2. Insert data
await db.insert('users', {
'username': 'John',
'email': 'john@example.com',
'age': 25,
});
// 3. Chained queries (see [Query Operators](#query-operators); supports =, !=, >, <, LIKE, IN, etc.)
final users = await db.query('users')
.where('age', '>', 20)
.where('username', 'like', '%John%')
.orderByDesc('age')
.limit(20);
// 4. Update and Delete
await db.update('users', {'age': 26}).where('username', '=', 'John');
await db.delete('users').where('username', '=', 'John');
// 5. Real-time Listening (UI updates automatically when data changes)
db.query('users').where('age', '>', 18).watch().listen((users) {
print('Matching users updated: $users');
});
Key-Value Storage (KV)
Suitable for scenarios that do not require structured tables. Simple and practical, featuring a built-in high-performance KV store for configuration, status, and other scattered data. Data in different Spaces is isolated by default but can be set for global sharing.
// Initialize the database
final db = await ToStore.open();
// Set key-value pairs (supports String, int, bool, double, Map, List, etc.)
await db.setValue('theme', 'dark');
await db.setValue('login_attempts', 3);
// Get data
final theme = await db.getValue('theme'); // 'dark'
// Remove data
await db.removeValue('theme');
// Global key-value (shared across Spaces)
// Default KV data becomes inactive after switching spaces. Use isGlobal: true for global sharing.
await db.setValue('app_version', '1.0.0', isGlobal: true);
final version = await db.getValue('app_version', isGlobal: true);
<a id="schema-definition"></a>
Schema Definition
The following mobile and server-side examples reuse appSchemas defined here.
TableSchema Overview
const userSchema = TableSchema(
name: 'users', // Table name, required
tableId: 'users', // Unique identifier, optional; used for 100% accurate rename detection
primaryKeyConfig: PrimaryKeyConfig(
name: 'id', // PK field name, defaults to 'id'
type: PrimaryKeyType.sequential, // Auto-generation type
sequentialConfig: SequentialIdConfig(
initialValue: 1000, // Starting value
increment: 1, // Step size
useRandomIncrement: false, // Whether to use random increments
),
),
fields: [
FieldSchema(
name: 'username', // Field name, required
type: DataType.text, // Data type, required
nullable: false, // Whether null is allowed
minLength: 3, // Min length
maxLength: 32, // Max length
unique: true, // Unique constraint
fieldId: 'username', // Field unique identifier, optional; for identify renames
comment: 'Login name', // Optional comment
),
FieldSchema(
Related Skills
oracle
339.5kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
prose
339.5kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
Command Development
83.9kThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
Plugin Structure
83.9kThis skill should be used when the user asks to "create a plugin", "scaffold a plugin", "understand plugin structure", "organize plugin components", "set up plugin.json", "use ${CLAUDE_PLUGIN_ROOT}", "add commands/agents/skills/hooks", "configure auto-discovery", or needs guidance on plugin directory layout, manifest configuration, component organization, file naming conventions, or Claude Code plugin architecture best practices.
