UNPKG

mongo-ts-struct

Version:

Mongoose wrapper for Typescript supports

23 lines 988 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const helpers_1 = require("../../../helpers"); /** * @description * class method, decorated with '@Static', will be handled as a static model method, * 'this' key word will refer to the Model itself, not a specific document. * @warn * using 'this' at compilation time is not reflect the context of the method at run-time. */ function Static() { return (targetPrototype, propertyName, propertyDesciptor) => { if (!helpers_1.MetadataAgent.has(targetPrototype, 'isProcessed')) { // take the actual method (decorated by @Static) const method = targetPrototype[propertyName]; // insert the method to '$metadata.functions.statics' helpers_1.MetadataAgent.set(targetPrototype, [`functions.statics.${propertyName}`, method]); } return propertyDesciptor; }; } exports.Static = Static; //# sourceMappingURL=static.js.map