Skip to main content
Module

x/mandarinets/main-core/reflectMetadata.ts>Reflect.defineMetadata

Mandarine.TS is a typescript, decorator-driven framework that allows you to create server-side applications. Mandarine.TS provides a range of built-in solutions such as Dependency Injection, Components, ORM and more. Under its umbrella, Mandarine.TS has 4 modules: Core, Data, Security and MVC, these modules will offer you the requirements to build a Mandarine-powered application.
Latest
function Reflect.defineMetadata
import { Reflect } from "https://deno.land/x/mandarinets@v2.3.2/main-core/reflectMetadata.ts";
const { defineMetadata } = Reflect;

Define a unique metadata entry on the target.

Examples

class Example { }

// constructor Reflect.defineMetadata("custom:annotation", options, Example);

// decorator factory as metadata-producing annotation.
function MyAnnotation(options): ClassDecorator {
    return target => Reflect.defineMetadata("custom:annotation", options, target);
}

Parameters

metadataKey: any

A key used to store and retrieve metadata.

metadataValue: any

A value that contains attached metadata.

target: any

The target object on which to define metadata.

Define a unique metadata entry on the target.

Examples

class Example { // property declarations are not part of ES6, though they are valid in TypeScript: // static staticProperty; // property;

static staticMethod(p) { } method(p) { } }

// property (on constructor)
Reflect.defineMetadata("custom:annotation", Number, Example, "staticProperty");

// property (on prototype)
Reflect.defineMetadata("custom:annotation", Number, Example.prototype, "property");

// method (on constructor)
Reflect.defineMetadata("custom:annotation", Number, Example, "staticMethod");

// method (on prototype)
Reflect.defineMetadata("custom:annotation", Number, Example.prototype, "method");

// decorator factory as metadata-producing annotation.
function MyAnnotation(options): PropertyDecorator {
    return (target, key) => Reflect.defineMetadata("custom:annotation", options, target, key);
}

Parameters

metadataKey: any

A key used to store and retrieve metadata.

metadataValue: any

A value that contains attached metadata.

target: any

The target object on which to define metadata.

propertyKey: string | symbol

The property key for the target.