Skip to main content

set_field

The set_field processor sets the value for a field in any DataEntity or DataWindow. If the field already exists on a record the default behavior to is not overwrite it, but there is an option to overwrite the field value even if it exists.

Usage

Example Job

{
"name" : "testing",
"workers" : 1,
"slicers" : 1,
"lifecycle" : "once",
"assets" : [
"standard"
],
"operations" : [
{
"_op": "test-reader"
},
{
"_op": "set_field",
"field": "some_field",
"value": 2
}
]
}

Example of the data and the expected results

const data = [
DataEntity.make({ name: 'milly' }),
DataEntity.make({ name: 'willy' }),
DataEntity.make({ name: 'billy' }),
DataEntity.make({ name: 'dilly' }),
]

const results = await processor.run(data);

results === [
{ name: 'milly', 'some_field': 2 }
{ name: 'willy', 'some_field': 2 }
{ name: 'billy', 'some_field': 2 }
{ name: 'dilly', 'some_field': 2 }
]

Parameters

ConfigurationDescriptionTypeNotes
_opName of operation, it must reflect the exact name of the fileStringrequired
fieldField name to set valueStringrequired
valueValue to set field toStringrequired
overwriteSet to true to overwrite the field to the specified value if it existsBooleandefault false