Skip to content
module@warp-drive/schema-dsl
ts
function alias(options): (target, key) => void;

Defined in: fields/alias.ts:78

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, key) => 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" } }
]

Since

5.9.0

Released under the MIT License.