Locospec

Alias Spec

Define virtual fields using path references or JMESPath transforms.

Aliases are virtual attributes defined in the Model Spec that allow you to:

  • Reference deeply nested relationships
  • Apply lightweight transformations to fields
  • Expose computed values for display or filtering

They are read-only, derived fields that do not exist in the database, but are resolved dynamically during query or rendering time.


🔧 Basic Structure

"aliases": {
  "role_name": {
    "source": "role.name"
  },
  "full_name": {
    "transform": "concat(first_name, ' ', last_name)"
  }
}

🔑 Keys

KeyTypeDescription
sourcestringDot-notated path to another attribute (can include relationships)
transformstringA JMESPath expression used to compute the value

You can use either source or transform, but not both.


📦 source

Simple alias to an existing field or nested relationship.

"aliases": {
  "approver_email": {
    "source": "meta.approver[0].email"
  }
}

Useful when your UI needs a flat field but the data is nested.


🔁 transform

Use a JMESPath expression to apply logic.

"aliases": {
  "full_name": {
    "transform": "concat(first_name, ' ', last_name)"
  }
}

Supported functions include:

🧠 Transforms allow you to prepare data for read-heavy UIs without modifying your actual schema.


🧪 Example: Complete Aliases Block

"aliases": {
  "role_name": {
    "source": "role.name"
  },
  "creator_email": {
    "source": "meta.created_by.email"
  },
  "full_name": {
    "transform": "join(' ', [first_name, last_name])"
  },
}

🔎 Where Aliases Are Used

  • In View Specs and Entity Specs as displayable fields
  • In Filters and Scopes for querying virtual fields
  • In Search definitions
  • In Transformations for data transformation.

📎 Spec Reference

👉 model.json#/properties/aliases

On this page