-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
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.