Cette page est affichée en anglais. Une traduction française est en cours.
SkillsApr 12, 2026·3 min de lecture

SurrealDB — Scalable Multi-Model Database for Modern Apps

SurrealDB is a scalable, distributed, collaborative, document-graph database for the real-time web. Combines relational, document, graph, and time-series models in one database with SurrealQL query language. Built in Rust for performance and reliability.

Prêt pour agents

Installation avec revue préalable

Cet actif nécessite une revue. Le prompt copié demande un dry-run, affiche les écritures, puis continue seulement après confirmation.

Needs Confirmation · 64/100Policy : confirmer
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
step-1.md
Commande avec revue préalable
npx -y tokrepo@latest install 9033274f-3649-11f1-9bc6-00163e2b0d79 --target codex

Dry-run d'abord, confirmez les écritures, puis lancez cette commande.

TL;DR
SurrealDB unifies relational, document, graph, and time-series models with SurrealQL.
§01

What it is

SurrealDB is a scalable, multi-model database designed for the real-time web. It combines relational, document, graph, and time-series data models in a single database with its own query language called SurrealQL. You can write SQL-like queries that traverse graphs, filter documents, and aggregate time-series data in one statement.

SurrealDB targets full-stack developers building real-time applications who want to avoid managing separate databases for different data models.

§02

How it saves time or tokens

SurrealDB eliminates the need for a document store, a graph database, and a relational database. One connection string, one query language, one backup process. The built-in permissions system means you can expose SurrealDB directly to the frontend with row-level security, removing the need for a separate backend API for simple CRUD operations.

Real-time subscriptions via WebSocket push data changes to clients without polling.

§03

How to use

  1. Install SurrealDB: curl -sSf https://install.surrealdb.com | sh
  2. Start the server: surreal start --user root --pass root
  3. Connect with the CLI: surreal sql --conn http://localhost:8000 --user root --pass root
  4. Create tables and query with SurrealQL
§04

Example

-- Create a user document
CREATE user:alice SET name = 'Alice', age = 30, role = 'engineer';

-- Create a graph edge
RELATE user:alice->works_at->company:acme SET since = '2024-01-01';

-- Query with graph traversal
SELECT name, ->works_at->company.name AS company
FROM user
WHERE role = 'engineer';

-- Real-time subscription
LIVE SELECT * FROM user WHERE age > 25;
§05

Related on TokRepo

§06

Common pitfalls

  • SurrealDB is younger than PostgreSQL or MongoDB; the ecosystem of drivers and ORM integrations is smaller
  • The direct-to-frontend pattern requires careful permission configuration; misconfigured DEFINE TABLE PERMISSIONS can expose data
  • SurrealQL looks like SQL but has significant differences in syntax for graph traversals and record IDs

Questions fréquentes

How does SurrealDB compare to PostgreSQL?+

PostgreSQL is a mature relational database with extensions for JSON and limited graph queries. SurrealDB is purpose-built for multi-model data with native graph traversals, real-time subscriptions, and document storage. PostgreSQL has a far larger ecosystem; SurrealDB has a more integrated multi-model experience.

Can SurrealDB replace MongoDB?+

For document storage, SurrealDB is a capable alternative. It stores schemaless JSON documents and supports flexible querying. The advantage is that you also get graph and relational capabilities without adding another database. The tradeoff is a smaller ecosystem and fewer managed hosting options.

Does SurrealDB support real-time subscriptions?+

Yes. LIVE SELECT queries push changes to connected clients via WebSocket whenever matching data changes. This enables real-time features like chat, notifications, and collaborative editing without polling.

What languages have SurrealDB drivers?+

Official drivers exist for Rust, JavaScript/TypeScript, Python, Go, Java, and .NET. The JavaScript SDK works in both Node.js and browsers, enabling the direct-to-frontend pattern.

Is SurrealDB production-ready?+

SurrealDB is in active development. It is used in production by some teams, but it is newer than established databases. Evaluate its stability against your requirements and have a fallback plan for critical workloads.

Sources citées (3)

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires