Skip to main content

add_short_id

The add_short_id processor adds a unique short id to a DataEntity or DataWindow. Useful for when a UUID is overkill.

Usage

Add a unique id to a record

Example of a job using the add_short_id processor

{
"name" : "testing",
"workers" : 1,
"slicers" : 1,
"lifecycle" : "once",
"assets" : [
"standard"
],
"operations" : [
{
"_op": "test-reader"
},
{
"_op": "add_short_id",
"field": "short_id",
"dictionary": "alphanum",
"length": 8
}
]
}

Here is a representation of what the processor will do with the configuration listed in the job above

const data = [
DataEntity.make({ name: 'chilly' }),
]

const results = await processor.run(data);

results = [{ name: 'chilly', short_id: 'de12Ed98' }]

Parameters

ConfigurationDescriptionTypeNotes
_opName of operation, it must reflect the exact name of the fileStringrequired
nameName of field that will store unique id valuestringrequired
lengthLength of idnumberdefaults to 6
dictionaryTypes of characters to use in the stringone of 'number', 'alpha', 'alpha_lower', 'alpha_upper', 'alphanum', 'alphanum_lower', 'alphanum_upper', 'hex'defaults to 'alphanum'