Untitled
unknown
plain_text
2 years ago
820 B
6
Indexable
function compareJSONs(merged) {
const differences = {};
Object.entries(merged).forEach(([key, value]) => {
const { mysql, postgres } = value;
// Check if the JSON objects are different
if (!_.isEqual(mysql, postgres)) {
const diff = {};
// Iterate over the keys in the JSON objects
Object.keys(mysql).forEach((jsonKey) => {
// If the values for the current key are different, add it to the diff object
if (!_.isEqual(mysql[jsonKey], postgres[jsonKey])) {
diff[jsonKey] = {
mysql: mysql[jsonKey],
postgres: postgres[jsonKey],
};
}
});
// Add the diff object to the differences object
if (Object.keys(diff).length > 0) {
differences[key] = diff;
}
}
});
return differences;
}Editor is loading...
Leave a Comment