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

Call Signature

ts
function ObjectSchema(target): void;

Defined in: entities/object-schema.ts:67

Class Decorator

Marks a class as an object schema — an embedded structure with no independent identity of its own, for use as the value of an @object or alias field on a resource.

The object's type is derived from the class name (dasherized) unless a type string is passed explicitly. Its identity is null unless a property is decorated with hash, in which case that compiled HashField becomes the identity.

Each decorated property on the class contributes one entry to the compiled fields array, in declaration order.

Parameters

target

AnyConstructor

Returns

void

Example

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

@ObjectSchema
export class Address {
  @field declare street: string;
  @field declare city: string;
}
json
{
  "type": "address",
  "identity": null,
  "fields": [
    { "kind": "field", "name": "street" },
    { "kind": "field", "name": "city" }
  ]
}

Since

5.9.0

Call Signature

ts
function ObjectSchema(type, options?): (target) => void;

Defined in: entities/object-schema.ts:68

Class Decorator

Marks a class as an object schema — an embedded structure with no independent identity of its own, for use as the value of an @object or alias field on a resource.

The object's type is derived from the class name (dasherized) unless a type string is passed explicitly. Its identity is null unless a property is decorated with hash, in which case that compiled HashField becomes the identity.

Each decorated property on the class contributes one entry to the compiled fields array, in declaration order.

Parameters

type

string

options?

ObjectSchemaOptions

Returns

(target) => void

Example

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

@ObjectSchema
export class Address {
  @field declare street: string;
  @field declare city: string;
}
json
{
  "type": "address",
  "identity": null,
  "fields": [
    { "kind": "field", "name": "street" },
    { "kind": "field", "name": "city" }
  ]
}

Since

5.9.0

Call Signature

ts
function ObjectSchema(options): (target) => void;

Defined in: entities/object-schema.ts:69

Class Decorator

Marks a class as an object schema — an embedded structure with no independent identity of its own, for use as the value of an @object or alias field on a resource.

The object's type is derived from the class name (dasherized) unless a type string is passed explicitly. Its identity is null unless a property is decorated with hash, in which case that compiled HashField becomes the identity.

Each decorated property on the class contributes one entry to the compiled fields array, in declaration order.

Parameters

options

ObjectSchemaOptions

Returns

(target) => void

Example

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

@ObjectSchema
export class Address {
  @field declare street: string;
  @field declare city: string;
}
json
{
  "type": "address",
  "identity": null,
  "fields": [
    { "kind": "field", "name": "street" },
    { "kind": "field", "name": "city" }
  ]
}

Since

5.9.0

Released under the MIT License.