module@warp-drive/schema-dsl
Call Signature
ts
function id(target, key): void;Defined in: fields/id.ts:55
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" }
}Since
5.9.0
Call Signature
ts
function id(options): (target, key) => void;Defined in: fields/id.ts:56
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
Returns
(target, key) => 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" }
}Since
5.9.0