Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
820 B
1
Indexable
Never
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;
}
Leave a Comment