Hello ,
We are evaluating mongodb relational migrator tool and we want to migrate from Azure SQL to mongodb atlas by making columns as dynamic key value pairs . We have enabled CDC and it is migrating but I cannot transform columns to key value pairs like shown below
Eg: Azure SQL
{ “ID”: “123”, “att1”: “a”, “name”: “blah blah”, “att2”: “b”, “count”: 45 }
to Target(MongoDb Atlas)
{“ID”: “123”,“attributes”: [{ “key”: “att1”, “value”: “a” },{ “key”: “name”, “value”: “blah blah” },{ “key”: “att2”, “value”: “b” },{ “key”: “count”, “value”: 45 }]}
Yes; you can perform complex transformations in JavaScript using Calculated Fields. So using the example above:
“ID” would just be a regular field
Create a calculated field with name “attributes”
The calculated field would have an expression like:
new Array(
new Object({
"key": "attr"
"value": columns["attr"]
}),
new Object({
"key": "name",
"value": columns["name"]
}),
...
)
`
I’ll add the while there’s no way to fetch all columns in the table as a single value, you could fetch them one by one through columns[“name”] , columns[“count”]. Let us know if you have any further questions.
Note this was originally answered in separate customer thread but I’ve reposted here for future reference.