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

Decorator schemaArray() sincev5.9.0

ts
function schemaArray(options): (target, key) => void;

Defined in: fields/schema-array.ts:132

Decorator

Marks a property as a SchemaArrayField — an array of embedded objects whose shape is described by an ObjectSchema.

This is not a relationship. @hasMany / CollectionField point at other resources by identity. A schema-array stores the objects inline on the parent; its elements have no identity of their own.

For an array of primitives with no schema, use array instead.

Parameters

options

SchemaArrayOptions

Returns

(target, key) => void

Example

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

@Resource
export class Post {
  @field declare title: string;
  @schemaArray({ type: 'address', key: '@index', defaultValue: true })
  declare locations: Address[];
}
json
[
  {
    "kind": "schema-array",
    "name": "locations",
    "type": "address",
    "options": { "key": "@index", "defaultValue": true }
  }
]

Released under the MIT License.