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

Decorator object() ​

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

Call Signature ​

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

Defined in: fields/object.ts:66

Decorator

Marks a property as an ObjectField — an object whose keys point to primitive values with no well-defined shape. For objects with a well-defined shape, use schemaObject with an ObjectSchema instead.

Parameters ​

target ​

object

key ​

string

Returns ​

void

Example ​

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

@Resource
export class User {
  @field declare name: string;
  @object declare metadata: Record<string, unknown>;
}
json
[
  { "kind": "object", "name": "metadata" }
]

Call Signature ​

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

Defined in: fields/object.ts:67

Decorator

Marks a property as an ObjectField — an object whose keys point to primitive values with no well-defined shape. For objects with a well-defined shape, use schemaObject with an ObjectSchema instead.

Parameters ​

options ​

ObjectFieldOptions

Returns ​

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

Example ​

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

@Resource
export class User {
  @field declare name: string;
  @object declare metadata: Record<string, unknown>;
}
json
[
  { "kind": "object", "name": "metadata" }
]

Released under the MIT License.