UNPKG

@dazejs/framework

Version:

Daze.js - A powerful web framework for Node.js

106 lines 4.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UpdateTimestampColumn = exports.CreateTimestampColumn = exports.SoftDeleteColumn = exports.AutoIncrementPrimaryColumn = exports.PrimaryColumn = exports.CustomColumn = exports.Column = void 0; const Column = function (type = 'varchar', length = 255) { return function (target, propertyKey) { var _a; if (typeof propertyKey !== 'string') return; const columns = (_a = Reflect.getMetadata('columns', target.constructor)) !== null && _a !== void 0 ? _a : new Map(); columns.set(propertyKey, { type, length, }); Reflect.defineMetadata('columns', columns, target.constructor); }; }; exports.Column = Column; const CustomColumn = function () { return function (target, propertyKey) { var _a; if (typeof propertyKey !== 'string') return; const columns = (_a = Reflect.getMetadata('customColumns', target.constructor)) !== null && _a !== void 0 ? _a : []; columns.push(propertyKey); Reflect.defineMetadata('customColumns', columns, target.constructor); }; }; exports.CustomColumn = CustomColumn; const PrimaryColumn = function (type = 'int', length = 11) { return function (target, propertyKey) { var _a; if (typeof propertyKey !== 'string') return; const columns = (_a = Reflect.getMetadata('columns', target.constructor)) !== null && _a !== void 0 ? _a : new Map(); columns.set(propertyKey, { type, length, }); Reflect.defineMetadata('columns', columns, target.constructor); Reflect.defineMetadata('primaryKey', propertyKey, target.constructor); Reflect.defineMetadata('incrementing', false, target.constructor); }; }; exports.PrimaryColumn = PrimaryColumn; const AutoIncrementPrimaryColumn = function (type = 'int', length = 11) { return function (target, propertyKey) { var _a; if (typeof propertyKey !== 'string') return; const columns = (_a = Reflect.getMetadata('columns', target.constructor)) !== null && _a !== void 0 ? _a : new Map(); columns.set(propertyKey, { type, length, }); Reflect.defineMetadata('columns', columns, target.constructor); Reflect.defineMetadata('primaryKey', propertyKey, target.constructor); Reflect.defineMetadata('incrementing', true, target.constructor); }; }; exports.AutoIncrementPrimaryColumn = AutoIncrementPrimaryColumn; const SoftDeleteColumn = function (type = 'int', length = 11) { return function (target, propertyKey) { var _a; if (typeof propertyKey !== 'string') return; const columns = (_a = Reflect.getMetadata('columns', target.constructor)) !== null && _a !== void 0 ? _a : new Map(); columns.set(propertyKey, { type, length, }); Reflect.defineMetadata('columns', columns, target.constructor); Reflect.defineMetadata('softDeleteKey', propertyKey, target.constructor); }; }; exports.SoftDeleteColumn = SoftDeleteColumn; const CreateTimestampColumn = function (type = 'int', length = 11) { return function (target, propertyKey) { var _a; if (typeof propertyKey !== 'string') return; const columns = (_a = Reflect.getMetadata('columns', target.constructor)) !== null && _a !== void 0 ? _a : new Map(); columns.set(propertyKey, { type, length, }); Reflect.defineMetadata('columns', columns, target.constructor); Reflect.defineMetadata('createTimestampKey', propertyKey, target.constructor); }; }; exports.CreateTimestampColumn = CreateTimestampColumn; const UpdateTimestampColumn = function (type = 'int', length = 11) { return function (target, propertyKey) { var _a; if (typeof propertyKey !== 'string') return; const columns = (_a = Reflect.getMetadata('columns', target.constructor)) !== null && _a !== void 0 ? _a : new Map(); columns.set(propertyKey, { type, length, }); Reflect.defineMetadata('columns', columns, target.constructor); Reflect.defineMetadata('updateTimestampKey', propertyKey, target.constructor); }; }; exports.UpdateTimestampColumn = UpdateTimestampColumn; //# sourceMappingURL=column.js.map