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

Decorator id() ​

ts
function id(target: object, key: string): void;
function id(options: IdOptions): (target: object, key: string) => void;

Call Signature ​

sincev5.9.0
ts
function id(target: object, key: string): void;

Defined in: fields/id.ts:58

Decorator

Marks a property as the identity field for a Resource, overriding the default { kind: '@id', name: 'id' } identity with { kind: '@id', name: <decorated property> }.

Only needed when a resource's primary key is not named id; most resources can rely on Resource's default identity instead.

Parameters ​

target ​

object

key ​

string

Returns ​

void

Example ​

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

@Resource
export class Post {
  @id declare uuid: string;
  @field declare title: string;
}
json
{
  "type": "post",
  "identity": { "kind": "@id", "name": "uuid" }
}

Call Signature ​

sincev5.9.0
ts
function id(options: IdOptions): (target: object, key: string) => void;

Defined in: fields/id.ts:59

Decorator

Marks a property as the identity field for a Resource, overriding the default { kind: '@id', name: 'id' } identity with { kind: '@id', name: <decorated property> }.

Only needed when a resource's primary key is not named id; most resources can rely on Resource's default identity instead.

Parameters ​

options ​

IdOptions

Returns ​

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

Example ​

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

@Resource
export class Post {
  @id declare uuid: string;
  @field declare title: string;
}
json
{
  "type": "post",
  "identity": { "kind": "@id", "name": "uuid" }
}

Released under the MIT License.