MongoDB Atlas

This page last updated on 2024-09-18

The PowerSync MongoDB module (alpha) is currently slated for release during the week of September 23, 2024. See the bottom of this page for detailed project status.

MongoDB Atlas deprecation

In September 2024, MongoDB deprecated the following services:

  • Atlas Device Sync

  • Atlas Data API

  • Atlas Device SDKs

If you have MongoDB Atlas Device Sync deployed today, at a high level your architecture probably looks something like this:

PowerSync upcoming support for MongoDB

PowerSync is currently working on support for MongoDB as a backend database.

Migrating to PowerSync's MongoDB module would take you to this: (new components in green)

As you can see, this is not a point-and-click migration, however it does enable you to stay on MongoDB and those are the customers we are primarily interested in working with and supporting.

Notable comments on the architecture

  1. PowerSync handles writes differently from reads. This is because developers typically want to have some business logic running on an authoritative server before allowing a client device to change data in the backend database.

    1. Reads are partitioned using Sync Rules

      1. Sync Rules are more flexible than MongoDB Realm Flexible Sync, but are defined server-side and not client-side.

    2. Writes are queued locally on the device and sent to the backend sequentially.

    3. The backend can be a very thin API layer or can contain significant amounts of logic — it is up to the developer

  2. The PowerSync Service is generally available as a cloud-hosted service (PowerSync Cloud), or you can self-host using our Open Edition. Our MongoDB module will at first only be available in our Open Edition, and we will work on on making it available on PowerSync Cloud thereafter.

  3. The PowerSync Client SDKs use SQLite under the hood. While there is nothing on a protocol level preventing us from supporting Realm as a client-side database, we are waiting to see whether Realm becomes a community project or not before investing in it, since it would be a significant amount of work for us to support Realm on the client-side.

    1. This will most likely be where the bulk of migration work takes place for customers.

    2. Client-side queries are typically written in SQL. ORM support is available for our JavaScript (React Native and web) and Flutter/Dart Client SDKs.

  4. PowerSync piggybacks off your existing authentication, however, it uses JWTs. If you were using Atlas Device SDKs for auth, you will need to implement an auth provider.

Migration steps

  1. Spin up an instance of the PowerSync Service and connect it to your MongoDB database

    1. We will have a demo project that automates this for you available soon.

  2. Define Sync Rules in PowerSync — this enables dynamic partial replication so that you don't need to sync your entire MongoDB database to devices.

    1. We recommend starting with one or two simple Global Data queries

  3. Use our Diagnostics App to validate that MongoDB is syncing into SQLite as expected.

  4. Implement an app using one of our Client SDKs

    1. You can continue using your Development Token for a start

    2. Implement a "Hello World" app to get a feel OR jump straight into pulling the Client SDK into your existing app

    3. Verify that downloads from MongoDB are working

  5. Implement authentication

  6. Implement your backend app to accept writes. We have Node.js, Django and Rails demos available here.

Implementation notes

PowerSync Service

The PowerSync Service can either be self-hosted or deployed using PowerSync Cloud. MongoDB support for PowerSync Cloud is planned for later in 2024.

To self-host, you need a Docker environment and we will be providing a Docker Compose demo.

Client SDKs

We are constantly adding additional PowerSync Client SDKs and some of them are under very active development. Below are the release status for each language/platform:

FlavorStatusETA

Stable

N/A

Stable

N/A

Stable

N/A

Beta

V1 ETA 2025Q1

Alpha

Beta ETA 2024Q4

We've had customers inquire about the availability of a Rust/C++ SDK. The PowerSync core SQLite extension is implemented in Rust and we can work with customers to integrate PowerSync into their C++ applications. Please reach out to us at hello@powersync.com or schedule a call with us

App Backend

You will need to host a backend that can accept client writes if you do not already have one. The app backend needs to expose an API endpoint to write changes from the PowerSync client.

Additional implementation notes are available here.

Status of MongoDB support in PowerSync

In PowerSync nomenclature, Beta means the package is ready to be used for production given you have adequately tested your use case. We typically don't make any breaking API changes when moving from Beta to V1. Alpha is a bit more unstable and could have breaking changes when moving to Beta, so we do not recommend using it in production.

PoC (Completed)

We have internally completed a proof-of-concept for supporting MongoDB as a backend database. This has not been released publicly.

Alpha (WIP) - 90% done

Beta (Not started) - estimated start 2024Q4

V1 (Not started) - estimated start 2025Q1

Last updated