@mikro-orm/core
Version:
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.
17 lines (16 loc) • 901 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ManyToMany = ManyToMany;
const metadata_1 = require("../metadata");
const utils_1 = require("../utils");
const enums_1 = require("../enums");
function ManyToMany(entity, mappedBy, options = {}) {
return function (target, propertyName) {
options = utils_1.Utils.processDecoratorParameters({ entity, mappedBy, options });
const meta = metadata_1.MetadataStorage.getMetadataFromDecorator(target.constructor);
metadata_1.MetadataValidator.validateSingleDecorator(meta, propertyName, enums_1.ReferenceKind.MANY_TO_MANY);
const property = { name: propertyName, kind: enums_1.ReferenceKind.MANY_TO_MANY };
meta.properties[propertyName] = Object.assign(meta.properties[propertyName] ?? {}, property, options);
return utils_1.Utils.propertyDecoratorReturnValue();
};
}