Skip to content
module@warp-drive/schema-dsl

Decorator alias() sincev5.9.0 ​

ts
function alias(options: AliasOptions): (target: object, key: string) => void;

Defined in: fields/alias.ts:82

Decorator

Marks a property as an alias — compiling to a LegacyAliasField, PolarisAliasField, or ObjectAliasField depending on the schema it's declared on — that points to another field already present in the schema.

Unlike derived, an alias may write back to its source field when the record is in an editable mode.

Parameters ​

options ​

AliasOptions

Returns ​

(target: object, key: string) => void

Example ​

ts
import { Resource, field, alias } from '@warp-drive/schema-dsl';

@Resource
export class Product {
  @field({ sourceKey: 'product_name' }) declare name: string;
  @alias({ kind: 'field', name: 'name' }) declare productName: string;
}
json
[
  { "kind": "field", "name": "name", "sourceKey": "product_name" },
  { "kind": "alias", "name": "productName", "type": null, "options": { "kind": "field", "name": "name" } }
]

Released under the MIT License.