
In-memory
SurrealDB can run in-memory, enabling high performance with the same transactional and multi-model features. This is suitable for caching data or testing locally.
Embedded
Run SurrealDB embedded within your application, executing directly inside Python and JavaScript runtimes, with WebAssembly, on mobile devices, at the edge, or within the browser.
Single node
SurrealDB supports single-node deployments with persistent on-disk storage, making it suitable for development, edge, or smaller production workloads.
Distributed
Run on a distributed storage architecture. Separation of compute and storage enables horizontally scaling compute nodes for read and write concurrency, and storage nodes for multi TBs datasets and high availability.
Multi-tenancy data separation
Split data into namespaces and databases. There is no limit to the number of databases under each namespace, with the ability to switch between databases inside queries and transactions.
Schemafull or schemaless
Store unstructured nested data with any columns, or limit data stored to only specific columns or fields. Get started quickly without having to define every column, and move to schemafull when your data model is defined.
Multi-table, multi-row transactions
As a fully ACID compliant database, SurrealDB allows you to run transactions across multiple-rows, and across multiple different tables. There is no limit to the length of time a transaction can run.
Versioned temporal tables
Versioned temporal tables enable the option to 'go back in time' when querying your data. See how data looked before changes were made, or restore to a particular point-in-time.
Table fields
When a table is defined as schemafull, only data allowed by defined fields will be stored. Table fields can be nested, and can be limited to a certain data type. VALUE clauses can be used to ensure a default value is always specified if no data is entered.
Table events
Table events can be triggered after any change or modification to the data in a record. Each trigger is able to see the $before and $after value of the record, enabling advanced custom logic with each trigger.
Table indexes
Table indexes improve data querying performance, and also allow for UNIQUE values in a table. Table indexes can be specified for a column, multiple columns, and have support for all nested fields including arrays and objects.
Table constraints
Each defined table field supports an ASSERT clause which acts as a constraint on the data. This clause enables advanced SurrealQL statements which can ensure that the $value entered is within certain parameters. Each clause is also able to see the $before and $after value of the record, enabling advanced custom logic with each trigger.
Full text indexing and filtering
The ability to define full-text indexes, with functionality to search through the full-text index on a table. Searches support field queries, configurable text analyzers, relevance matching, highlighting with offsets extraction.
Vector embedding indexing
Indexing of vector embeddings, with support for euclidean distance metrics. Vector embeddings can be used for similarity matching, and for advanced data analysis.
Aggregate analytics views
Aggregate views let you pre-compute analytics queries as data is written to SurrealDB. Similarly to an index, a table view lets you select, aggregate, group, and order data, with support for moving averages, time-based windowing, and attribute-based counting.
Live queries and record changes
Live SQL queries allow for advanced filtering of the changes to specific documents, documents which match a particular filter, or all documents in a specific table. Live SQL queries can send the fully-updated document, or only the document changesets.
Global parameters
Global parameters can be used to store values across the database, which are then accessible to all queries.
Basic types
Support for booleans, strings, and numerics is built in by default. Numeric values default to decimal based numbers, but can be stored as int or float values for 64 bit integer or 64 bit floating point precision.
Empty values
Values can be NONE, or NULL. A field which is NONE does not have any data stored, while NULL values are values which are entered but empty.
Arrays
SurrealDB has native support for arrays, with no limit to the depth of nesting within arrays. Arrays can contain any other data value.
Objects
Embedded object types are an integral feature of SurrealDB, with no limit to the depth of nesting for objects.
Durations
Any duration from nanoseconds to weeks can be stored and used for calculations. Durations can be added to datetimes, and to other durations.
Datetimes
Support for dates and datetimes in ISO-8601 format are supported. All dates are converted and stored in the UTC timezone.
Geometries
SurrealDB makes working with GeoJSON easy, with support for Point, Line, Polygon, MultiPoint, MultiLine, MultiPolygon, and Collection values. SurrealQL automatically detects GeoJSON objects converting them into a single data type.
Futures
Values which should be computed only when outputting data, can be stored as futures. These values are stored in SurrealDB as SurrealQL code, and are calculated only when output as part of a SELECT clause.
Casting
In SurrealDB, all data values are strongly typed. Values can be cast and converted to other types using specific casting operators. These include bool, int, float, string, number, decimal, datetime, and duration casts.
Strict typing
With a strict typing system, SurrealQL ensures that document structures are easier to understand, and any data conforms to the defined record schema. Advanced types for arrays and record links, ensure that related data works in the same way as basic types.
SELECT, CREATE, UPDATE, DELETE statements
Manipulation and querying of data in SurrealQL is done using the SELECT, CREATE, UPDATE, and DELETE methods. These enable selecting or modifying individual records, or whole tables. Each statement supports multiple different tables or record types at once.
RELATE statements
The RELATE statement adds graph edges between records in SurrealDB. It follows the convention of vertex -> edge -> vertex or noun -> verb -> noun, enabling the addition of metadata to the edge record.
INSERT statements
The INSERT statement resembles the traditional SQL statement, enabling users to get started quickly. It supports the creation of records using a VALUES clause, or by specifying the record data as an object.
FOR statements
FOR statements enable simplified iteration over data, or for advanced logic when dealing with nested arrays or recursive functions, within code blocks or custom functions.
THROW statements
The THROW statement can be used to return custom error types, which allow for building advanced programming and business logic right within the database and authentication engine.
Parameters
Parameters can be used to store values or result sets, and can be used as stored parameters in client code.
Subqueries
Recursive subqueries are useful for advanced querying or modification of values, whilst simplifying the overall query.
Nested field queries
In SurrealQL any nested array or object value can be accessed and manipulated using traditional dot notation, or array notation.
Maths operators
Maths operators can be used to perform complex mathematical calculations directly in SurrealQL.
Geo operators
Geospatial operators enable geospatial containment and intersection operators on geospatial types.
Set operators
Advanced set operators can be used to detect whether one or multiple values are included within an array. Fuzzy matching and regex matching can also be used for advanced filtering.
Maths constants
SurrealQL has a number of built-in constants for advanced mathematical expressions and calculations, including math::E, math::PI, math::TAU, and more.
Expressions
SurrealQL supports fetching data using dot notation, array notation, and graph semantics. SurrealQL enables records to link to other records and traverses all embedded links or graph connections as desired. When traversing and fetching remote records SurrealQL enables advanced filtering using traditional WHERE clauses.
Complex Record IDs
SurrealDB supports the ability to define complex record IDs using arrays. These values sort correctly, and can be used to store values or recordings in a timeseries context.
Record ID ranges
SurrealDB supports the ability to query a range of records, using the record ID. The record ID ranges, retrieve records using the natural sorting order of the record IDs. These range queries can be used to query a range of records in a timeseries context.
Custom machine learning models
Use SurrealML to train custom machine learning models in Python, using PyTorch, Tensorflow, or Sklearn. The models are stored in a custom .surml data-format, enabling the model to be run consistently and safely in Python, Rust, or SurrealDB.
Import models into SurrealDB
SurrealDB allows developers the choice of storing SurrealML models on local storage, or remote storage including Amazon S3, Google Cloud Storage, or Azure Storage.
PyTorch
PyTorch models are supported natively with SurrealML when running in Python, or within SurrealDB.
Tensorflow
Tensorflow models are supported natively with SurrealML when running in Python, or within SurrealDB.
Sklearn
Sklearn models are supported natively with SurrealML when running in Python, or within SurrealDB.
Export models from SurrealDB
SurrealDB allows developers to store multiple versions of each SurrealML model, and to export each model from the database as a binary file.
Model inference in Python
Inference on .surml model files in Python allows for consistent and reproducible model computation in development, continuous integration, testing, or production environments.
Model inference in SurrealDB
Model inference within SurrealDB is powered by a Rust-native runtime, backed by ONNX, with support for PyTorch, Tensorflow, and Sklearn models. This secure, and performant runtime allows for CPU and GPU model inference right alongside the data within the database.
Array functions
Functions for manipulation, joining, and diffing of arrays are built into SurrealDB as standard.
Http functions
HTTP functions can be used for remote trigger events and webhook functionality.
Math functions
Math functions can be used for complex statistical analysis of numbers and sets of numbers.
Parsing functions
Parsing functions can be used for parsing and extracting individual parts or urls, emails, and domains.
Rand functions
Random generation functions can be used to generate random values, numbers, strings, UUIDs, and datetimes.
Search functions
Functions related to the full-text search capabilities, such as calculating relevance scores or highlighting content.
String functions
Functions for string manipulation enable modification and processing of strings.
Type functions
Type checking functions can be used to check the type of a value, which is useful in custom function definitions.
Vector functions
A collection of essential vector operations that provide foundational functionality for numerical computation, machine learning, and data analysis.
Geo functions
Geospatial functions can be used for converting between geohash values, and for calculating the distance, bearing, and area of GeoJSON data types.
Time functions
Time functions can be used to manipulate dates and times - with support for rounding, and extracting specific parts of datetimes.
Count functions
SurrealDB supports general count functionality for counting total values, or for aggregate grouping. It's also possible to count only those expressions which result in a truthy value.
Validation functions
Validation functions can be used to determine that field values match a certain pattern including hexadecimal, alphanumeric, ascii, numeric, or email addresses.
Embedded JavaScript functions
JavaScript functions can be used for more complex functions and triggers. Each JavaScript function iteration runs with its own context isolation - with the current record data passed in as the execution context or this value.
Custom functions
Custom functions allow for complicated or repeated user-defined code, to be run seamlessly within any query across the database. Custom functions support typed arguments, and multiple nested queries with custom logic.
Root access
Root access enables full data access for all data in SurrealDB. Root access can be limited to specific IPv4 or IPv6 IP addresses.
Namespace access
Namespace access enables full data access for all databases under a specific namespace. This access level is controlled using custom defined usernames and passwords.
Database access
Database access enables full data access to a specific database under a specific namespace. This access level is controlled using custom defined usernames and passwords.
Record access
Record access is the powerful functionality which enables SurrealDB to operate as a web database. Flexible authentication and access rules enable fine-grained access to tables and fields with the highest security, whilst ensuring that performance is affected as little as possible.
3rd party authentication
If authentication with a 3rd party OAuth provider is desired, specific tokens can be used for authentication with SurrealDB. ES256, ES384, ES512, HS256, HS384, HS512, PS256, PS384, PS512, RS256, RS384, and RS512 algorithms are supported.
Table permissions
Fine-grained table permissions can be used to prevent users from accessing data which they shouldn't see. Independent permissions for selecting, creating, updating, and deleting data are supported, ensuring fine-grained control over all data in SurrealDB.
REST API
All tables and data can be queried using a traditional Key-Value REST API. In addition, SurrealQL statements can be submitted to the REST API for custom query logic.
SurrealQL over HTTP/WS
SurrealQL querying and data modification is supported over WebSockets for bi-directional communication, and real-time updates.
CBOR RPC over HTTP/WS
Querying and data modification is available using CBOR-RPC over WebSockets, enabling easier implementation of 3rd party libraries.
JSON RPC over HTTP/WS
SurrealQL querying and data modification is supported over WebSockets for bi-directional communication, and real-time updates.
Binary RPC over HTTP/WS
Querying and data modification is available using JSON-RPC over WebSockets, enabling easier implementation of 3rd party libraries.
GraphQL schema generation
Support for automatic generation of GraphQL schema, from database tables, fields, types, and custom functions.
GraphQL querying
Support for querying all data using GraphQL, with embedded and remote record fetching.
GraphQL mutations
Support for modifying and updating any data using GraphQL, depending on permissions.
GraphQL subscriptions
Support for subscribing to real-time data modification events, depending on permissions.
Command-line tool
The command-line tool can be used to export data as SurrealQL, import data as SurrealQL, and start a SurrealDB instance or cluster.
SQL export
Export all data as SurrealQL from a SurrealDB database for backup purposes. This includes authentication scopes, tables, fields, events, indexes, and data.
SQL import
Import SurrealQL into a SurrealDB database in order to restore from a backup. This includes authentication scopes, tables, fields, events, indexes, and data.
Incremental backups
Export all data from SurrealDB as raw binary data. This will also support incremental binary backups for efficient backing up of SurrealDB clusters.
Docker container
In addition to binary releases, SurrealDB is packaged as a Docker container for easy setup and configuration. The Docker container can be used to start a SurrealDB instance or cluster, or to import and export data.
IDE language support
Official SurrealQL language highlighting packages for Visual Studio Code using TextMate grammar definitions.
Language Server Protocol
Support for the Language Server Protocol will help with code and query completion, and error highlighting for SurrealQL.
User Interface
An easy-to-use interface with support for table-based views, SurrealQL querying, embedded object editing, and graph visualisation.
Web app
The interface is available as a web app.
macOS
The interface is available as a desktop application for macOS powered by Tauri.
Windows
The interface is available as a desktop application for Windows powered by Tauri.
Linux
The interface is available as a desktop application for Linux powered by Tauri.
Rust
A native async-friendly SDK for Rust with bi-directional, binary communication over WebSocket or HTTP, and support for SurrealDB embedded in-memory and on-disk.
JavaScript
A native SDK for JavaScript with bi-directional, binary communication over WebSockets or HTTP, and support for SurrealDB embedded in-memory and on-disk.
TypeScript
Full support for TypeScript definitions from within the JavaScript SDK, for working with strongly-typed data with embedded and remote databases.
Node.js
A native Node.js plugin for use with the JavaScript SDK, enabling support for SurrealDB embedded in-memory or on-disk using SurrealKV.
Deno
A native Deno plugin for use with the JavaScript SDK, enabling support for SurrealDB embedded in-memory or on-disk using SurrealKV.
Python
An SDK for sync or async Python runtimes, with binary communication over WebSocket or HTTP, and support for SurrealDB embedded in-memory and on-disk.
Java
An SDK for Java with binary communication over WebSocket or HTTP, and support for SurrealDB embedded in-memory and on-disk.
Golang
An SDK for Golang with binary communication over WebSocket or HTTP, and support for SurrealDB embedded in-memory and on-disk.
.NET
A native SDK for .NET with bi-directional communication over WebSockets or HTTP.
PHP
A native SDK for PHP with bi-directional, binary communication over WebSockets or HTTP.
C
An SDK for C with binary communication over WebSocket or HTTP, and support for SurrealDB embedded in-memory and on-disk.
Dart
An SDK for Dart with binary communication over WebSocket or HTTP, and support for SurrealDB embedded in-memory and on-disk.
Swift
A native SDK for Swift with bi-directional, binary communication over WebSockets or HTTP.
Ruby
A native SDK for Ruby with bi-directional, binary communication over WebSockets or HTTP.
Erlang
A native SDK for Erlang with bi-directional, binary communication over WebSockets or HTTP.
JavaScript
A native SDK for JavaScript with bi-directional, binary communication over WebSockets or HTTP, and support for SurrealDB embedded in-memory and on-disk.
TypeScript
Full support for TypeScript definitions from within the JavaScript SDK, for working with strongly-typed data with embedded and remote databases.
WebAssembly
A WebAssembly plugin for use with the JavaScript SDK in the browser, enabling support for SurrealDB embedded in-memory or persisted in IndexedDB.
Ember.js
A real-time, live-updating SDK for Ember.js, with authentication, model definition, embedded types, caching, and remote fetching.
React.js
Support for React.js using the native JavaScript SDK, within TanStack Query, with support for data caching and syncing, and authentication.
Next.js
Support for Next.js using the native JavaScript SDK, within TanStack Query, with support for data caching and syncing, and authentication.
Vue.js
Support for Vue.js using the native JavaScript SDK, within TanStack Query, with support for data caching and syncing, and authentication.
Angular
Support for Angular using the native JavaScript SDK, within TanStack Query, with support for data caching and syncing, and authentication.
Solid.js
Support for Solid.js using the native JavaScript SDK, within TanStack Query, with support for data caching and syncing, and authentication.
Svelte
Support for Svelte using the native JavaScript SDK, within TanStack Query, with support for data caching and syncing, and authentication.
Flutter
An SDK for Flutter with bi-directional communication over WebSockets.