UNPKG

1.31 kBJavaScriptView Raw
1"use strict";
2var __assign = (this && this.__assign) || function () {
3 __assign = Object.assign || function(t) {
4 for (var s, i = 1, n = arguments.length; i < n; i++) {
5 s = arguments[i];
6 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7 t[p] = s[p];
8 }
9 return t;
10 };
11 return __assign.apply(this, arguments);
12};
13Object.defineProperty(exports, "__esModule", { value: true });
14exports.ManyToManyJoin = void 0;
15var type_graphql_1 = require("type-graphql");
16var typeorm_1 = require("typeorm");
17var utils_1 = require("../utils");
18// Note: for many to many relationships, you need to set one item as the "JoinTable"
19// therefore, we have 2 separate decorators. Just make sure to add one to one table and
20// One to the other in the relationship
21function ManyToManyJoin(parentType, joinFunc, options) {
22 if (options === void 0) { options = {}; }
23 var factories = [
24 typeorm_1.JoinTable(),
25 type_graphql_1.Field(function () { return [parentType()]; }, __assign({ nullable: true }, options)),
26 typeorm_1.ManyToMany(parentType, joinFunc, options)
27 ];
28 return utils_1.composeMethodDecorators.apply(void 0, factories);
29}
30exports.ManyToManyJoin = ManyToManyJoin;
31//# sourceMappingURL=ManyToManyJoin.js.map
\No newline at end of file