Skip to content

VirtualRef

@tsed/mongoose

Usage

typescript
import { VirtualRef } from "@tsed/mongoose";

See /packages/orm/mongoose/src/types/decorators/virtualRef.ts.

Overview

ts
function VirtualRef(ref: string, foreignField: string): Function;
export function VirtualRef(options: MongooseVirtualRefOptions): Function;
export function VirtualRef(options: string | MongooseVirtualRefOptions, foreignField?: string): Function;
export type VirtualRef<T> = T | null;

Description

Define a property as mongoose virtual reference to other Model (decorated with @Model).

WARNING

To avoid circular dependencies, do not use the virtual reference model in anything except a type declaration. Using the virtual reference model will prevent typescript transpiler from stripping away the import statement and cause a circular import in node.

Released under the MIT License.