@codemask-labs/nestjs-mongodb
Version:
Nestjs Mongodb Module
31 lines • 1.21 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Column = void 0;
const constants_1 = require("../lib/constants");
const metadata_1 = require("../lib/metadata");
const Column = (options) => (target, propertyKey) => {
const type = Reflect.getMetadata('design:type', target, propertyKey);
if (type === Array && !options?.type && !options?.enum) {
const message = [
`Unknown type for '${propertyKey}' in [class ${target.constructor.name}].`,
`Please provide explicit type at @Column({ type: ... }) or @Column({ enum: ... }).`
].join('\r\n');
throw new Error(message);
}
metadata_1.Metadata.mergeDeep(target.constructor, constants_1.ENTITY_METADATA, {
entityColumns: [
{
propertyKey,
type: options?.type ?? options?.enum ?? type,
parent: target.constructor,
options: {
...options,
array: type === Array || options?.array,
required: options?.required ?? true
}
}
]
});
};
exports.Column = Column;
//# sourceMappingURL=column.js.map
;