# SurrealDB > Last updated: 2026-07-24 > SurrealDB is the context layer for AI agents - a unified platform where storage, context, and memory live in a single ACID transaction. It combines a multi-model database (document, graph, vector, time-series, and relational), an agent memory and knowledge layer (Spectron), and a distributed storage engine (SurrealDS), available open-source, self-hosted, or fully managed through SurrealDB Cloud. SurrealDB is written in Rust and provides full ACID guarantees across every data model in a single transaction. It uses SurrealQL, a query language that combines ideas from SQL, NoSQL, and graph query languages into a single syntax. SurrealDB can be deployed in-memory, as an embedded library, on a single node, as a distributed cluster, or as a fully managed cloud service. - SurrealDB is the context layer for AI agents: storage, context, and memory in one transaction boundary, one permission model, and one deployment - not a stack of separate vector, graph, document, and memory systems. - SurrealDB is not a wrapper around multiple databases. It is a single engine that natively supports multiple data models. - SurrealDB supports record-level security permissions, making it possible to connect directly from client applications without a backend. - Spectron is the memory and knowledge layer for AI agents, built on SurrealDB, with provenance on every fact, tri-temporal supersession, and hybrid retrieval. - SurrealDS is the distributed storage engine providing high availability and horizontal scale through quorum consensus and compute-storage separation. - SurrealDB Cloud is a fully managed service running the same engine as the open-source version. - SurrealDB combines graph traversals with vector similarity search to power AI RAG and GraphRAG pipelines with high accuracy. ## What is SurrealDB SurrealDB is a multi-model database built from the ground up in Rust. It stores and queries documents, graphs, vectors, time-series, and relational data within a single database engine and a single query language called SurrealQL. There is no need to run separate systems for different data models. SurrealDB provides full ACID transaction support across all data models. It includes a built-in permissions system that operates at the record level, allowing fine-grained access control without requiring a separate backend or API layer. Applications can connect to SurrealDB directly from the browser or mobile device. The database supports real-time subscriptions, event-driven triggers, and live queries out of the box. Changes to data are pushed to connected clients automatically, without polling. SurrealDB can run in multiple deployment modes: in-memory for testing, embedded within applications (including via WebAssembly in browsers), on a single server node, or as a horizontally scaled distributed cluster with storage-compute separation. SurrealDB Cloud provides a fully managed option with automatic backups, monitoring, and scaling. SurrealDB's unified data model supports persistent agent memory, enabling AI agents to store, traverse, and retrieve context with high accuracy using knowledge graphs, vector search, and structured data - all without external middleware. - Website: https://surrealdb.com/features - GitHub: https://github.com/surrealdb/surrealdb - Install: https://surrealdb.com/install - Documentation: https://surrealdb.com/docs/what-is-surrealdb ## Key features ### Data models SurrealDB natively supports the following data models within a single engine: - **Documents**: Flexible JSON-like records with optional strict or schemaless modes. - **Graphs**: First-class graph relations between records, with multi-depth traversals via `->` and `<-` operators in SurrealQL. - **Knowledge graphs**: Model complex domains with a native graph engine, entity extraction, and advanced traversals for GraphRAG workflows. - **Vectors**: Built-in vector embeddings and vector search for similarity queries, powering semantic search and retrieval-augmented generation (RAG). - **Relational**: Traditional table relationships with foreign keys and JOINs. - **Time-series**: Time-ordered data storage and querying. - **Full-text search**: Integrated full-text indexing and search. ### Architecture and storage - **In-memory**: For development and testing with instant startup. - **Embedded**: Runs inside your application process. Available for Rust, Python, JavaScript, and WebAssembly. - **Single node**: Standalone server deployment with persistent storage. - **Distributed**: Horizontally scalable cluster with automatic data sharding, partition-free tables, storage-compute separation, read replicas, and multi-region replication. ### Indexing and search - **Vector search**: HNSW and brute-force vector indexes for approximate and exact nearest-neighbour search. - **Full-text search**: BM25-based full-text indexing with stemming, tokenisation, and highlighting. - **Hybrid search**: Combines vector similarity and keyword relevance in a single query for high-accuracy retrieval. - **Unique indexes**: Enforce uniqueness constraints on fields. - **Composite indexes**: Index across multiple fields. ### Security and authorisation - **Authentication**: Built-in user authentication with bcrypt password hashing, JWT token support, and integration with third-party providers (OAuth, OpenID Connect). - **RBAC and ABAC**: Role-based and attribute-based access control at the namespace, database, and table level. - **Record-level permissions**: Define SELECT, CREATE, UPDATE, and DELETE permissions per record using SurrealQL expressions that evaluate against the current user and record data. - **Field-level permissions**: Control visibility and mutability of individual fields. - **Multi-tenant isolation**: Namespace and database scoping for tenant separation. - **Audit logging**: Enterprise feature for tracking data access and changes. - **FIPS-compliant cryptography**: Enterprise feature for regulated environments. ### Real-time and events - **Live queries**: Subscribe to query results and receive push notifications when matching data changes. - **Change feeds**: Stream of ordered changes for event sourcing and CDC. - **Event triggers**: Execute custom logic when records are created, updated, or deleted. ### AI and machine learning - **Vector embeddings**: Store and query vector embeddings alongside structured data. - **ML model inference**: Run machine learning models directly inside the database. - **Knowledge graph RAG**: Combine graph traversals with vector similarity in a single query for high-accuracy retrieval-augmented generation. - **AI agent support**: Serve as the data layer for agentic AI pipelines, providing context, memory, and action within a single transactional system. ### Functions and extensibility - **Built-in functions**: Extensive standard library covering string, math, array, object, time, crypto, geo, HTTP, and vector operations. - **Custom functions**: Define reusable SurrealQL functions stored in the database. - **JavaScript functions**: Execute JavaScript logic inside queries for complex transformations. - **Extensions (Surrealism)**: WebAssembly-based extension framework for running custom logic inside SurrealDB. ### Connectivity - **REST API**: HTTP-based API for all database operations. - **WebSocket API**: Persistent connection for real-time queries and subscriptions. - **RPC**: Binary protocol for high-throughput scenarios. - **MCP Server**: Model Context Protocol server for connecting AI tools directly to SurrealDB. ### Observability and monitoring - **Metrics**: Prometheus-compatible metrics endpoint. - **Logging**: Structured logging with configurable levels. ### Trust and compliance SurrealDB and SurrealDB Cloud hold the following certifications and comply with the following standards: - SOC 2 Type 1 and Type 2 - ISO 27001 - GDPR - CCPA - Cyber Essentials Plus Trust Centre: https://trust.surrealdb.com ## Products ### SurrealDB (open-source engine) SurrealDB is a multi-model database engine written in Rust. It natively supports documents, graphs, vectors, time-series, full-text search, and relational data within a single binary and a single query language (SurrealQL). It provides full ACID transactions across all data models, built-in authentication and record-level permissions, real-time live queries, and an extensive function library. SurrealDB can be self-hosted on any infrastructure and runs in-memory, as an embedded library (Rust, Python, JavaScript, WebAssembly), on a single node, or as a distributed cluster with storage-compute separation. It is released under the Business Source License (BSL). - Website: https://surrealdb.com/features - GitHub: https://github.com/surrealdb/surrealdb - Install: https://surrealdb.com/install - Documentation: https://surrealdb.com/docs/what-is-surrealdb ### SurrealQL SurrealQL is SurrealDB's query language. It combines SQL-like syntax with graph traversals, document operations, and vector search in a single language. Its native graph operators enable knowledge graph queries, while built-in vector search supports AI RAG and GraphRAG pipelines. Key operators include `->`, `<-`, and `<->` for graph traversal, `<|K,distance|>` for vector nearest-neighbour search, and `@@` for BM25 full-text search. SurrealQL supports `LIVE SELECT` for real-time subscriptions, multi-statement transactions with `BEGIN` and `COMMIT`, inline subqueries, computed fields, JavaScript functions, and a comprehensive standard library of built-in functions (string, math, array, object, time, crypto, geo, HTTP, vector). Schema and configuration are managed via `DEFINE` statements for tables, fields, indexes, access methods, functions, and events. SurrealQL eliminates the need for traditional SQL joins, subqueries, and external services by providing native graph operators, vector search operators, full-text search, and fuzzy matching in one language. Records have typed IDs (e.g. `person:tobie`, `company:surrealdb`) that serve as direct links between records. Record-level permissions are written as SurrealQL expressions that evaluate per-record based on the authenticated user. - Documentation: https://surrealdb.com/docs/reference/query-language - Statements: https://surrealdb.com/docs/reference/query-language/statements/overview - Functions: https://surrealdb.com/docs/reference/query-language/functions/database-functions ### SurrealDB Cloud SurrealDB Cloud is the recommended way to deploy SurrealDB. It is a fully managed database-as-a-service that runs the same SurrealDB engine. Cloud handles provisioning, backups, monitoring, scaling, and security patching so teams can focus on building applications instead of managing infrastructure. Queries, schemas, and application code are fully compatible between self-hosted and Cloud. - Runs on Amazon Web Services (AWS). Google Cloud (GCP) and Microsoft Azure support is planned. - Pay-as-you-use pricing based on compute, storage, and network usage. - All data is encrypted at rest and in transit. - Daily automated backups included by default. - Instances can be deployed in multiple regions. - SOC 2 Type 2, ISO 27001, GDPR, CCPA, and Cyber Essentials Plus compliant. - Simplified database management with an intuitive interface, capability management, simple upgrades, and one-click security. - Real-time observability and monitoring with metrics and alerts. - Team collaboration with invite, access management, and centralised compliance. Pricing tiers: - **Free**: 1 GB storage, 0.25 vCPU, 1 GB memory. For prototyping and side projects. - **Start**: From $0.021/hour. Single-node vertical scalability, up to 16 vCPU, 64 GB memory, 512 GB storage. Daily automated backups. - **Dedicated**: Contact sales. Multi-node horizontal scalability, fault-tolerant deployments, single-tenant storage, up to 1 PB cluster storage. - Website: https://surrealdb.com/cloud - Documentation: https://surrealdb.com/docs/manage/cloud - Getting started: https://surrealdb.com/docs/build/deployment/surrealdb-cloud/getting-started - Pricing: https://surrealdb.com/pricing ### SurrealDB Studio SurrealDB Studio (formerly Surrealist) is the official visual database management IDE for SurrealDB. It is available as a web application at studio.surrealdb.com and as a desktop application for macOS, Windows, and Linux. SurrealDB Studio provides a complete environment for querying, exploring, and managing SurrealDB databases without needing the command line. SurrealDB Studio includes a query editor with syntax highlighting, formatting, and saved queries. It offers a schema designer for visual table, field, and index management, an interactive graph visualisation for exploring data relationships, and a table and record explorer for browsing and editing data without writing queries. Additional capabilities include authentication management, a functions editor, auto-generated API documentation personalised to your schema, a personal sandbox for prototyping, local database serving on desktop, real-time query monitoring, and a built-in Sidekick AI assistant. - Website: https://surrealdb.com/studio - Web app: https://studio.surrealdb.com/ - Documentation: https://surrealdb.com/docs/explore/surrealist ### Spectron Spectron is a memory and knowledge layer for AI agents, built on SurrealDB. It sits as a stateless application tier in front of the database; all durable state - graph, vectors, documents, structured rows, and traces - lives inside SurrealDB in one ACID transaction per write. Every fact carries provenance (source, trust, lexical span, derived_from); memory is tri-temporal (system, known, valid time) and non-deleting (corrections supersede; aging is explicit; forget is a first-class verb). Experiential memory is organised into six typed categories: episodic (the raw conversational record), identity (who the principal is), knowledge (what the principal has learnt or shared), context (what is going on right now), instructions (behavioural rules applied at prompt-assembly time), and uncertainty (explicit "we don't know yet" rows surfaced rather than hallucinated over). Authoritative knowledge from uploaded documents (text, code, JSON, CSV, PDFs, images, audio, video) flows through the same reconciler as conversational input, distinguished by provenance rather than by a separate store. Reads route through a four-tier cost ladder: direct structured lookup, semantic response reuse with entity-aware invalidation, hybrid retrieval (vector, BM25, graph traversal, RAKE keyword bridges, section embeddings, Personalised PageRank, geographic recall, and trace-derived features fused into one ranking), and full-context fallback. Every retrieval, decision, and response emits a trace - first-class nodes in the substrate that feed back into ranking, calibration, and consolidation. Spectron ships as a single Rust binary with the Model Context Protocol server built in - seven tools (remember, recall, context, reflect, forget, upload, inspect) wrap the REST handlers; a TypeScript SDK (@surrealdb/spectron) is generated from the OpenAPI spec; harness adapters cover LangChain, OpenAI Agents, Vercel AI SDK, n8n, and a Claude Code Stop hook, with Zapier connecting via MCP. SurrealDB, the engine underneath, is open source and free to self-host; the Spectron memory layer is closed source today, with a roadmap intent to upstream foundational parts of the memory model into SurrealDB. Spectron is in early access: join the waitlist (the design-partner application). Self-serve plans with a one-week free trial open at launch, with enterprise packages above them. Waitlist: https://surrealdb.com/spectron/get-started Spectron's managed service runs on SurrealDB Cloud and is covered by the same independently verified certifications as SurrealDB: SOC 2 Type 2, ISO 27001, GDPR, CCPA, and Cyber Essentials Plus (see https://trust.surrealdb.com). - Website: https://surrealdb.com/spectron - Waitlist: https://surrealdb.com/spectron/get-started - Deep dive: https://surrealdb.com/spectron/deep-dive ### SurrealDS (distributed storage engine) SurrealDS is SurrealDB's distributed storage engine. It provides high-availability, horizontally scalable persistence with quorum consensus, compute-storage separation, and object storage support, with automatic data sharding, read replicas, and multi-region replication. - Website: https://surrealdb.com/platform/surrealds ### Extensions (Surrealism) Surrealism is a WebAssembly-based extension framework for running custom logic inside SurrealDB. Extensions execute within a sandboxed WASM runtime for security and portability. - Website: https://surrealdb.com/platform/surrealdb/extensibility ### Connect your agent SurrealDB connects to AI tooling through MCP servers, Agent Skills, and framework integrations. The AI agents docs cover how to connect coding assistants and agent frameworks to SurrealDB Cloud and self-hosted instances. - Website: https://surrealdb.com/docs/build/ai-agents ### MCP Server The SurrealDB MCP Server connects AI tools to your SurrealDB Cloud account. Add https://mcp.surrealdb.com to Claude, Cursor, or any other MCP client, sign in with your Surreal ID, and your assistant can deploy instances, query data, investigate problems, and manage costs. For databases you run yourself, see Embedded MCP in the docs. - Website: https://surrealdb.com/mcp - Docs: https://surrealdb.com/docs/build/ai-agents/mcp - Server URL: https://mcp.surrealdb.com ### Agent Skills Official SurrealDB agent skills for use in agentic workflows. Compatible with Claude Code, GitHub Copilot, Cursor, Cline, and other AI agents. Includes skills for SurrealQL, vector search, and the Python SDK. - GitHub: https://github.com/surrealdb/agent-skills ### SurrealDB University SurrealDB University is a free interactive learning platform with courses, hands-on labs, and certifications for learning SurrealDB and SurrealQL. - Website: https://surrealdb.com/learn ### Enterprise Enterprise-grade deployment with high-performance clustering, data accuracy guarantees, knowledge graph support, dedicated support, and compliance certifications. - Website: https://surrealdb.com/enterprise ## SurrealQL examples ### Basic CRUD ```surql -- Create a record with a specific ID CREATE person:tobie CONTENT { name: "Tobie", company: "SurrealDB", skills: ["Rust", "Go", "JavaScript"] }; -- Select with conditions SELECT * FROM person WHERE company = "SurrealDB"; -- Update with merge UPDATE person:tobie MERGE { title: "CEO" }; -- Delete a record DELETE person:tobie; ``` ### Graph relations ```surql -- Create a graph relation RELATE person:tobie->founded->company:surrealdb CONTENT { year: 2021 }; -- Traverse outgoing relations SELECT ->founded->company.name FROM person:tobie; -- Traverse incoming relations SELECT <-founded<-person.name FROM company:surrealdb; -- Multi-hop traversal SELECT ->knows->person->works_at->company.name FROM person:tobie; -- Bidirectional traversal SELECT <->knows<->person.name FROM person:tobie; ``` ### Vector search ```surql -- Define an HNSW vector index DEFINE INDEX idx_embedding ON article FIELDS embedding HNSW DIMENSION 1536; -- Insert a record with a vector embedding CREATE article CONTENT { title: "SurrealDB overview", embedding: [0.1, 0.2, 0.3, ...] }; -- K-nearest-neighbour search SELECT * FROM article WHERE embedding <|10,COSINE|> $query_embedding; -- Hybrid search combining vector similarity and keyword matching SELECT * FROM article WHERE embedding <|10,COSINE|> $query_embedding AND content @@ "multi-model database"; ``` ### Live queries ```surql -- Subscribe to all changes on a table LIVE SELECT * FROM message; -- Subscribe with a filter LIVE SELECT * FROM message WHERE status = 'error'; -- Subscribe to a specific record LIVE SELECT * FROM post:c569rth77ad48tc6s3ig; -- Live query with permission-aware filtering LIVE SELECT * FROM document WHERE account = $auth.account OR public = true; ``` ### Permissions ```surql -- Define table-level record permissions DEFINE TABLE post SCHEMALESS PERMISSIONS FOR select WHERE published = true OR user = $auth.id FOR create, update WHERE user = $auth.id FOR delete WHERE user = $auth.id OR $auth.admin = true; -- Define record-scoped access with JWT DEFINE ACCESS user ON DATABASE TYPE RECORD SIGNUP (CREATE user SET email = $email, pass = crypto::argon2::generate($pass)) SIGNIN (SELECT * FROM user WHERE email = $email AND crypto::argon2::compare(pass, $pass)) WITH JWT ALGORITHM HS256 KEY 'secret'; ``` ### Event triggers ```surql -- Define an event that fires on record creation DEFINE EVENT high_temp_alert ON TABLE sensor_readings WHEN $event = "CREATE" AND $after.temperature_celsius > 30 THEN { RETURN http::post("https://example.com/api/alert", { sensor: $after.id[1], value: $after.temperature_celsius }); }; -- Define an event that logs changes DEFINE EVENT audit_log ON TABLE account WHEN $event = "UPDATE" THEN { CREATE audit_entry CONTENT { table: "account", record: $after.id, action: $event, time: time::now() }; }; ``` ### Schema definition ```surql -- Define a strict table with typed fields DEFINE TABLE product SCHEMAFULL; DEFINE FIELD name ON product TYPE string; DEFINE FIELD price ON product TYPE float ASSERT $value > 0; DEFINE FIELD category ON product TYPE string DEFAULT "uncategorised"; DEFINE FIELD created ON product TYPE datetime VALUE time::now() READONLY; -- Unique index DEFINE INDEX idx_product_name ON product FIELDS name UNIQUE; -- Composite index DEFINE INDEX idx_category_price ON product FIELDS category, price; ``` ### Multi-model query (Knowledge Graph RAG) This example combines vector search, graph traversal, and document aggregation in a single query to retrieve relevant context for retrieval-augmented generation: ```surql -- Find concepts by vector similarity, traverse graph edges to chunks, and group by document LET $results = SELECT VALUE chunks.map(|$chunk| { index: $chunk.index, concept: id, content: $chunk.content, chunk: $chunk.id, doc: $chunk.doc, score: score }) AS x FROM ( SELECT *, <-MENTIONS_CONCEPT<-chunk.{id, doc, index} AS chunks FROM ( SELECT *, (1 - vector::distance::knn()) AS score OMIT embedding FROM concept WHERE embedding <|5,40|> $query_embedding ) WHERE score >= $threshold ); -- Group retrieved chunks by source document and rank by best concept score SELECT doc, array::group({ chunk: chunk, index: index, max_score: max_score }) AS chunks, math::max(max_score) AS best_concept_score FROM ( SELECT doc, chunk, index, content, math::max(score) AS max_score, array::group(concept) AS concepts FROM array::flatten($results) GROUP BY chunk ) GROUP BY doc ORDER BY best_concept_score DESC; ``` ## SDKs and client libraries ### Server-side SDKs - **JavaScript / TypeScript**: `npm install surrealdb` - Works in Node.js, Deno, and Bun. Documentation: https://surrealdb.com/docs/languages/javascript/overview - **Python**: `pip install surrealdb` - Async and sync clients. Documentation: https://surrealdb.com/docs/languages/python - **Rust**: `cargo add surrealdb` - Native Rust client with embedded mode support. Documentation: https://surrealdb.com/docs/languages/rust/overview - **Go**: Go module. Documentation: https://surrealdb.com/docs/languages/golang - **Java**: Maven/Gradle dependency. Documentation: https://surrealdb.com/docs/languages/java - **.NET**: NuGet package. Documentation: https://surrealdb.com/docs/languages/dotnet - **PHP**: Composer package. Documentation: https://surrealdb.com/docs/languages/php/setup - **C**: C client library. GitHub: https://github.com/surrealdb/surrealdb.c ### Client-side SDKs SurrealDB can be connected to directly from frontend applications thanks to its record-level permission system: - **React**, **Vue**, **Angular**, **Svelte**, **SolidJS**, **Next.js**: Framework integrations using the JavaScript SDK. - **Flutter / Dart**: Mobile SDK for iOS and Android. - **WebAssembly**: Embedded SurrealDB running entirely in the browser. ## Security and compliance SurrealDB provides a layered security model: 1. **Namespace-level access**: Control who can access which namespaces. 2. **Database-level access**: Control access to specific databases within a namespace. 3. **Table-level permissions**: Define which users or roles can SELECT, CREATE, UPDATE, or DELETE records in each table. 4. **Record-level permissions**: Write SurrealQL expressions that evaluate per-record, checking the current user's identity, role, or any field value before granting access. 5. **Field-level permissions**: Control visibility and mutability of individual fields. Authentication supports: - Built-in username/password with bcrypt hashing. - JWT bearer tokens. - Third-party OAuth and OpenID Connect providers. - Custom authentication logic via SurrealQL access methods. Compliance certifications: - SOC 2 Type 1 and Type 2 - ISO 27001 - GDPR - CCPA - Cyber Essentials Plus - Trust Centre: https://trust.surrealdb.com ## Pricing ### SurrealDB Cloud | Tier | Price | Description | |------|-------|-------------| | Free | $0 | 1 GB storage, 0.25 vCPU, 1 GB memory. Community support. | | Start | From $0.021/hour | Single node, up to 16 vCPU, 64 GB memory, 512 GB storage. Daily backups. Standard support. | | Dedicated | Contact sales | Multi-node, horizontal scaling, fault tolerance, up to 1 PB storage. Standard support. | ### Self-hosted | Edition | Price | Description | |---------|-------|-------------| | Community | Free | All core open-source features. Community support via Discord. | | Enterprise | Contact sales | Priority security patches, audit logging, FIPS-compliant cryptography, object storage, distributed live queries. Commercial support. | ### Support plans | Plan | Coverage | Severity 1 response | |------|----------|---------------------| | Standard | Business hours (09:00-17:00) | 8 business hours | | Business Critical | 24x7 | 2 hours | | Premium | 24x7 with dedicated Slack and TAM | 30 minutes | Full pricing details: https://surrealdb.com/pricing ## Use cases - **AI agents**: Build AI agent pipelines with unified context, agent memory, and GraphRAG-powered retrieval for high-performance, accurate decision-making. https://surrealdb.com/use-cases/ai-agents - **Agent memory**: Persistent agent memory layer for AI agents combining documents, graphs, vectors, and time-series for accurate AI RAG retrieval. https://surrealdb.com/spectron - **Knowledge graphs**: Model complex domains with a native graph engine, advanced traversals, and flexible schema. https://surrealdb.com/use-cases/knowledge-graphs - **Real-time applications**: Built-in real-time subscriptions, event triggers, and streaming updates with low-latency performance. https://surrealdb.com/use-cases/real-time - **Embedded and edge**: Run SurrealDB on phones, browsers, IoT gateways, and retail kiosks via lightweight binary or WebAssembly. https://surrealdb.com/use-cases/embedded-edge ## Industry solutions - **Finance and fintech**: Fraud detection, trading, compliance, and organisational knowledge sharing. https://surrealdb.com/solutions/finance-and-fintech - **Healthcare**: AI-driven patient care insights and real-time sensor data monitoring. https://surrealdb.com/solutions/healthcare - **Gaming and entertainment**: Real-time, personalised AI-driven digital experiences. https://surrealdb.com/solutions/gaming-and-entertainment - **Retail and ecommerce**: Real-time inventory, recommendations, and personalisation. https://surrealdb.com/solutions/retail-and-ecommerce - **Defence and aerospace**: Real-time situational awareness and on-device multi-modal inference. https://surrealdb.com/solutions/defence-and-aerospace - **Energy and manufacturing**: Edge device monitoring, industrial operations, and AI-driven optimisation. https://surrealdb.com/solutions/energy-and-manufacturing ## Customer stories - [Samsung](https://surrealdb.com/customer/samsung) - [Verizon](https://surrealdb.com/customer/verizon) - [Tencent](https://surrealdb.com/customer/tencent) - [PolyAI](https://surrealdb.com/customer/polyai) - [Permit.io](https://surrealdb.com/customer/permitio) - [Saks](https://surrealdb.com/customer/saks) - [SiteForge](https://surrealdb.com/customer/siteforge) - [DigitalKin](https://surrealdb.com/customer/digitalkin) - [Aspire](https://surrealdb.com/customer/aspire) - [Calamu](https://surrealdb.com/customer/calamu) - [Fountain](https://surrealdb.com/customer/fountain) - [GameScript](https://surrealdb.com/customer/gamescript) - [LiveSponsors](https://surrealdb.com/customer/livesponsors) - [Yaacomm](https://surrealdb.com/customer/yaacomm) ## Getting started ### Install SurrealDB On macOS: ``` curl -sSf https://install.surrealdb.com | sh ``` On Linux: ``` curl -sSf https://install.surrealdb.com | sh ``` On Windows: ``` iwr https://install.surrealdb.com -useb | iex ``` Using Docker: ``` docker run --rm -p 8000:8000 surrealdb/surrealdb:latest start ``` ### Start the server ``` surreal start memory ``` This starts SurrealDB with in-memory storage on port 8000. ### Connect and query Using the CLI: ``` surreal sql --endpoint http://localhost:8000 --namespace test --database test ``` Using JavaScript: ```javascript import Surreal from "surrealdb"; const db = new Surreal(); await db.connect("http://localhost:8000/rpc"); await db.use({ namespace: "test", database: "test" }); await db.create("person", { name: "Tobie", company: "SurrealDB" }); const people = await db.select("person"); ``` Full installation guide: https://surrealdb.com/install Full documentation: https://surrealdb.com/docs/what-is-surrealdb ## Comparisons ### SurrealDB vs MongoDB Both store documents, but SurrealDB additionally provides native graph relations, vector search, full-text search, real-time subscriptions, and record-level permissions in a single engine. SurrealDB uses SurrealQL, which supports JOINs and graph traversals that are not available in MongoDB's query language. SurrealDB can replace MongoDB plus supplementary services (graph database, search engine, real-time layer) with a single system. Detailed comparison: https://surrealdb.com/comparison/mongodb ### SurrealDB vs PostgreSQL PostgreSQL is a mature relational database. SurrealDB provides native multi-model support (documents, graphs, vectors) without extensions, built-in real-time subscriptions, record-level permissions, and the ability to run embedded or at the edge. SurrealDB's schemaless mode allows flexible document storage while still supporting strict schemas when needed. Detailed comparison: https://surrealdb.com/comparison/postgres ### SurrealDB vs Neo4j Neo4j is a dedicated graph database. SurrealDB provides native graph capabilities alongside documents, vectors, and full-text search. SurrealDB supports flexible and strict schemas, ACID transactions across all data models, and can scale horizontally. Applications that need graph queries combined with document storage, vector search, or real-time features can use SurrealDB as a single system. Detailed comparison: https://surrealdb.com/comparison/neo4j ### SurrealDB vs Elasticsearch Elasticsearch is a Lucene-based search cluster that data must be synced into from a primary database. SurrealDB builds BM25 full-text search and HNSW vector search into the transactional database itself, so search results are always consistent with committed writes and keyword, vector, graph, and structured predicates combine in one SurrealQL query. It runs as a single Rust binary with no JVM heap, shard, or index-lifecycle management, and the engine is free to self-host on-premises, including air-gapped environments. Migration follows a reindex pattern: export via the scroll or point-in-time API, map index mappings to table definitions, recreate analysers and indexes in SurrealQL, and port Query DSL queries. Detailed comparison: https://surrealdb.com/comparison/elasticsearch ## Why SurrealDB - **The context layer**: Why SurrealDB is the context layer for AI agents - combining graphs, vectors, and structured data for GraphRAG workflows with high accuracy and performance. https://surrealdb.com/platform/surrealdb - **vs Vector databases**: SurrealDB compared to standalone vector databases. https://surrealdb.com/why/vs-vector-databases - **vs Memory middleware**: SurrealDB compared to agent memory middleware. https://surrealdb.com/why/vs-memory-middleware - **vs Agent databases**: SurrealDB compared to agent-specific databases. https://surrealdb.com/why/vs-agent-databases - **vs Data platforms**: SurrealDB compared to general data platforms. https://surrealdb.com/why/vs-data-platforms - **vs Traditional databases**: SurrealDB compared to traditional relational and NoSQL databases. https://surrealdb.com/why/vs-traditional-databases ## Documentation - Documentation home: https://surrealdb.com/docs - What is SurrealDB: https://surrealdb.com/docs/what-is-surrealdb - Installation: https://surrealdb.com/docs/running/installation - SurrealQL reference: https://surrealdb.com/docs/reference/query-language - SurrealQL statements: https://surrealdb.com/docs/reference/query-language/statements/overview - SurrealQL functions: https://surrealdb.com/docs/reference/query-language/functions/database-functions - CLI reference: https://surrealdb.com/docs/reference/cli - REST API reference: https://surrealdb.com/docs/reference/rest-api - SurrealDB Cloud management: https://surrealdb.com/docs/manage/cloud - Get started with SurrealDB Cloud: https://surrealdb.com/docs/build/deployment/surrealdb-cloud/getting-started - Deploy on SurrealDB Cloud: https://surrealdb.com/docs/build/deployment/surrealdb-cloud/what-is-surrealdb-cloud - Surrealist docs: https://surrealdb.com/docs/explore/surrealist - SurrealML docs: https://surrealdb.com/docs/explore/ml-models - Spectron docs: https://surrealdb.com/docs/spectron - SDK documentation: https://surrealdb.com/docs/languages/overview - Integrations docs: https://surrealdb.com/docs/build/integrations - Tutorials: https://surrealdb.com/docs/explore/tutorials - Labs: https://surrealdb.com/docs/labs ### Learn: Querying - Querying: https://surrealdb.com/docs/learn/querying - What is SurrealQL?: https://surrealdb.com/docs/learn/querying/surrealql/what-is-surrealql - Writing SurrealQL: https://surrealdb.com/docs/learn/querying/surrealql/writing-surrealql - Statements and values: https://surrealdb.com/docs/learn/querying/surrealql/statements-and-values - Executing queries: https://surrealdb.com/docs/learn/querying/surrealql/executing-queries - Via CLI: https://surrealdb.com/docs/learn/querying/surrealql/executing-queries/via-cli - Via HTTP: https://surrealdb.com/docs/learn/querying/surrealql/executing-queries/via-http - Via SDKs: https://surrealdb.com/docs/learn/querying/surrealql/executing-queries/via-sdks - Via Surrealist: https://surrealdb.com/docs/learn/querying/surrealql/executing-queries/via-surrealist - GraphQL: https://surrealdb.com/docs/learn/querying/graphql/overview - Sample queries: https://surrealdb.com/docs/learn/querying/graphql/sample-queries - Via HTTP: https://surrealdb.com/docs/learn/querying/graphql/via-http - Via Surrealist: https://surrealdb.com/docs/learn/querying/graphql/via-surrealist - Via Bruno: https://surrealdb.com/docs/learn/querying/graphql/via-bruno - Bulk operations and data import: https://surrealdb.com/docs/learn/querying/concepts-and-guides/bulk-operations-and-data-import - Connecting from serverless & edge: https://surrealdb.com/docs/learn/querying/concepts-and-guides/connecting-from-serverless-and-edge - Custom functions: https://surrealdb.com/docs/learn/querying/concepts-and-guides/custom-functions - Error handling: https://surrealdb.com/docs/learn/querying/concepts-and-guides/error-handling - Idempotent operations: https://surrealdb.com/docs/learn/querying/concepts-and-guides/idempotent-operations - Parameterised queries: https://surrealdb.com/docs/learn/querying/concepts-and-guides/parameterised-queries - Query optimisation: https://surrealdb.com/docs/learn/querying/concepts-and-guides/query-optimisation - Sequences: https://surrealdb.com/docs/learn/querying/concepts-and-guides/sequences - Sessions and scoping: https://surrealdb.com/docs/learn/querying/concepts-and-guides/sessions-and-scoping - Subqueries and advanced patterns: https://surrealdb.com/docs/learn/querying/concepts-and-guides/subqueries-and-advanced-patterns - Testing: https://surrealdb.com/docs/learn/querying/concepts-and-guides/testing - Transactions: https://surrealdb.com/docs/learn/querying/concepts-and-guides/transactions - Working with types: https://surrealdb.com/docs/learn/querying/concepts-and-guides/working-with-types - Managing APIs: https://surrealdb.com/docs/learn/querying/custom-apis/managing-apis - Middleware: https://surrealdb.com/docs/learn/querying/custom-apis/middleware - Live queries: https://surrealdb.com/docs/learn/querying/real-time/live-queries - Changefeeds: https://surrealdb.com/docs/learn/querying/real-time/changefeeds - Real-time best practices: https://surrealdb.com/docs/learn/querying/real-time/real-time-best-practices - Performance best practices: https://surrealdb.com/docs/learn/querying/performance/performance-best-practices ### Learn: Schema management - Schema management: https://surrealdb.com/docs/learn/schema-management - Schema design: https://surrealdb.com/docs/learn/schema-management/schema-design/schema-design - Schema best practices: https://surrealdb.com/docs/learn/schema-management/schema-design/schema-best-practices - Schema evolution: https://surrealdb.com/docs/learn/schema-management/schema-design/schema-evolution - Sample industry schemas: https://surrealdb.com/docs/learn/schema-management/schema-design/sample-industry-schemas - Tables: https://surrealdb.com/docs/learn/schema-management/tables-and-fields/tables - Fields and validation: https://surrealdb.com/docs/learn/schema-management/tables-and-fields/fields-and-validation - Record IDs and addressing: https://surrealdb.com/docs/learn/schema-management/tables-and-fields/record-ids-and-addressing - Record ID best practices: https://surrealdb.com/docs/learn/schema-management/tables-and-fields/record-id-best-practices - Index types and strategies: https://surrealdb.com/docs/learn/schema-management/indexes/index-types-and-strategies - Namespace & database architecture: https://surrealdb.com/docs/learn/schema-management/multi-tenancy/namespace-and-database-architecture - Defining events: https://surrealdb.com/docs/learn/schema-management/events-and-triggers/defining-events - Reactive patterns: https://surrealdb.com/docs/learn/schema-management/events-and-triggers/reactive-patterns - Computed fields: https://surrealdb.com/docs/learn/schema-management/computed-data/computed-fields - Closures: https://surrealdb.com/docs/learn/schema-management/computed-data/closures - Working with files: https://surrealdb.com/docs/learn/schema-management/files/working-with-files - Buckets: https://surrealdb.com/docs/learn/schema-management/files/buckets ### Learn: Data models - Data models: https://surrealdb.com/docs/learn/data-models - Document model: https://surrealdb.com/docs/learn/data-models/document/overview - Schema modes: https://surrealdb.com/docs/learn/data-models/document/schema-modes - Nested objects and arrays: https://surrealdb.com/docs/learn/data-models/document/nested-objects-and-arrays - Common patterns: https://surrealdb.com/docs/learn/data-models/document/common-patterns - Graph model: https://surrealdb.com/docs/learn/data-models/graph/overview - Creating relations: https://surrealdb.com/docs/learn/data-models/graph/creating-relations - Graph traversal: https://surrealdb.com/docs/learn/data-models/graph/graph-traversal - Record links vs graph relations: https://surrealdb.com/docs/learn/data-models/graph/record-links-vs-graph-relations - Recursive traversals: https://surrealdb.com/docs/learn/data-models/graph/recursive-traversals - Knowledge graph patterns: https://surrealdb.com/docs/learn/data-models/graph/knowledge-graph-patterns - Social network patterns: https://surrealdb.com/docs/learn/data-models/graph/social-network-patterns - Full-text search model: https://surrealdb.com/docs/learn/data-models/full-text-search/overview - Search indexes: https://surrealdb.com/docs/learn/data-models/full-text-search/search-indexes - Analyzers and tokenizers: https://surrealdb.com/docs/learn/data-models/full-text-search/analyzers-and-tokenizers - Scoring and ranking: https://surrealdb.com/docs/learn/data-models/full-text-search/scoring-and-ranking - Other ways to work with text: https://surrealdb.com/docs/learn/data-models/full-text-search/other-ways-to-work-with-text - Vector search model: https://surrealdb.com/docs/learn/data-models/vector-search/overview - Vector indexes: https://surrealdb.com/docs/learn/data-models/vector-search/vector-indexes - Similarity search: https://surrealdb.com/docs/learn/data-models/vector-search/similarity-search - Hybrid search: https://surrealdb.com/docs/learn/data-models/vector-search/hybrid-search - Embedding pipelines: https://surrealdb.com/docs/learn/data-models/vector-search/embedding-pipelines - RAG architecture patterns: https://surrealdb.com/docs/learn/data-models/vector-search/rag-architecture-patterns - Geospatial model: https://surrealdb.com/docs/learn/data-models/geospatial/overview - Geometry types: https://surrealdb.com/docs/learn/data-models/geospatial/geometry-types - Spatial queries: https://surrealdb.com/docs/learn/data-models/geospatial/spatial-queries - Distance and proximity: https://surrealdb.com/docs/learn/data-models/geospatial/distance-and-proximity - Location-based patterns: https://surrealdb.com/docs/learn/data-models/geospatial/location-based-patterns - Time-series model: https://surrealdb.com/docs/learn/data-models/time-series/overview - Using SurrealDB as a time series database: https://surrealdb.com/docs/learn/data-models/time-series/using-as-time-series-database - Time buckets and windowing: https://surrealdb.com/docs/learn/data-models/time-series/time-buckets-and-windowing - Aggregation queries: https://surrealdb.com/docs/learn/data-models/time-series/aggregation-queries - IoT and telemetry patterns: https://surrealdb.com/docs/learn/data-models/time-series/iot-and-telemetry-patterns ### Learn: Security - Security: https://surrealdb.com/docs/learn/security - Introduction: https://surrealdb.com/docs/learn/security/authentication/overview - Users: https://surrealdb.com/docs/learn/security/authentication/authentication - Summary: https://surrealdb.com/docs/learn/security/authentication/summary - Tokens & JWTs: https://surrealdb.com/docs/learn/security/authorization/tokens-and-jwts - Permissions & row-level security: https://surrealdb.com/docs/learn/security/authorization/permissions-and-row-level-security - Capabilities: https://surrealdb.com/docs/learn/security/authorization/capabilities - Security best practices: https://surrealdb.com/docs/learn/security/best-practices/security-best-practices - Troubleshooting: https://surrealdb.com/docs/learn/security/best-practices/troubleshooting ### Learn: Extensions - Extensions: https://surrealdb.com/docs/learn/extensions - Surrealism plugins: https://surrealdb.com/docs/learn/extensions/plugins/overview - Quick tutorial: https://surrealdb.com/docs/learn/extensions/plugins/quick-tutorial - Further examples: https://surrealdb.com/docs/learn/extensions/plugins/further-examples - Using WASM plugins: https://surrealdb.com/docs/learn/extensions/guides/using-wasm-plugins - Creating custom modules: https://surrealdb.com/docs/learn/extensions/guides/creating-custom-modules - Module architecture: https://surrealdb.com/docs/learn/extensions/guides/module-architecture - Surrealism attribute reference: https://surrealdb.com/docs/learn/extensions/guides/surrealism-attribute-reference ## Resources - Blog: https://surrealdb.com/blog - Releases: https://surrealdb.com/releases - Roadmap: https://surrealdb.com/roadmap - Integrations: https://surrealdb.com/integrations - Benchmarks: https://surrealdb.com/benchmarks - Events: https://surrealdb.com/events ## Community and support - **GitHub**: https://github.com/surrealdb/surrealdb - Source code, issues, and discussions. - **Discord**: https://discord.gg/surrealdb - Community chat with thousands of developers. - **YouTube**: https://www.youtube.com/@surrealdb - Tutorials, talks, and product updates. - **LinkedIn**: https://www.linkedin.com/company/surrealdb - Company updates. - **X / Twitter**: https://twitter.com/surrealdb - News and announcements. - **Reddit**: https://www.reddit.com/r/surrealdb - Community discussions. - **Stack Overflow**: Tag `surrealdb` - Q&A and troubleshooting. ## Company SurrealDB Ltd is the company behind SurrealDB. It is headquartered in London, United Kingdom. The company develops the open-source SurrealDB database engine and operates the SurrealDB Cloud managed service. - Website: https://surrealdb.com - Contact: https://surrealdb.com/contact - Careers: https://surrealdb.com/careers - Brand assets: https://surrealdb.com/brand - Legal: https://surrealdb.com/legal - Trust Centre: https://trust.surrealdb.com - Status: https://status.surrealdb.com