Generated Fields

Generate additional fields on the fly

Stapsher can generate additional fields for you, if you want it to. It can be helpful if you, for example, want to add a timestamp field in each of the data files.

You can define Generated Fields in Stapsher’s configuration file (stapsher.yaml), under the generatedFields option.

generatedFields option takes an Object with the following structures:

Simple Structure

generatedFields:
  key: [String]

Example:

generatedFields:
  baseUrl: "https://example.com"

Extended Structure

generatedFields:
  key:
    type: [String]
    options: [Object]

Currently, the only type supported in extended structure is:

  • date

    type: "date"
    options:
      format: [String]

    Supported formats are:

    • unix-milliseconds / unix: Milliseconds since epoch 1970-01-01 00:00:00 UTC
    • unix-seconds: Seconds since epoch 1970-01-01 00:00:00 UTC
    • All the formats supported by dateformat package

Example:

generatedFields:
  timestamp:
    type: "date"
    options:
      format: "unix"

You can have multiple Generated Fields, each with either Simple or Extended structure.