{"version":3,"sources":["../../src/decorator/tree/TreeParent.ts"],"names":[],"mappings":";;AAAA,4BAA8C;AAG9C;;;GAGG;AACH,SAAgB,UAAU;IACtB,OAAO,UAAU,MAAc,EAAE,YAAoB;QAEjD,4CAA4C;QAC5C,IAAM,aAAa,GAAG,OAAO,IAAK,OAAe,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrI,IAAM,MAAM,GAAG,CAAC,aAAa,IAAI,OAAO,aAAa,CAAC,IAAI,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,IAAI,KAAK,CAAC;QAEpI,0BAAsB,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;YACpC,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,MAAM,EAAE,MAAM;YACd,YAAY,EAAE,aAAa;YAC3B,IAAI,EAAE,cAAM,OAAA,MAAM,CAAC,WAAW,EAAlB,CAAkB;YAC9B,OAAO,EAAE,EAAE;SACU,CAAC,CAAC;IAC/B,CAAC,CAAC;AACN,CAAC;AAjBD,gCAiBC","file":"TreeParent.js","sourcesContent":["import {getMetadataArgsStorage} from \"../../\";\nimport {RelationMetadataArgs} from \"../../metadata-args/RelationMetadataArgs\";\n\n/**\n * Marks a entity property as a parent of the tree.\n * \"Tree parent\" indicates who owns (is a parent) of this entity in tree structure.\n */\nexport function TreeParent(): Function {\n return function (object: Object, propertyName: string) {\n\n // now try to determine it its lazy relation\n const reflectedType = Reflect && (Reflect as any).getMetadata ? Reflect.getMetadata(\"design:type\", object, propertyName) : undefined;\n const isLazy = (reflectedType && typeof reflectedType.name === \"string\" && reflectedType.name.toLowerCase() === \"promise\") || false;\n\n getMetadataArgsStorage().relations.push({\n isTreeParent: true,\n target: object.constructor,\n propertyName: propertyName,\n isLazy: isLazy,\n relationType: \"many-to-one\",\n type: () => object.constructor,\n options: {}\n } as RelationMetadataArgs);\n };\n}\n"],"sourceRoot":"../.."}
|