{"version":3,"sources":["../../src/decorator/tree/TreeChildren.ts"],"names":[],"mappings":";;AAAA,4BAA+D;AAG/D;;;GAGG;AACH,SAAgB,YAAY,CAAC,OAA8D;IACvF,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,IAAI,CAAC,OAAO;YAAE,OAAO,GAAG,EAAqB,CAAC;QAE9C,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,qCAAqC;QACrC,0BAAsB,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;YACpC,cAAc,EAAE,IAAI;YACpB,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,OAAO;SACK,CAAC,CAAC;IAC/B,CAAC,CAAC;AACN,CAAC;AAnBD,oCAmBC","file":"TreeChildren.js","sourcesContent":["import {getMetadataArgsStorage, RelationOptions} from \"../../\";\nimport {RelationMetadataArgs} from \"../../metadata-args/RelationMetadataArgs\";\n\n/**\n * Marks a entity property as a children of the tree.\n * \"Tree children\" will contain all children (bind) of this entity.\n */\nexport function TreeChildren(options?: { cascade?: boolean|(\"insert\"|\"update\"|\"remove\")[] }): Function {\n return function (object: Object, propertyName: string) {\n if (!options) options = {} as RelationOptions;\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 // add one-to-many relation for this \n getMetadataArgsStorage().relations.push({\n isTreeChildren: true,\n target: object.constructor,\n propertyName: propertyName,\n isLazy: isLazy,\n relationType: \"one-to-many\",\n type: () => object.constructor,\n options: options\n } as RelationMetadataArgs);\n };\n}\n"],"sourceRoot":"../.."}
|