---
title: Surreal ORM Lite documentation
description: >-
  The user guide of Surreal ORM Lite: a Django-style async ORM for SurrealDB
  built on the official SurrealDB Python SDK.
---
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.page/EulogySnowfall/SurrealDB-ORM-lite/llms.txt
> Use this file to discover all available pages before exploring further.

# Surreal ORM Lite documentation

The user guide of [Surreal ORM Lite](https://github.com/EulogySnowfall/SurrealDB-ORM-lite/blob/main/README.md): a Django-style async ORM for SurrealDB built on the official
SurrealDB Python SDK. Start with [Getting started](/getting-started), then open the guide of the feature you need.
The same code runs on SurrealDB 2.x, 3.x, 4.x and the SDK's embedded engine; where they behave differently, the
guide says so and [Compatibility](/compatibility) lists every difference. Coming from 0.40.x (SDK 2.0), read
[Migrating to 0.50](/migrating-to-0.50) first.

## Guides

- **[Getting started](/getting-started)**
  - [Why This Project?](/getting-started#why-this-project)
  - [Requirements](/getting-started#requirements)
  - [Installation](/getting-started#installation)
  - [Quick Start](/getting-started#quick-start)
    - [1. Configure the Connection](/getting-started#1-configure-the-connection)
    - [2. Define a Model](/getting-started#2-define-a-model)
    - [3. CRUD Operations](/getting-started#3-crud-operations)
- **[Models](/models)**
  - [Custom Primary Key](/models#custom-primary-key)
  - [Custom table name (`table_name`)](/models#custom-table-name-tablename)
  - [15. Server-side values: `SurrealFunc` + `server_values=`](/models#15-server-side-values-surrealfunc-servervalues)
  - [16. Computed fields: `Computed[...]` → `DEFINE FIELD … VALUE`](/models#16-computed-fields-computed-define-field-value)
  - [20. Field aliases, `server_fields` and `merge(refresh=False)`](/models#20-field-aliases-serverfields-and-mergerefreshfalse)
- **[Field types](/fields)**
  - [24. Rich field types](/fields#24-rich-field-types)
  - [25. Geospatial fields](/fields#25-geospatial-fields)
- **[Querying](/querying)**
  - [4. QuerySet Methods](/querying#4-queryset-methods)
  - [Supported Filter Lookups](/querying#supported-filter-lookups)
  - [5. Q Objects (Complex Queries)](/querying#5-q-objects-complex-queries)
  - [8. FETCH Clause](/querying#8-fetch-clause)
  - [9. Aggregations](/querying#9-aggregations)
  - [27. Time travel (`as_of()`)](/querying#27-time-travel-asof)
  - [28. Subqueries (`Subquery`)](/querying#28-subqueries-subquery)
  - [29. Query cache (`cache()`, `QueryCache`)](/querying#29-query-cache-cache-querycache)
- **[Writing data](/writing)**
  - [6. Bulk Operations](/writing#6-bulk-operations)
  - [10. Model Signals](/writing#10-model-signals)
  - [11. Transactions (atomic, all-or-nothing)](/writing#11-transactions-atomic-all-or-nothing)
  - [12. Upsert & get_or_create / update_or_create](/writing#12-upsert-getorcreate-updateorcreate)
  - [13. Patch & atomic field/array operations](/writing#13-patch-atomic-fieldarray-operations)
  - [14. Optimistic concurrency: `retry_on_conflict`](/writing#14-optimistic-concurrency-retryonconflict)
- **[Relations and graph](/relations)**
  - [7. Relations & Graph](/relations#7-relations-graph)
  - [23. Typed edges (`BaseSurrealEdge`)](/relations#23-typed-edges-basesurrealedge)
  - [34. Relation constraints (`relation_in`, `define_relation()`)](/relations#34-relation-constraints-relationin-definerelation)
- **[Stored functions and events](/functions-and-events)**
  - [17. Stored functions: `call_function()`](/functions-and-events#17-stored-functions-callfunction)
  - [32. Server-side events and stored functions (`Event`, `define_events()`, `define_function()`)](/functions-and-events#32-server-side-events-and-stored-functions-event-defineevents-definefunction)
- **[Authentication](/authentication)**
  - [18. Authentication (`signin` / `signup` / `info` / `invalidate`)](/authentication#18-authentication-signin-signup-info-invalidate)
  - [19. Model-level authentication (`AuthenticatedUserMixin`)](/authentication#19-model-level-authentication-authenticatedusermixin)
- **[Live queries and change feeds](/realtime)**
  - [21. Live queries (real-time notifications)](/realtime#21-live-queries-real-time-notifications)
  - [22. Change feeds (`changes()`)](/realtime#22-change-feeds-changes)
- **[Connections](/connections)**
  - [Context Manager](/connections#context-manager)
  - [Connections and event loops](/connections#connections-and-event-loops)
  - [30. Multiple databases (`add_connection()`, `using()`)](/connections#30-multiple-databases-addconnection-using)
- **[Embedded engine](/embedded)**
  - [26. Embedded engine and test fixtures](/embedded#26-embedded-engine-and-test-fixtures)
- **[Schema and DDL](/schema)**
  - [31. Schema introspection (`DatabaseIntrospector`, `generate_models_from_db()`)](/schema#31-schema-introspection-databaseintrospector-generatemodelsfromdb)
  - [33. Materialized views (`view_query`, `define_view()`)](/schema#33-materialized-views-viewquery-defineview)
  - [35. Model table DDL (`define_table()`, `schema_mode`, `permissions`)](/schema#35-model-table-ddl-definetable-schemamode-permissions)
- **[Search](/search)**
  - [36. Full-text search (`search()`, `SearchScore`, `SearchHighlight`, `Analyzer`, `Index`)](/search#36-full-text-search-search-searchscore-searchhighlight-analyzer-index)
  - [37. Vector search (`similar_to()`, `VectorField`, `Index(hnsw=True)`)](/search#37-vector-search-similarto-vectorfield-indexhnswtrue)
  - [38. Hybrid search (`hybrid_search()`, Reciprocal Rank Fusion)](/search#38-hybrid-search-hybridsearch-reciprocal-rank-fusion)
- **[Migrations](/migrations)**
  - [39. Migrations (`makemigrations()`, `MigrationExecutor`, operations)](/migrations#39-migrations-makemigrations-migrationexecutor-operations)
- **[Command line](/cli)**
  - [40. Command line (`surreal-orm-lite`)](/cli#40-command-line-surreal-orm-lite)
- **[Testing](/testing)**
  - [41. Test data factories (`ModelFactory`, `Faker`) and the pytest plugin](/testing#41-test-data-factories-modelfactory-faker-and-the-pytest-plugin)
- **[Compatibility](/compatibility)**
  - [ORM behaviour: SurrealDB 2.x, 3.x and 4.x](/compatibility#orm-behaviour-surrealdb-2x-3x-and-4x)
  - [ORM behaviour: the embedded engine](/compatibility#orm-behaviour-the-embedded-engine)
- **[Migrating to 0.50](/migrating-to-0.50)**
  - [Installing](/migrating-to-0.50#installing)
  - [The client of `get_client()`](/migrating-to-0.50#the-client-of-getclient)
  - [Order of `first()` and of pages](/migrating-to-0.50#order-of-first-and-of-pages)
  - [The embedded engine is SurrealDB 4.0](/migrating-to-0.50#the-embedded-engine-is-surrealdb-40)
  - [Migrations on SurrealDB 4.x](/migrating-to-0.50#migrations-on-surrealdb-4x)
  - [Deprecated forms removed](/migrating-to-0.50#deprecated-forms-removed)
- **[Contributing](/contributing)**

## Sections by number

The guides keep the section numbers of the manual, so a reference such as "section 26" names one place.

| Section                                                                                                                                                                                                 | Guide                         |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
| [1. Configure the Connection](/getting-started#1-configure-the-connection)                                                                                                                            | Getting started               |
| [2. Define a Model](/getting-started#2-define-a-model)                                                                                                                                                | Getting started               |
| [3. CRUD Operations](/getting-started#3-crud-operations)                                                                                                                                              | Getting started               |
| [4. QuerySet Methods](/querying#4-queryset-methods)                                                                                                                                                   | Querying                      |
| [5. Q Objects (Complex Queries)](/querying#5-q-objects-complex-queries)                                                                                                                               | Querying                      |
| [6. Bulk Operations](/writing#6-bulk-operations)                                                                                                                                                      | Writing data                  |
| [7. Relations & Graph](/relations#7-relations-graph)                                                                                                                                                 | Relations and graph           |
| [8. FETCH Clause](/querying#8-fetch-clause)                                                                                                                                                           | Querying                      |
| [9. Aggregations](/querying#9-aggregations)                                                                                                                                                           | Querying                      |
| [10. Model Signals](/writing#10-model-signals)                                                                                                                                                        | Writing data                  |
| [11. Transactions (atomic, all-or-nothing)](/writing#11-transactions-atomic-all-or-nothing)                                                                                                           | Writing data                  |
| [12. Upsert & get_or_create / update_or_create](/writing#12-upsert-getorcreate-updateorcreate)                                                                                                  | Writing data                  |
| [13. Patch & atomic field/array operations](/writing#13-patch-atomic-fieldarray-operations)                                                                                                          | Writing data                  |
| [14. Optimistic concurrency: `retry_on_conflict`](/writing#14-optimistic-concurrency-retryonconflict)                                                                                               | Writing data                  |
| [15. Server-side values: `SurrealFunc` + `server_values=`](/models#15-server-side-values-surrealfunc-servervalues)                                                                                  | Models                        |
| [16. Computed fields: `Computed[...]` → `DEFINE FIELD … VALUE`](/models#16-computed-fields-computed-define-field-value)                                                                             | Models                        |
| [17. Stored functions: `call_function()`](/functions-and-events#17-stored-functions-callfunction)                                                                                                    | Stored functions and events   |
| [18. Authentication (`signin` / `signup` / `info` / `invalidate`)](/authentication#18-authentication-signin-signup-info-invalidate)                                                                | Authentication                |
| [19. Model-level authentication (`AuthenticatedUserMixin`)](/authentication#19-model-level-authentication-authenticatedusermixin)                                                                     | Authentication                |
| [20. Field aliases, `server_fields` and `merge(refresh=False)`](/models#20-field-aliases-serverfields-and-mergerefreshfalse)                                                                         | Models                        |
| [21. Live queries (real-time notifications)](/realtime#21-live-queries-real-time-notifications)                                                                                                       | Live queries and change feeds |
| [22. Change feeds (`changes()`)](/realtime#22-change-feeds-changes)                                                                                                                                   | Live queries and change feeds |
| [23. Typed edges (`BaseSurrealEdge`)](/relations#23-typed-edges-basesurrealedge)                                                                                                                      | Relations and graph           |
| [24. Rich field types](/fields#24-rich-field-types)                                                                                                                                                   | Field types                   |
| [25. Geospatial fields](/fields#25-geospatial-fields)                                                                                                                                                 | Field types                   |
| [26. Embedded engine and test fixtures](/embedded#26-embedded-engine-and-test-fixtures)                                                                                                               | Embedded engine               |
| [27. Time travel (`as_of()`)](/querying#27-time-travel-asof)                                                                                                                                         | Querying                      |
| [28. Subqueries (`Subquery`)](/querying#28-subqueries-subquery)                                                                                                                                       | Querying                      |
| [29. Query cache (`cache()`, `QueryCache`)](/querying#29-query-cache-cache-querycache)                                                                                                                | Querying                      |
| [30. Multiple databases (`add_connection()`, `using()`)](/connections#30-multiple-databases-addconnection-using)                                                                                     | Connections                   |
| [31. Schema introspection (`DatabaseIntrospector`, `generate_models_from_db()`)](/schema#31-schema-introspection-databaseintrospector-generatemodelsfromdb)                                        | Schema and DDL                |
| [32. Server-side events and stored functions (`Event`, `define_events()`, `define_function()`)](/functions-and-events#32-server-side-events-and-stored-functions-event-defineevents-definefunction) | Stored functions and events   |
| [33. Materialized views (`view_query`, `define_view()`)](/schema#33-materialized-views-viewquery-defineview)                                                                                        | Schema and DDL                |
| [34. Relation constraints (`relation_in`, `define_relation()`)](/relations#34-relation-constraints-relationin-definerelation)                                                                       | Relations and graph           |
| [35. Model table DDL (`define_table()`, `schema_mode`, `permissions`)](/schema#35-model-table-ddl-definetable-schemamode-permissions)                                                               | Schema and DDL                |
| [36. Full-text search (`search()`, `SearchScore`, `SearchHighlight`, `Analyzer`, `Index`)](/search#36-full-text-search-search-searchscore-searchhighlight-analyzer-index)                             | Search                        |
| [37. Vector search (`similar_to()`, `VectorField`, `Index(hnsw=True)`)](/search#37-vector-search-similarto-vectorfield-indexhnswtrue)                                                                | Search                        |
| [38. Hybrid search (`hybrid_search()`, Reciprocal Rank Fusion)](/search#38-hybrid-search-hybridsearch-reciprocal-rank-fusion)                                                                        | Search                        |
| [39. Migrations (`makemigrations()`, `MigrationExecutor`, operations)](/migrations#39-migrations-makemigrations-migrationexecutor-operations)                                                         | Migrations                    |
| [40. Command line (`surreal-orm-lite`)](/cli#40-command-line-surreal-orm-lite)                                                                                                                        | Command line                  |
| [41. Test data factories (`ModelFactory`, `Faker`) and the pytest plugin](/testing#41-test-data-factories-modelfactory-faker-and-the-pytest-plugin)                                                   | Testing                       |

## Other documents

- [Roadmap](/ROADMAP): every release, its design notes and what comes next.
- [Changelog](https://github.com/EulogySnowfall/SurrealDB-ORM-lite/blob/main/CHANGELOG.md): what changed in each version.
- [Security policy](https://github.com/EulogySnowfall/SurrealDB-ORM-lite/blob/main/SECURITY.md): supported versions and how to report a vulnerability.
- [Runnable examples](https://github.com/EulogySnowfall/SurrealDB-ORM-lite/tree/main/examples/): one Jupyter notebook per feature release.
- [Guide for AI coding assistants](/ai/CLAUDE): a compact page to import into an assistant's `CLAUDE.md`.

## Roadmap

| Version           | Theme                                                | Status      |
| ----------------- | ---------------------------------------------------- | ----------- |
| v0.2.x – v0.7.0   | Core ORM → SDK 2.0 / SurrealDB 3.x migration         | ✅ Released |
| v0.8.0            | Transactions ORM (`tx=`)                             | ✅ Released |
| v0.9.0            | Transactions — QuerySet & interactive (3.x)          | ✅ Released |
| v0.10.0           | upsert / update_or_create / get_or_create            | ✅ Released |
| v0.11.0           | patch / atomic field & array ops                     | ✅ Released |
| v0.12.0           | retry_on_conflict & optimistic concurrency           | ✅ Released |
| v0.13.0           | SurrealFunc & server-side values                     | ✅ Released |
| v0.14.0           | Computed fields (`DEFINE FIELD … VALUE`)             | ✅ Released |
| v0.14.3 – v0.14.5 | Correctness: `$`-values, record-id lookups, loops    | ✅ Released |
| v0.15.0           | `call_function()` — custom `fn::` stored functions   | ✅ Released |
| v0.16.0           | Connection auth (`signin`/`signup`/`info`)           | ✅ Released |
| v0.17.0           | Model auth (`AuthenticatedUserMixin`)                | ✅ Released |
| v0.18.0           | Field aliases, `server_fields`, `merge(refresh=)`    | ✅ Released |
| v0.19.0           | Live queries (base): `live()` / `kill()`, raw notifs | ✅ Released |
| v0.20.0           | Typed live queries: `LiveModelStream`, diff, filters | ✅ Released |
| v0.21.0           | Auto-resubscribe & change feeds (`changes()`)        | ✅ Released |
| v0.22.0           | Tier 1 — Native typed relations                      | ✅ Released |
| v0.23.0           | Rich field types                                     | ✅ Released |
| v0.24.0           | Geospatial fields                                    | ✅ Released |
| v0.25.0           | Embedded test engine                                 | ✅ Released |
| v0.26.0           | Time travel (versioned storage)                      | ✅ Released |
| v0.27.0           | Subqueries                                           | ✅ Released |
| v0.28.0           | Query cache                                          | ✅ Released |
| v0.29.0           | Tier 2 — Multi-database                              | ✅ Released |
| v0.30.0           | Tier 3 — Schema introspection                        | ✅ Released |
| v0.31.0           | Tier 3 — Server-side events and DDL helpers          | ✅ Released |
| v0.32.0           | Tier 3 — Materialized views                          | ✅ Released |
| v0.33.0           | Tier 3 — `TYPE RELATION` constraints                 | ✅ Released |
| v0.34.0           | Tier 3 — Model table DDL                             | ✅ Released |
| v0.35.0           | Tier 3 — Full-text search                            | ✅ Released |
| v0.36.0           | Tier 3 — Vector search                               | ✅ Released |
| v0.37.0           | Tier 3 — Hybrid search                               | ✅ Released |
| v0.38.0           | Tier 3 — Migration system                            | ✅ Released |
| v0.39.0           | Tier 3 — Command line (`surreal-orm-lite`)           | ✅ Released |
| v0.40.0           | Tier 3 — Test fixtures & factories                   | ✅ Released |
| v0.50.0           | Official SDK 3.0 and SurrealDB 4.x                   | ✅ Released |
| v0.51.0           | Connection resilience (reconnect, token renewal)     | 📋 Planned  |
| v0.52.0           | Typed errors and per-statement results               | 📋 Planned  |
| v0.53.0           | Sessions and transaction options                     | 📋 Planned  |
| v0.54.0           | Streaming QuerySet iteration                         | 📋 Planned  |
| v0.55.0           | New field types (sized numbers, calendar, regex)     | 📋 Planned  |
| v0.56.0           | Schema evolution on 4.x (named types, row migration) | 📋 Planned  |
| v0.57.0           | Files and buckets                                    | 📋 Planned  |
| v0.58.0           | Server endpoints (DEFINE API, GraphQL) and export    | 📋 Planned  |
| v0.59.0           | Beta Phase (API freeze, hardening)                   | 📋 Planned  |
| v3.0.0            | Production / GA (aligned with SDK 3.0)               | 📋 Planned  |

> The ORM's minor series follows the official SDK's major: `0.40.x` is the SDK 2.0 line (deprecated, security fixes
> only), `0.50.x` and later the SDK 3.0 line, and the ORM supports the SurrealDB versions that SDK supports. Every
> roadmap feature is implementable with the **official SDK 3.0** (native methods or `query()` SurrealQL) — no custom
> SDK. GA is numbered **v3.0.0** to mirror SDK 3.0; the `1.x` and `2.x` lines are intentionally skipped.

See [docs/ROADMAP.md](/ROADMAP) for full details.
