Skip to content

Support for migration / transformation of cases #73

@vlaurin

Description

@vlaurin

Consider the addition of utility functions to modify cases in an immutable manner, like in the example functions below:

To simply add or edit fields in a case payload:

const setFields = (fields) => (aCase) => ({
  ...aCase,
  data: {
    ...aCase.data,
    ...fields,
  }
});

To map existing values to new values, especially in the context of a migration:

const mapField = (field) => (map) => (aCase) => {
  const before = fieldExtractor(aCase)(field);

  if (map[before] === undefined) {
    return aCase;
  }

  return {
    ...aCase,
    data: {
      ...aCase.data,
      [field]: map[before],
    }
  };
};

Both examples create a new case object with modified fields.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions