{"version":3,"sources":["../browser/src/metadata/RelationCountMetadata.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH;IAyCI,wEAAwE;IACxE,cAAc;IACd,wEAAwE;IAExE,+BAAY,OAGX;QACG,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;QAC9C,IAAI,CAAC,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QACnD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAChC,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC;IAChE,CAAC;IAED,wEAAwE;IACxE,yBAAyB;IACzB,wEAAwE;IAExE;;;OAGG;IACH,qCAAK,GAAL;QACI,IAAM,YAAY,GAAG,IAAI,CAAC,qBAAqB,YAAY,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC;QACjK,IAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,4BAA4B,CAAC,YAAY,CAAC,CAAC;QAChF,IAAI,CAAC,QAAQ;YACT,MAAM,IAAI,KAAK,CAAC,0BAAwB,YAAY,6DAA0D,CAAC,CAAC;QAEpH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;IAEL,4BAAC;AAAD,CA1EA,AA0EC,IAAA","file":"RelationCountMetadata.js","sourcesContent":["import {RelationCountMetadataArgs} from \"../metadata-args/RelationCountMetadataArgs\";\nimport {EntityMetadata} from \"./EntityMetadata\";\nimport {RelationMetadata} from \"./RelationMetadata\";\nimport {SelectQueryBuilder} from \"../query-builder/SelectQueryBuilder\";\n\n/**\n * Contains all information about entity's relation count.\n */\nexport class RelationCountMetadata {\n\n // ---------------------------------------------------------------------\n // Public Properties\n // ---------------------------------------------------------------------\n\n /**\n * Entity metadata where this column metadata is.\n */\n entityMetadata: EntityMetadata;\n\n /**\n * Relation which needs to be counted.\n */\n relation: RelationMetadata;\n\n /**\n * Relation name which need to count.\n */\n relationNameOrFactory: string|((object: any) => any);\n\n /**\n * Target class to which metadata is applied.\n */\n target: Function|string;\n\n /**\n * Target's property name to which this metadata is applied.\n */\n propertyName: string;\n\n /**\n * Alias of the joined (destination) table.\n */\n alias?: string;\n\n /**\n * Extra condition applied to \"ON\" section of join.\n */\n queryBuilderFactory?: (qb: SelectQueryBuilder<any>) => SelectQueryBuilder<any>;\n\n // ---------------------------------------------------------------------\n // Constructor\n // ---------------------------------------------------------------------\n\n constructor(options: {\n entityMetadata: EntityMetadata,\n args: RelationCountMetadataArgs\n }) {\n this.entityMetadata = options.entityMetadata;\n this.target = options.args.target;\n this.propertyName = options.args.propertyName;\n this.relationNameOrFactory = options.args.relation;\n this.alias = options.args.alias;\n this.queryBuilderFactory = options.args.queryBuilderFactory;\n }\n\n // ---------------------------------------------------------------------\n // Public Builder Methods\n // ---------------------------------------------------------------------\n\n /**\n * Builds some depend relation count metadata properties.\n * This builder method should be used only after entity metadata, its properties map and all relations are build.\n */\n build() {\n const propertyPath = this.relationNameOrFactory instanceof Function ? this.relationNameOrFactory(this.entityMetadata.propertiesMap) : this.relationNameOrFactory;\n const relation = this.entityMetadata.findRelationWithPropertyPath(propertyPath);\n if (!relation)\n throw new Error(`Cannot find relation ${propertyPath}. Wrong relation specified for @RelationCount decorator.`);\n\n this.relation = relation;\n }\n\n}"],"sourceRoot":".."}
|