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

Defined in: fields/hash.ts:52

Decorator

Marks a property as the HashField used to compute the identity of an ObjectSchema. At most one property per object schema may use this decorator, and doing so becomes that schema's identity.

Parameters

options

HashOptions

Returns

(target, key) => void

Example

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

@ObjectSchema
export class Address {
  @hash({ type: 'address-hash' }) declare addressHash: string;
  @field declare street: string;
}
json
{
  "type": "address",
  "identity": { "kind": "@hash", "name": "addressHash", "type": "address-hash" }
}

Since

5.9.0

Released under the MIT License.