/** * @packageDocumentation * @module Decorators */ import { JsonBackReferenceDecorator } from '../@types'; /** * Decorator used to indicate that associated property is part of two-way linkage between fields; * and that its role is "child" (or "back") link. Value type of the property must be a Class: * it can not be an `Iterable` or a `Map`. * Linkage is handled such that the property decorated with this decorator is not serialized; * and during deserialization, its value is set to instance that has * the "managed" (forward) link (see {@link JsonManagedReference}). * * All references have logical name to allow handling multiple linkages; * typical case would be that where nodes have both parent/child and sibling linkages. * If so, pairs of references should be named differently. * It is an error for a class to have multiple back references with same name, * even if types pointed are different. * * @example * ```typescript * class User { * @JsonProperty() @JsonClassType({type: () => [Number]}) * id: number; * @JsonProperty() @JsonClassType({type: () => [String]}) * email: string; * @JsonProperty() @JsonClassType({type: () => [String]}) * firstname: string; * @JsonProperty() @JsonClassType({type: () => [String]}) * lastname: string; * * @JsonProperty() * @JsonClassType({type: () => [Array, [Item]]}) * @JsonManagedReference() * items: Item[] = []; * } * * class Item { * @JsonProperty() @JsonClassType({type: () => [Number]}) * id: number; * @JsonProperty() @JsonClassType({type: () => [String]}) * name: string; * * @JsonProperty() * @JsonClassType({type: () => [User]}) * @JsonBackReference() * owner: User; * } * ``` */ export declare const JsonBackReference: JsonBackReferenceDecorator;