Skip to content
module@warp-drive/schema-dsl
ts
function belongsTo(options): (target, key) => void;

Defined in: fields/belongs-to.ts:98

Decorator

CAUTION

This decorator is LEGACY, and only valid on resources decorated with @Resource({ legacy: true }).

Marks a property as a LegacyBelongsToField for use with @warp-drive/legacy/model.

Parameters

options

BelongsToOptions

Returns

(target, key) => void

Example

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

@Resource({ legacy: true })
export class Comment {
  @belongsTo({ type: 'post', inverse: 'comments', async: true })
  declare post: unknown;
}
json
[
  {
    "kind": "belongsTo",
    "name": "post",
    "type": "post",
    "options": { "async": true, "inverse": "comments" }
  }
]

Since

5.9.0

Released under the MIT License.