Full Document Before Change

My trigger is set to receive the full document before change.

However I’m not receiving the property fullDocumentBeforeChange in my Realm function.

My Linked Data Source has no collections in it, and I don’t see where I could add them. Maybe this is the issue? How do I add collections to the configuraton below?

1 Like

I managed to solve it by running the following command through mongosh:

db.runCommand({ collMod: "collection_name", recordPreImages: true })

After running it it appears on the list above.

Sadly I have to run it manually for every collection of every database that I need preimages enabled. This should also be configured through Realm config files.

1 Like

Thanks for this! Upon further looking into it, I realized you can also set it in your realm app configuration files.

In you local realm app directory, navigate to data_sources/<service name>/config.json. To enable preimages on a collection called “myCollection”, your config file might look like:

{
  "name": "myMongoDBService",
  "type": "mongodb-atlas",
  "config": {
    "clusterName": "myCluster",
    "namespacePreimageConfigs": [
      {
        "collectionName": "myCollection",
        "dbName": "myDB",
        "recordPreimages": true
      }
    ],
    "readPreference": "primary",
    "wireProtocolEnabled": false
  },
  "version": 1
}
1 Like

Nice!

This pre-image stuff is still not production-ready, so there’s not much information about it.

More information about it can be found at MongoDB 4.4 Change Streams and Experimental Pre-Image 'Support' | ALEX BEVILACQUA

1 Like