Skip to content

Moving document workloads from MongoDB to RedDB

Compare a MongoDB document workload with RedDB document queries and plan a tested export, import, and cutover.

On this page

Begin with query behavior

MongoDB and RedDB both support document-oriented workloads, but matching labels do not mean identical query languages, indexes, aggregation behavior, transaction semantics, or driver APIs. List the queries and operational features your application depends on before choosing a migration path.

Try the examples locally

Start RedDB with its HTTP endpoint bound to your local machine:

bash
red server --http-bind 127.0.0.1:5000 --path ./example.rdb --dev

--dev disables authentication and is only for a trusted local environment. In a second terminal, define a helper to send a query. It requires curl and jq:

bash
query() {
  curl -fsS http://127.0.0.1:5000/query \
    -H 'content-type: application/json' \
    --data "$(jq -cn --arg query "$1" '{query: $query}')"
}

The examples below were executed against RedDB 1.26.8. Use a fresh database for this walkthrough; reusing names from another example can change the results.

Write and query a RedDB document

bash
query 'INSERT INTO product_docs DOCUMENT VALUES ({"source_id":"item-1","category":"ops","title":"Runbook"})'
query "SELECT source_id, title FROM product_docs WHERE category = 'ops'"

The response contains the source ID and title for the matching document. RedDB creates the document collection on first write in this tested example. source_id is an application field here; it is not a promise that MongoDB _id values or indexes are migrated automatically.

Translate a workload one feature at a time

Start with representative examples for inserts and filters, then test sorting, pagination and the nested-field expressions your code uses. For aggregation pipelines, joins, text search, change streams and TTL behavior, verify support and equivalent results against your deployed release. RedDB SQL is not automatically interchangeable with MongoDB aggregation syntax.

Create a mapping for source identifiers and reference relationships. Export a representative dataset and transform it using an application-owned process; the public red CLI does not expose an automated red migrate documents command. Validate the resulting records and indexes rather than assuming they were preserved.

Rehearse the cutover

Compare counts and sampled data, run application-level query tests, and establish how concurrent writes and deletes are reconciled during the move. Document the point of cutover and keep a tested rollback and restore path. For the native document operations, start with the RedDB documents reference.

Get the next dispatch.

New essays on multi-model storage, RAG, agents, security. No spam.

No spam. Unsubscribe anytime.