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

Class Decorator ObjectSchema() ​

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

Call Signature ​

sincev5.9.0
ts
function ObjectSchema(target: AnyConstructor): void;

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

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 a schemaObject or schemaArray field.

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" }
  ]
}

Call Signature ​

sincev5.9.0
ts
function ObjectSchema(type: string, options?: ObjectSchemaOptions): (target: AnyConstructor) => void;

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

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 a schemaObject or schemaArray field.

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: AnyConstructor) => 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" }
  ]
}

Call Signature ​

sincev5.9.0
ts
function ObjectSchema(options: ObjectSchemaOptions): (target: AnyConstructor) => void;

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

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 a schemaObject or schemaArray field.

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: AnyConstructor) => 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" }
  ]
}

Released under the MIT License.