UNPKG

978 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.BelongsToMany = void 0;
4const belongs_to_many_association_1 = require("./belongs-to-many-association");
5const association_service_1 = require("../shared/association-service");
6function BelongsToMany(associatedClassGetter, throughOrOptions, foreignKey, otherKey) {
7 return (target, propertyName) => {
8 let options = { foreignKey, otherKey };
9 if (typeof throughOrOptions === 'string' || typeof throughOrOptions === 'function') {
10 options.through = throughOrOptions;
11 }
12 else {
13 options = Object.assign({}, throughOrOptions);
14 }
15 if (!options.as)
16 options.as = propertyName;
17 (0, association_service_1.addAssociation)(target, new belongs_to_many_association_1.BelongsToManyAssociation(associatedClassGetter, options));
18 };
19}
20exports.BelongsToMany = BelongsToMany;
21//# sourceMappingURL=belongs-to-many.js.map
\No newline at end of file