Skip to content

Conversation

rkistner
Copy link
Contributor

@rkistner rkistner commented Sep 19, 2024

Alpha MongoDB replication module. Loosely based on the Postgres module.

Replication is performed using MongoDB change streams, rather than the low-level oplog API, to make sure we get proper documents out instead of the low-level operations. The clusterTime (oplog timestamp) is used in place of postgres LSN.

Replication currently uses the fullDocument: 'updateLookup' option, which means that operations could replicate out of order. This will be fixed in a future release.

Sample config:

# powersync.yaml
replication:
  connections:
    - type: mongodb
      uri: mongodb://127.0.0.1:27017/powersync_demodb
# sync-rules.yaml
bucket_definitions:
  global:
    data:
      - select _id as id, * from lists
      - select _id as id, * from todos

Demo backend: https://github.com/powersync-ja/powersync-nodejs-backend-todolist-demo
Demo app: https://github.com/powersync-ja/self-host-demo/tree/main/demos/nodejs/demo-app (no changes from the Postgres version)

Copy link

changeset-bot bot commented Sep 19, 2024

🦋 Changeset detected

Latest commit: 94c87aa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@powersync/service-module-mongodb Minor
@powersync/service-image Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

stevensJourney
stevensJourney previously approved these changes Oct 14, 2024
@rkistner rkistner marked this pull request as ready for review October 14, 2024 15:14
@rkistner rkistner merged commit 04d5f30 into feat/modular-replication-architecture Oct 15, 2024
9 checks passed
@rkistner rkistner deleted the mongodb-alpha branch October 15, 2024 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants