typeorm 0.3.15-dev.115059d → 0.3.15-dev.f1c5662

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/README.md +1 -1
  2. package/browser/cache/DbQueryResultCache.d.ts +1 -1
  3. package/browser/cache/DbQueryResultCache.js +1 -1
  4. package/browser/cache/DbQueryResultCache.js.map +1 -1
  5. package/browser/cache/QueryResultCacheOptions.d.ts +2 -2
  6. package/browser/cache/QueryResultCacheOptions.js.map +1 -1
  7. package/browser/cache/RedisQueryResultCache.d.ts +1 -1
  8. package/browser/cache/RedisQueryResultCache.js +1 -1
  9. package/browser/cache/RedisQueryResultCache.js.map +1 -1
  10. package/browser/data-source/DataSource.js +1 -2
  11. package/browser/data-source/DataSource.js.map +1 -1
  12. package/browser/driver/mongodb/MongoDriver.js +12 -19
  13. package/browser/driver/mongodb/MongoDriver.js.map +1 -1
  14. package/browser/driver/mongodb/MongoQueryRunner.d.ts +34 -78
  15. package/browser/driver/mongodb/MongoQueryRunner.js +43 -74
  16. package/browser/driver/mongodb/MongoQueryRunner.js.map +1 -1
  17. package/browser/driver/mongodb/bson.typings.d.ts +1084 -0
  18. package/browser/driver/mongodb/bson.typings.js +3 -0
  19. package/browser/driver/mongodb/bson.typings.js.map +1 -0
  20. package/browser/driver/mongodb/typings.d.ts +4882 -4718
  21. package/browser/driver/mongodb/typings.js +23 -1
  22. package/browser/driver/mongodb/typings.js.map +1 -1
  23. package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js +6 -10
  24. package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
  25. package/browser/entity-manager/EntityManager.d.ts +6 -6
  26. package/browser/entity-manager/EntityManager.js.map +1 -1
  27. package/browser/entity-manager/MongoEntityManager.d.ts +46 -92
  28. package/browser/entity-manager/MongoEntityManager.js +66 -133
  29. package/browser/entity-manager/MongoEntityManager.js.map +1 -1
  30. package/browser/entity-schema/EntitySchemaColumnOptions.d.ts +1 -1
  31. package/browser/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
  32. package/browser/find-options/FindOptionsOrder.d.ts +2 -2
  33. package/browser/find-options/FindOptionsOrder.js.map +1 -1
  34. package/browser/find-options/FindOptionsRelations.d.ts +2 -2
  35. package/browser/find-options/FindOptionsRelations.js.map +1 -1
  36. package/browser/find-options/FindOptionsSelect.d.ts +2 -2
  37. package/browser/find-options/FindOptionsSelect.js.map +1 -1
  38. package/browser/find-options/FindOptionsWhere.d.ts +2 -2
  39. package/browser/find-options/FindOptionsWhere.js.map +1 -1
  40. package/browser/metadata-builder/RelationJoinColumnBuilder.d.ts +1 -1
  41. package/browser/metadata-builder/RelationJoinColumnBuilder.js +18 -20
  42. package/browser/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
  43. package/browser/migration/MigrationExecutor.js +2 -4
  44. package/browser/migration/MigrationExecutor.js.map +1 -1
  45. package/browser/query-builder/SelectQueryBuilder.d.ts +1 -1
  46. package/browser/query-builder/SelectQueryBuilder.js +3 -2
  47. package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
  48. package/browser/query-builder/transformer/DocumentToEntityTransformer.js +13 -6
  49. package/browser/query-builder/transformer/DocumentToEntityTransformer.js.map +1 -1
  50. package/browser/repository/BaseEntity.d.ts +4 -4
  51. package/browser/repository/BaseEntity.js.map +1 -1
  52. package/browser/repository/EntityId.d.ts +2 -2
  53. package/browser/repository/EntityId.js.map +1 -1
  54. package/browser/repository/MongoRepository.d.ts +30 -72
  55. package/browser/repository/MongoRepository.js +1 -38
  56. package/browser/repository/MongoRepository.js.map +1 -1
  57. package/browser/repository/Repository.d.ts +6 -6
  58. package/browser/repository/Repository.js.map +1 -1
  59. package/browser/schema-builder/MongoSchemaBuilder.js.map +1 -1
  60. package/browser/schema-builder/RdbmsSchemaBuilder.js +1 -1
  61. package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
  62. package/cache/DbQueryResultCache.d.ts +1 -1
  63. package/cache/DbQueryResultCache.js +1 -1
  64. package/cache/DbQueryResultCache.js.map +1 -1
  65. package/cache/QueryResultCacheOptions.d.ts +2 -2
  66. package/cache/QueryResultCacheOptions.js.map +1 -1
  67. package/cache/RedisQueryResultCache.d.ts +1 -1
  68. package/cache/RedisQueryResultCache.js +1 -1
  69. package/cache/RedisQueryResultCache.js.map +1 -1
  70. package/commands/InitCommand.js +6 -4
  71. package/commands/InitCommand.js.map +1 -1
  72. package/data-source/DataSource.js +7 -8
  73. package/data-source/DataSource.js.map +1 -1
  74. package/driver/mongodb/MongoDriver.js +12 -19
  75. package/driver/mongodb/MongoDriver.js.map +1 -1
  76. package/driver/mongodb/MongoQueryRunner.d.ts +34 -78
  77. package/driver/mongodb/MongoQueryRunner.js +43 -74
  78. package/driver/mongodb/MongoQueryRunner.js.map +1 -1
  79. package/driver/mongodb/bson.typings.d.ts +1084 -0
  80. package/driver/mongodb/bson.typings.js +5 -0
  81. package/driver/mongodb/bson.typings.js.map +1 -0
  82. package/driver/mongodb/typings.d.ts +4882 -4718
  83. package/driver/mongodb/typings.js +19 -0
  84. package/driver/mongodb/typings.js.map +1 -1
  85. package/driver/sqlite-abstract/AbstractSqliteDriver.js +6 -10
  86. package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
  87. package/entity-manager/EntityManager.d.ts +6 -6
  88. package/entity-manager/EntityManager.js.map +1 -1
  89. package/entity-manager/MongoEntityManager.d.ts +46 -92
  90. package/entity-manager/MongoEntityManager.js +66 -133
  91. package/entity-manager/MongoEntityManager.js.map +1 -1
  92. package/entity-schema/EntitySchemaColumnOptions.d.ts +1 -1
  93. package/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
  94. package/find-options/FindOptionsOrder.d.ts +2 -2
  95. package/find-options/FindOptionsOrder.js.map +1 -1
  96. package/find-options/FindOptionsRelations.d.ts +2 -2
  97. package/find-options/FindOptionsRelations.js.map +1 -1
  98. package/find-options/FindOptionsSelect.d.ts +2 -2
  99. package/find-options/FindOptionsSelect.js.map +1 -1
  100. package/find-options/FindOptionsWhere.d.ts +2 -2
  101. package/find-options/FindOptionsWhere.js.map +1 -1
  102. package/index.mjs +34 -0
  103. package/metadata-builder/RelationJoinColumnBuilder.d.ts +1 -1
  104. package/metadata-builder/RelationJoinColumnBuilder.js +18 -20
  105. package/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
  106. package/migration/MigrationExecutor.js +2 -4
  107. package/migration/MigrationExecutor.js.map +1 -1
  108. package/package.json +1 -1
  109. package/query-builder/SelectQueryBuilder.d.ts +1 -1
  110. package/query-builder/SelectQueryBuilder.js +3 -2
  111. package/query-builder/SelectQueryBuilder.js.map +1 -1
  112. package/query-builder/transformer/DocumentToEntityTransformer.js +13 -6
  113. package/query-builder/transformer/DocumentToEntityTransformer.js.map +1 -1
  114. package/repository/BaseEntity.d.ts +4 -4
  115. package/repository/BaseEntity.js.map +1 -1
  116. package/repository/EntityId.d.ts +2 -2
  117. package/repository/EntityId.js.map +1 -1
  118. package/repository/MongoRepository.d.ts +30 -72
  119. package/repository/MongoRepository.js +1 -38
  120. package/repository/MongoRepository.js.map +1 -1
  121. package/repository/Repository.d.ts +6 -6
  122. package/repository/Repository.js.map +1 -1
  123. package/schema-builder/MongoSchemaBuilder.js.map +1 -1
  124. package/schema-builder/RdbmsSchemaBuilder.js +1 -1
  125. package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
@@ -28,14 +28,21 @@ class DocumentToEntityTransformer {
28
28
  });
29
29
  let hasData = false;
30
30
  // handle _id property the special way
31
- if (metadata.objectIdColumn &&
32
- document[metadata.objectIdColumn.databaseNameWithoutPrefixes]) {
31
+ if (metadata.objectIdColumn) {
33
32
  // todo: we can't use driver in this class
34
33
  // do we really need prepare hydrated value here? If no then no problem. If yes then think maybe prepareHydratedValue process should be extracted out of driver class?
35
- // entity[metadata.objectIdColumn.propertyName] = this.driver.prepareHydratedValue(document[metadata.objectIdColumn.name"], metadata.objectIdColumn);
36
- entity[metadata.objectIdColumn.propertyName] =
37
- document[metadata.objectIdColumn.databaseNameWithoutPrefixes];
38
- hasData = true;
34
+ // entity[metadata.ObjectIdColumn.propertyName] = this.driver.prepareHydratedValue(document[metadata.ObjectIdColumn.name"], metadata.ObjectIdColumn);
35
+ const { databaseNameWithoutPrefixes, propertyName } = metadata.objectIdColumn;
36
+ const documentIdWithoutPrefixes = document[databaseNameWithoutPrefixes];
37
+ const documentIdWithPropertyName = document[propertyName];
38
+ if (documentIdWithoutPrefixes) {
39
+ entity[propertyName] = documentIdWithoutPrefixes;
40
+ hasData = true;
41
+ }
42
+ else if (documentIdWithPropertyName) {
43
+ entity[propertyName] = documentIdWithPropertyName;
44
+ hasData = true;
45
+ }
39
46
  }
40
47
  // add special columns that contains relation ids
41
48
  if (this.enableRelationIdValues) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/query-builder/transformer/DocumentToEntityTransformer.ts"],"names":[],"mappings":";;;AAIA;;;GAGG;AACH,MAAa,2BAA2B;IACpC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E;IACI,kCAAkC;IAClC,uCAAuC;IACvC,wDAAwD;IAChD,yBAAkC,KAAK;QAAvC,2BAAsB,GAAtB,sBAAsB,CAAiB;IAChD,CAAC;IAEJ,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,YAAY,CAAC,SAA0B,EAAE,QAAwB;QAC7D,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;IAC1E,CAAC;IAED,SAAS,CAAC,QAAa,EAAE,QAAwB;QAC7C,MAAM,MAAM,GAAQ,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE;YAC3C,gBAAgB,EAAE,IAAI;SACzB,CAAC,CAAA;QACF,IAAI,OAAO,GAAG,KAAK,CAAA;QAEnB,sCAAsC;QACtC,IACI,QAAQ,CAAC,cAAc;YACvB,Q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AK,SAAS;4BAAE,OAAM;wBAE/B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC;4BAC9B,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC;gCAC5C,gBAAgB,EAAE,IAAI;6BACzB,CAAC,CAAA;wBAEN,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;4BAC9C,KAAK,CAAA;oBACb,CAAC,CAAC,CAAA;oBAEF,4BAA4B,CACxB,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,EAC7B,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EACzB,QAAQ,CAAC,SAAS,CACrB,CAAA;iBACJ;YACL,CAAC,CAAC,CAAA;QACN,CAAC,CAAA;QAED,4BAA4B,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAA;QAElE,iFAAiF;QACjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAgEK;QAEL,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA;IAClC,CAAC;CACJ;AA1ND,kEA0NC","file":"DocumentToEntityTransformer.js","sourcesContent":["import { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { ObjectLiteral } from \"../../common/ObjectLiteral\"\nimport { EmbeddedMetadata } from \"../../metadata/EmbeddedMetadata\"\n\n/**\n * Transforms raw document into entity object.\n * Entity is constructed based on its entity metadata.\n */\nexport class DocumentToEntityTransformer {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n // private selectionMap: AliasMap,\n // private joinMappings: JoinMapping[],\n // private relationCountMetas: RelationCountAttribute[],\n private enableRelationIdValues: boolean = false,\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n transformAll(documents: ObjectLiteral[], metadata: EntityMetadata) {\n return documents.map((document) => this.transform(document, metadata))\n }\n\n transform(document: any, metadata: EntityMetadata) {\n const entity: any = metadata.create(undefined, {\n fromDeserializer: true,\n })\n let hasData = false\n\n // handle _id property the special way\n if (\n metadata.objectIdColumn &&\n document[metadata.objectIdColumn.databaseNameWithoutPrefixes]\n ) {\n // todo: we can't use driver in this class\n // do we really need prepare hydrated value here? If no then no problem. If yes then think maybe prepareHydratedValue process should be extracted out of driver class?\n // entity[metadata.objectIdColumn.propertyName] = this.driver.prepareHydratedValue(document[metadata.objectIdColumn.name\"], metadata.objectIdColumn);\n entity[metadata.objectIdColumn.propertyName] =\n document[metadata.objectIdColumn.databaseNameWithoutPrefixes]\n hasData = true\n }\n\n // add special columns that contains relation ids\n if (this.enableRelationIdValues) {\n metadata.columns\n .filter((column) => !!column.relationMetadata)\n .forEach((column) => {\n const valueInObject =\n document[column.databaseNameWithoutPrefixes]\n if (\n valueInObject !== undefined &&\n valueInObject !== null &&\n column.propertyName\n ) {\n // todo: we can't use driver in this class\n // const value = this.driver.prepareHydratedValue(valueInObject, column);\n entity[column.propertyName] = valueInObject\n hasData = true\n }\n })\n }\n\n /*this.joinMappings\n .filter(joinMapping => joinMapping.parentName === alias.name && !joinMapping.alias.relationOwnerSelection && joinMapping.alias.target)\n .map(joinMapping => {\n const relatedEntities = this.transformRawResultsGroup(rawSqlResults, joinMapping.alias);\n const isResultArray = joinMapping.isMany;\n const result = !isResultArray ? relatedEntities[0] : relatedEntities;\n\n if (result && (!isResultArray || result.length > 0)) {\n entity[joinMapping.propertyName] = result;\n hasData = true;\n }\n });*/\n\n // get value from columns selections and put them into object\n metadata.ownColumns.forEach((column) => {\n const valueInObject = document[column.databaseNameWithoutPrefixes]\n if (\n valueInObject !== undefined &&\n column.propertyName &&\n !column.isVirtual\n ) {\n // const value = this.driver.prepareHydratedValue(valueInObject, column);\n\n entity[column.propertyName] = valueInObject\n hasData = true\n }\n })\n\n const addEmbeddedValuesRecursively = (\n entity: any,\n document: any,\n embeddeds: EmbeddedMetadata[],\n ) => {\n embeddeds.forEach((embedded) => {\n if (!document[embedded.prefix]) return\n\n if (embedded.isArray) {\n entity[embedded.propertyName] = (\n document[embedded.prefix] as any[]\n ).map((subValue: any, index: number) => {\n const newItem = embedded.create({\n fromDeserializer: true,\n })\n embedded.columns.forEach((column) => {\n newItem[column.propertyName] =\n subValue[column.databaseNameWithoutPrefixes]\n })\n addEmbeddedValuesRecursively(\n newItem,\n document[embedded.prefix][index],\n embedded.embeddeds,\n )\n return newItem\n })\n } else {\n if (\n embedded.embeddeds.length &&\n !entity[embedded.propertyName]\n )\n entity[embedded.propertyName] = embedded.create({\n fromDeserializer: true,\n })\n\n embedded.columns.forEach((column) => {\n const value =\n document[embedded.prefix][\n column.databaseNameWithoutPrefixes\n ]\n if (value === undefined) return\n\n if (!entity[embedded.propertyName])\n entity[embedded.propertyName] = embedded.create({\n fromDeserializer: true,\n })\n\n entity[embedded.propertyName][column.propertyName] =\n value\n })\n\n addEmbeddedValuesRecursively(\n entity[embedded.propertyName],\n document[embedded.prefix],\n embedded.embeddeds,\n )\n }\n })\n }\n\n addEmbeddedValuesRecursively(entity, document, metadata.embeddeds)\n\n // if relation is loaded then go into it recursively and transform its values too\n /*metadata.relations.forEach(relation => {\n const relationAlias = this.selectionMap.findSelectionByParent(alias.name, relation.propertyName);\n if (relationAlias) {\n const joinMapping = this.joinMappings.find(joinMapping => joinMapping.type === \"join\" && joinMapping.alias === relationAlias);\n const relatedEntities = this.transformRawResultsGroup(rawSqlResults, relationAlias);\n const isResultArray = relation.isManyToMany || relation.isOneToMany;\n const result = !isResultArray ? relatedEntities[0] : relatedEntities;\n\n if (result) {\n let propertyName = relation.propertyName;\n if (joinMapping) {\n propertyName = joinMapping.propertyName;\n }\n\n if (relation.isLazy) {\n entity[\"__\" + propertyName + \"__\"] = result;\n } else {\n entity[propertyName] = result;\n }\n\n if (!isResultArray || result.length > 0)\n hasData = true;\n }\n }\n\n // if relation has id field then relation id/ids to that field.\n if (relation.isManyToMany) {\n if (relationAlias) {\n const ids: any[] = [];\n const joinMapping = this.joinMappings.find(joinMapping => joinMapping.type === \"relationId\" && joinMapping.alias === relationAlias);\n\n if (relation.idField || joinMapping) {\n const propertyName = joinMapping ? joinMapping.propertyName : relation.idField as string;\n const junctionMetadata = relation.junctionEntityMetadata;\n const columnName = relation.isOwning ? junctionMetadata.columns[1].name : junctionMetadata.columns[0].name;\n\n rawSqlResults.forEach(results => {\n if (relationAlias) {\n const resultsKey = relationAlias.name + \"_\" + columnName;\n const value = this.driver.prepareHydratedValue(results[resultsKey], relation.referencedColumn);\n if (value !== undefined && value !== null)\n ids.push(value);\n }\n });\n\n if (ids && ids.length)\n entity[propertyName] = ids;\n }\n }\n } else if (relation.idField) {\n const relationName = relation.name;\n entity[relation.idField] = this.driver.prepareHydratedValue(rawSqlResults[0][alias.name + \"_\" + relationName], relation.referencedColumn);\n }\n\n // if relation counter\n this.relationCountMetas.forEach(joinMeta => {\n if (joinMeta.alias === relationAlias) {\n // console.log(\"relation count was found for relation: \", relation);\n // joinMeta.entity = entity;\n joinMeta.entities.push({ entity: entity, metadata: metadata });\n // console.log(joinMeta);\n // console.log(\"---------------------\");\n }\n });\n });*/\n\n return hasData ? entity : null\n }\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../../src/query-builder/transformer/DocumentToEntityTransformer.ts"],"names":[],"mappings":";;;AAIA;;;GAGG;AACH,MAAa,2BAA2B;IACpC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E;IACI,kCAAkC;IAClC,uCAAuC;IACvC,wDAAwD;IAChD,yBAAkC,KAAK;QAAvC,2BAAsB,GAAtB,sBAAsB,CAAiB;IAChD,CAAC;IAEJ,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,YAAY,CAAC,SAA0B,EAAE,QAAwB;QAC7D,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EA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;aAgEK;QAEL,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA;IAClC,CAAC;CACJ;AAlOD,kEAkOC","file":"DocumentToEntityTransformer.js","sourcesContent":["import { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { ObjectLiteral } from \"../../common/ObjectLiteral\"\nimport { EmbeddedMetadata } from \"../../metadata/EmbeddedMetadata\"\n\n/**\n * Transforms raw document into entity object.\n * Entity is constructed based on its entity metadata.\n */\nexport class DocumentToEntityTransformer {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n // private selectionMap: AliasMap,\n // private joinMappings: JoinMapping[],\n // private relationCountMetas: RelationCountAttribute[],\n private enableRelationIdValues: boolean = false,\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n transformAll(documents: ObjectLiteral[], metadata: EntityMetadata) {\n return documents.map((document) => this.transform(document, metadata))\n }\n\n transform(document: any, metadata: EntityMetadata) {\n const entity: any = metadata.create(undefined, {\n fromDeserializer: true,\n })\n let hasData = false\n\n // handle _id property the special way\n if (metadata.objectIdColumn) {\n // todo: we can't use driver in this class\n // do we really need prepare hydrated value here? If no then no problem. If yes then think maybe prepareHydratedValue process should be extracted out of driver class?\n // entity[metadata.ObjectIdColumn.propertyName] = this.driver.prepareHydratedValue(document[metadata.ObjectIdColumn.name\"], metadata.ObjectIdColumn);\n const { databaseNameWithoutPrefixes, propertyName } =\n metadata.objectIdColumn\n\n const documentIdWithoutPrefixes =\n document[databaseNameWithoutPrefixes]\n const documentIdWithPropertyName = document[propertyName]\n\n if (documentIdWithoutPrefixes) {\n entity[propertyName] = documentIdWithoutPrefixes\n hasData = true\n } else if (documentIdWithPropertyName) {\n entity[propertyName] = documentIdWithPropertyName\n hasData = true\n }\n }\n\n // add special columns that contains relation ids\n if (this.enableRelationIdValues) {\n metadata.columns\n .filter((column) => !!column.relationMetadata)\n .forEach((column) => {\n const valueInObject =\n document[column.databaseNameWithoutPrefixes]\n if (\n valueInObject !== undefined &&\n valueInObject !== null &&\n column.propertyName\n ) {\n // todo: we can't use driver in this class\n // const value = this.driver.prepareHydratedValue(valueInObject, column);\n entity[column.propertyName] = valueInObject\n hasData = true\n }\n })\n }\n\n /*this.joinMappings\n .filter(joinMapping => joinMapping.parentName === alias.name && !joinMapping.alias.relationOwnerSelection && joinMapping.alias.target)\n .map(joinMapping => {\n const relatedEntities = this.transformRawResultsGroup(rawSqlResults, joinMapping.alias);\n const isResultArray = joinMapping.isMany;\n const result = !isResultArray ? relatedEntities[0] : relatedEntities;\n\n if (result && (!isResultArray || result.length > 0)) {\n entity[joinMapping.propertyName] = result;\n hasData = true;\n }\n });*/\n\n // get value from columns selections and put them into object\n metadata.ownColumns.forEach((column) => {\n const valueInObject = document[column.databaseNameWithoutPrefixes]\n if (\n valueInObject !== undefined &&\n column.propertyName &&\n !column.isVirtual\n ) {\n // const value = this.driver.prepareHydratedValue(valueInObject, column);\n\n entity[column.propertyName] = valueInObject\n hasData = true\n }\n })\n\n const addEmbeddedValuesRecursively = (\n entity: any,\n document: any,\n embeddeds: EmbeddedMetadata[],\n ) => {\n embeddeds.forEach((embedded) => {\n if (!document[embedded.prefix]) return\n\n if (embedded.isArray) {\n entity[embedded.propertyName] = (\n document[embedded.prefix] as any[]\n ).map((subValue: any, index: number) => {\n const newItem = embedded.create({\n fromDeserializer: true,\n })\n embedded.columns.forEach((column) => {\n newItem[column.propertyName] =\n subValue[column.databaseNameWithoutPrefixes]\n })\n addEmbeddedValuesRecursively(\n newItem,\n document[embedded.prefix][index],\n embedded.embeddeds,\n )\n return newItem\n })\n } else {\n if (\n embedded.embeddeds.length &&\n !entity[embedded.propertyName]\n )\n entity[embedded.propertyName] = embedded.create({\n fromDeserializer: true,\n })\n\n embedded.columns.forEach((column) => {\n const value =\n document[embedded.prefix][\n column.databaseNameWithoutPrefixes\n ]\n if (value === undefined) return\n\n if (!entity[embedded.propertyName])\n entity[embedded.propertyName] = embedded.create({\n fromDeserializer: true,\n })\n\n entity[embedded.propertyName][column.propertyName] =\n value\n })\n\n addEmbeddedValuesRecursively(\n entity[embedded.propertyName],\n document[embedded.prefix],\n embedded.embeddeds,\n )\n }\n })\n }\n\n addEmbeddedValuesRecursively(entity, document, metadata.embeddeds)\n\n // if relation is loaded then go into it recursively and transform its values too\n /*metadata.relations.forEach(relation => {\n const relationAlias = this.selectionMap.findSelectionByParent(alias.name, relation.propertyName);\n if (relationAlias) {\n const joinMapping = this.joinMappings.find(joinMapping => joinMapping.type === \"join\" && joinMapping.alias === relationAlias);\n const relatedEntities = this.transformRawResultsGroup(rawSqlResults, relationAlias);\n const isResultArray = relation.isManyToMany || relation.isOneToMany;\n const result = !isResultArray ? relatedEntities[0] : relatedEntities;\n\n if (result) {\n let propertyName = relation.propertyName;\n if (joinMapping) {\n propertyName = joinMapping.propertyName;\n }\n\n if (relation.isLazy) {\n entity[\"__\" + propertyName + \"__\"] = result;\n } else {\n entity[propertyName] = result;\n }\n\n if (!isResultArray || result.length > 0)\n hasData = true;\n }\n }\n\n // if relation has id field then relation id/ids to that field.\n if (relation.isManyToMany) {\n if (relationAlias) {\n const ids: any[] = [];\n const joinMapping = this.joinMappings.find(joinMapping => joinMapping.type === \"relationId\" && joinMapping.alias === relationAlias);\n\n if (relation.idField || joinMapping) {\n const propertyName = joinMapping ? joinMapping.propertyName : relation.idField as string;\n const junctionMetadata = relation.junctionEntityMetadata;\n const columnName = relation.isOwning ? junctionMetadata.columns[1].name : junctionMetadata.columns[0].name;\n\n rawSqlResults.forEach(results => {\n if (relationAlias) {\n const resultsKey = relationAlias.name + \"_\" + columnName;\n const value = this.driver.prepareHydratedValue(results[resultsKey], relation.referencedColumn);\n if (value !== undefined && value !== null)\n ids.push(value);\n }\n });\n\n if (ids && ids.length)\n entity[propertyName] = ids;\n }\n }\n } else if (relation.idField) {\n const relationName = relation.name;\n entity[relation.idField] = this.driver.prepareHydratedValue(rawSqlResults[0][alias.name + \"_\" + relationName], relation.referencedColumn);\n }\n\n // if relation counter\n this.relationCountMetas.forEach(joinMeta => {\n if (joinMeta.alias === relationAlias) {\n // console.log(\"relation count was found for relation: \", relation);\n // joinMeta.entity = entity;\n joinMeta.entities.push({ entity: entity, metadata: metadata });\n // console.log(joinMeta);\n // console.log(\"---------------------\");\n }\n });\n });*/\n\n return hasData ? entity : null\n }\n}\n"],"sourceRoot":"../.."}
@@ -10,7 +10,7 @@ import { SelectQueryBuilder } from "../query-builder/SelectQueryBuilder";
10
10
  import { InsertResult } from "../query-builder/result/InsertResult";
11
11
  import { UpdateResult } from "../query-builder/result/UpdateResult";
12
12
  import { DeleteResult } from "../query-builder/result/DeleteResult";
13
- import { ObjectID } from "../driver/mongodb/typings";
13
+ import { ObjectId } from "../driver/mongodb/typings";
14
14
  import { QueryDeepPartialEntity } from "../query-builder/QueryPartialEntity";
15
15
  import { UpsertOptions } from "./UpsertOptions";
16
16
  import { EntityTarget } from "../common/EntityTarget";
@@ -175,7 +175,7 @@ export declare class BaseEntity {
175
175
  */
176
176
  static update<T extends BaseEntity>(this: {
177
177
  new (): T;
178
- } & typeof BaseEntity, criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindOptionsWhere<T>, partialEntity: QueryDeepPartialEntity<T>): Promise<UpdateResult>;
178
+ } & typeof BaseEntity, criteria: string | string[] | number | number[] | Date | Date[] | ObjectId | ObjectId[] | FindOptionsWhere<T>, partialEntity: QueryDeepPartialEntity<T>): Promise<UpdateResult>;
179
179
  /**
180
180
  * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity
181
181
  * Unlike save method executes a primitive operation without cascades, relations and other operations included.
@@ -192,7 +192,7 @@ export declare class BaseEntity {
192
192
  */
193
193
  static delete<T extends BaseEntity>(this: {
194
194
  new (): T;
195
- } & typeof BaseEntity, criteria: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[] | FindOptionsWhere<T>): Promise<DeleteResult>;
195
+ } & typeof BaseEntity, criteria: string | string[] | number | number[] | Date | Date[] | ObjectId | ObjectId[] | FindOptionsWhere<T>): Promise<DeleteResult>;
196
196
  /**
197
197
  * Counts entities that match given options.
198
198
  */
@@ -293,7 +293,7 @@ export declare class BaseEntity {
293
293
  */
294
294
  static findOneById<T extends BaseEntity>(this: {
295
295
  new (): T;
296
- } & typeof BaseEntity, id: string | number | Date | ObjectID): Promise<T | null>;
296
+ } & typeof BaseEntity, id: string | number | Date | ObjectId): Promise<T | null>;
297
297
  /**
298
298
  * Finds first entity that matches given conditions.
299
299
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/repository/BaseEntity.ts"],"names":[],"mappings":";;;AAaA,qDAAiD;AAMjD;;GAEG;AACH,MAAa,UAAU;IAUnB,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;;OAGG;IACH,KAAK;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,WAAgC,CAAA;QACxD,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACjD,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,OAAqB;QACtB,MAAM,UAAU,GAAG,IAAI,CAAC,WAAgC,CAAA;QACxD,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACzD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAAuB;QAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,WAAgC,CAAA;QACxD,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAkB,CAAA;IAC5E,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAqB;QAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,WAAgC,CAAA;QACxD,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC/D,CAAC;IAED;;O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G;IACH,MAAM,CAAC,WAAW,CAEd,EAAqC;QAErC,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;IAClD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAEhB,OAA0B;QAE1B,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IACzD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,eAAe,CAElB,KAA0B;QAE1B,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;IACzD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAER,KAAa,EACb,UAAkB;QAElB,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IAC3D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK;QAGR,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,KAAK,EAAE,CAAA;IAC1C,CAAC;CACJ;AA1jBD,gCA0jBC","file":"BaseEntity.js","sourcesContent":["import { Repository } from \"./Repository\"\nimport { FindOptionsWhere } from \"../find-options/FindOptionsWhere\"\nimport { DeepPartial } from \"../common/DeepPartial\"\nimport { SaveOptions } from \"./SaveOptions\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\nimport { RemoveOptions } from \"./RemoveOptions\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { DataSource } from \"../data-source\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { InsertResult } from \"../query-builder/result/InsertResult\"\nimport { UpdateResult } from \"../query-builder/result/UpdateResult\"\nimport { DeleteResult } from \"../query-builder/result/DeleteResult\"\nimport { ObjectID } from \"../driver/mongodb/typings\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { QueryDeepPartialEntity } from \"../query-builder/QueryPartialEntity\"\nimport { UpsertOptions } from \"./UpsertOptions\"\nimport { EntityTarget } from \"../common/EntityTarget\"\nimport { PickKeysByType } from \"../common/PickKeysByType\"\n\n/**\n * Base abstract entity for all entities, used in ActiveRecord patterns.\n */\nexport class BaseEntity {\n // -------------------------------------------------------------------------\n // Private Static Properties\n // -------------------------------------------------------------------------\n\n /**\n * DataSource used in all static methods of the BaseEntity.\n */\n private static dataSource: DataSource | null\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(): boolean {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().hasId(this)\n }\n\n /**\n * Saves current entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().save(this, options)\n }\n\n /**\n * Removes current entity from the database.\n */\n remove(options?: RemoveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().remove(this, options) as Promise<this>\n }\n\n /**\n * Records the delete date of current entity.\n */\n softRemove(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().softRemove(this, options)\n }\n\n /**\n * Recovers a given entity in the database.\n */\n recover(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().recover(this, options)\n }\n\n /**\n * Reloads entity data from the database.\n */\n async reload(): Promise<void> {\n const baseEntity = this.constructor as typeof BaseEntity\n const id = baseEntity.getRepository().metadata.getEntityIdMap(this)\n if (!id) {\n throw new Error(\n `Entity doesn't have id-s set, cannot reload entity`,\n )\n }\n const reloadedEntity: BaseEntity = await baseEntity\n .getRepository()\n .findOneByOrFail(id)\n\n ObjectUtils.assign(this, reloadedEntity)\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Sets DataSource to be used by entity.\n */\n static useDataSource(dataSource: DataSource | null) {\n this.dataSource = dataSource\n }\n\n /**\n * Gets current entity's Repository.\n */\n static getRepository<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): Repository<T> {\n const dataSource = (this as typeof BaseEntity).dataSource\n if (!dataSource)\n throw new Error(`DataSource is not set for this entity.`)\n return dataSource.getRepository<T>(this)\n }\n\n /**\n * Returns object that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n static get target(): EntityTarget<any> {\n return this.getRepository().target\n }\n\n /**\n * Checks entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n static hasId(entity: BaseEntity): boolean {\n return this.getRepository().hasId(entity)\n }\n\n /**\n * Gets entity mixed id.\n */\n static getId<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n ): any {\n return this.getRepository<T>().getId(entity)\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n static createQueryBuilder<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n alias?: string,\n ): SelectQueryBuilder<T> {\n return this.getRepository<T>().createQueryBuilder(alias)\n }\n\n /**\n * Creates a new entity instance.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): T\n\n /**\n * Creates a new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLikeArray: DeepPartial<T>[],\n ): T[]\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLike: DeepPartial<T>,\n ): T\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities?: any,\n ) {\n return this.getRepository<T>().create(entityOrEntities)\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n static merge<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n mergeIntoEntity: T,\n ...entityLikes: DeepPartial<T>[]\n ): T {\n return this.getRepository<T>().merge(\n mergeIntoEntity,\n ...entityLikes,\n ) as T\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n *\n * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n static preload<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLike: DeepPartial<T>,\n ): Promise<T | undefined> {\n const thisRepository = this.getRepository<T>()\n return thisRepository.preload(entityLike)\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: DeepPartial<T>[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: DeepPartial<T>,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Saves one or many given entities.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: DeepPartial<T> | DeepPartial<T>[],\n options?: SaveOptions,\n ) {\n return this.getRepository<T>().save(entityOrEntities as any, options)\n }\n\n /**\n * Removes a given entities from the database.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: T[],\n options?: RemoveOptions,\n ): Promise<T[]>\n\n /**\n * Removes a given entity from the database.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n options?: RemoveOptions,\n ): Promise<T>\n\n /**\n * Removes one or many given entities.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: T | T[],\n options?: RemoveOptions,\n ) {\n return this.getRepository<T>().remove(entityOrEntities as any, options)\n }\n\n /**\n * Records the delete date of all given entities.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: T[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Records the delete date of a given entity.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Records the delete date of one or many given entities.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: T | T[],\n options?: SaveOptions,\n ) {\n return this.getRepository<T>().softRemove(\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n */\n static insert<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: QueryDeepPartialEntity<T> | QueryDeepPartialEntity<T>[],\n ): Promise<InsertResult> {\n return this.getRepository<T>().insert(entity)\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n */\n static update<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | FindOptionsWhere<T>,\n partialEntity: QueryDeepPartialEntity<T>,\n ): Promise<UpdateResult> {\n return this.getRepository<T>().update(criteria, partialEntity)\n }\n\n /**\n * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.\n */\n static upsert<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities:\n | QueryDeepPartialEntity<T>\n | QueryDeepPartialEntity<T>[],\n conflictPathsOrOptions: string[] | UpsertOptions<T>,\n ): Promise<InsertResult> {\n return this.getRepository<T>().upsert(\n entityOrEntities,\n conflictPathsOrOptions,\n )\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike remove method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n */\n static delete<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | FindOptionsWhere<T>,\n ): Promise<DeleteResult> {\n return this.getRepository<T>().delete(criteria)\n }\n\n /**\n * Counts entities that match given options.\n */\n static count<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<number> {\n return this.getRepository<T>().count(options)\n }\n\n /**\n * Counts entities that match given WHERE conditions.\n */\n static countBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<number> {\n return this.getRepository<T>().countBy(where)\n }\n\n /**\n * Return the SUM of a column\n */\n static sum<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType<T, number>,\n where: FindOptionsWhere<T>,\n ): Promise<number | null> {\n return this.getRepository<T>().sum(columnName, where)\n }\n\n /**\n * Return the AVG of a column\n */\n static average<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType<T, number>,\n where: FindOptionsWhere<T>,\n ): Promise<number | null> {\n return this.getRepository<T>().average(columnName, where)\n }\n\n /**\n * Return the MIN of a column\n */\n static minimum<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType<T, number>,\n where: FindOptionsWhere<T>,\n ): Promise<number | null> {\n return this.getRepository<T>().minimum(columnName, where)\n }\n\n /**\n * Return the MAX of a column\n */\n static maximum<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType<T, number>,\n where: FindOptionsWhere<T>,\n ): Promise<number | null> {\n return this.getRepository<T>().maximum(columnName, where)\n }\n\n /**\n * Finds entities that match given options.\n */\n static find<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<T[]> {\n return this.getRepository<T>().find(options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n */\n static findBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T[]> {\n return this.getRepository<T>().findBy(where)\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<[T[], number]> {\n return this.getRepository<T>().findAndCount(options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCountBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<[T[], number]> {\n return this.getRepository<T>().findAndCountBy(where)\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n static findByIds<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ids: any[],\n ): Promise<T[]> {\n return this.getRepository<T>().findByIds(ids)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options: FindOneOptions<T>,\n ): Promise<T | null> {\n return this.getRepository<T>().findOne(options)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T | null> {\n return this.getRepository<T>().findOneBy(where)\n }\n\n /**\n * Finds first entity that matches given options.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n static findOneById<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n id: string | number | Date | ObjectID,\n ): Promise<T | null> {\n return this.getRepository<T>().findOneById(id)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options: FindOneOptions<T>,\n ): Promise<T> {\n return this.getRepository<T>().findOneOrFail(options)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneByOrFail<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T> {\n return this.getRepository<T>().findOneByOrFail(where)\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n static query<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n query: string,\n parameters?: any[],\n ): Promise<any> {\n return this.getRepository<T>().query(query, parameters)\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n */\n static clear<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): Promise<void> {\n return this.getRepository<T>().clear()\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/repository/BaseEntity.ts"],"names":[],"mappings":";;;AAaA,qDAAiD;AAMjD;;GAEG;AACH,MAAa,UAAU;IAUnB,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;;OAGG;IACH,KAAK;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,WAAgC,CAAA;QACxD,O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AAI,CAAC,aAAa,EAAK,CAAC,KAAK,EAAE,CAAA;IAC1C,CAAC;CACJ;AA1jBD,gCA0jBC","file":"BaseEntity.js","sourcesContent":["import { Repository } from \"./Repository\"\nimport { FindOptionsWhere } from \"../find-options/FindOptionsWhere\"\nimport { DeepPartial } from \"../common/DeepPartial\"\nimport { SaveOptions } from \"./SaveOptions\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\nimport { RemoveOptions } from \"./RemoveOptions\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { DataSource } from \"../data-source\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { InsertResult } from \"../query-builder/result/InsertResult\"\nimport { UpdateResult } from \"../query-builder/result/UpdateResult\"\nimport { DeleteResult } from \"../query-builder/result/DeleteResult\"\nimport { ObjectId } from \"../driver/mongodb/typings\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { QueryDeepPartialEntity } from \"../query-builder/QueryPartialEntity\"\nimport { UpsertOptions } from \"./UpsertOptions\"\nimport { EntityTarget } from \"../common/EntityTarget\"\nimport { PickKeysByType } from \"../common/PickKeysByType\"\n\n/**\n * Base abstract entity for all entities, used in ActiveRecord patterns.\n */\nexport class BaseEntity {\n // -------------------------------------------------------------------------\n // Private Static Properties\n // -------------------------------------------------------------------------\n\n /**\n * DataSource used in all static methods of the BaseEntity.\n */\n private static dataSource: DataSource | null\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(): boolean {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().hasId(this)\n }\n\n /**\n * Saves current entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().save(this, options)\n }\n\n /**\n * Removes current entity from the database.\n */\n remove(options?: RemoveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().remove(this, options) as Promise<this>\n }\n\n /**\n * Records the delete date of current entity.\n */\n softRemove(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().softRemove(this, options)\n }\n\n /**\n * Recovers a given entity in the database.\n */\n recover(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().recover(this, options)\n }\n\n /**\n * Reloads entity data from the database.\n */\n async reload(): Promise<void> {\n const baseEntity = this.constructor as typeof BaseEntity\n const id = baseEntity.getRepository().metadata.getEntityIdMap(this)\n if (!id) {\n throw new Error(\n `Entity doesn't have id-s set, cannot reload entity`,\n )\n }\n const reloadedEntity: BaseEntity = await baseEntity\n .getRepository()\n .findOneByOrFail(id)\n\n ObjectUtils.assign(this, reloadedEntity)\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Sets DataSource to be used by entity.\n */\n static useDataSource(dataSource: DataSource | null) {\n this.dataSource = dataSource\n }\n\n /**\n * Gets current entity's Repository.\n */\n static getRepository<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): Repository<T> {\n const dataSource = (this as typeof BaseEntity).dataSource\n if (!dataSource)\n throw new Error(`DataSource is not set for this entity.`)\n return dataSource.getRepository<T>(this)\n }\n\n /**\n * Returns object that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n static get target(): EntityTarget<any> {\n return this.getRepository().target\n }\n\n /**\n * Checks entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n static hasId(entity: BaseEntity): boolean {\n return this.getRepository().hasId(entity)\n }\n\n /**\n * Gets entity mixed id.\n */\n static getId<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n ): any {\n return this.getRepository<T>().getId(entity)\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n static createQueryBuilder<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n alias?: string,\n ): SelectQueryBuilder<T> {\n return this.getRepository<T>().createQueryBuilder(alias)\n }\n\n /**\n * Creates a new entity instance.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): T\n\n /**\n * Creates a new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLikeArray: DeepPartial<T>[],\n ): T[]\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLike: DeepPartial<T>,\n ): T\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities?: any,\n ) {\n return this.getRepository<T>().create(entityOrEntities)\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n static merge<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n mergeIntoEntity: T,\n ...entityLikes: DeepPartial<T>[]\n ): T {\n return this.getRepository<T>().merge(\n mergeIntoEntity,\n ...entityLikes,\n ) as T\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n *\n * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n static preload<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLike: DeepPartial<T>,\n ): Promise<T | undefined> {\n const thisRepository = this.getRepository<T>()\n return thisRepository.preload(entityLike)\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: DeepPartial<T>[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: DeepPartial<T>,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Saves one or many given entities.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: DeepPartial<T> | DeepPartial<T>[],\n options?: SaveOptions,\n ) {\n return this.getRepository<T>().save(entityOrEntities as any, options)\n }\n\n /**\n * Removes a given entities from the database.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: T[],\n options?: RemoveOptions,\n ): Promise<T[]>\n\n /**\n * Removes a given entity from the database.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n options?: RemoveOptions,\n ): Promise<T>\n\n /**\n * Removes one or many given entities.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: T | T[],\n options?: RemoveOptions,\n ) {\n return this.getRepository<T>().remove(entityOrEntities as any, options)\n }\n\n /**\n * Records the delete date of all given entities.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: T[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Records the delete date of a given entity.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Records the delete date of one or many given entities.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: T | T[],\n options?: SaveOptions,\n ) {\n return this.getRepository<T>().softRemove(\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n */\n static insert<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: QueryDeepPartialEntity<T> | QueryDeepPartialEntity<T>[],\n ): Promise<InsertResult> {\n return this.getRepository<T>().insert(entity)\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n */\n static update<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectId\n | ObjectId[]\n | FindOptionsWhere<T>,\n partialEntity: QueryDeepPartialEntity<T>,\n ): Promise<UpdateResult> {\n return this.getRepository<T>().update(criteria, partialEntity)\n }\n\n /**\n * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.\n */\n static upsert<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities:\n | QueryDeepPartialEntity<T>\n | QueryDeepPartialEntity<T>[],\n conflictPathsOrOptions: string[] | UpsertOptions<T>,\n ): Promise<InsertResult> {\n return this.getRepository<T>().upsert(\n entityOrEntities,\n conflictPathsOrOptions,\n )\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike remove method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n */\n static delete<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectId\n | ObjectId[]\n | FindOptionsWhere<T>,\n ): Promise<DeleteResult> {\n return this.getRepository<T>().delete(criteria)\n }\n\n /**\n * Counts entities that match given options.\n */\n static count<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<number> {\n return this.getRepository<T>().count(options)\n }\n\n /**\n * Counts entities that match given WHERE conditions.\n */\n static countBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<number> {\n return this.getRepository<T>().countBy(where)\n }\n\n /**\n * Return the SUM of a column\n */\n static sum<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType<T, number>,\n where: FindOptionsWhere<T>,\n ): Promise<number | null> {\n return this.getRepository<T>().sum(columnName, where)\n }\n\n /**\n * Return the AVG of a column\n */\n static average<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType<T, number>,\n where: FindOptionsWhere<T>,\n ): Promise<number | null> {\n return this.getRepository<T>().average(columnName, where)\n }\n\n /**\n * Return the MIN of a column\n */\n static minimum<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType<T, number>,\n where: FindOptionsWhere<T>,\n ): Promise<number | null> {\n return this.getRepository<T>().minimum(columnName, where)\n }\n\n /**\n * Return the MAX of a column\n */\n static maximum<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType<T, number>,\n where: FindOptionsWhere<T>,\n ): Promise<number | null> {\n return this.getRepository<T>().maximum(columnName, where)\n }\n\n /**\n * Finds entities that match given options.\n */\n static find<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<T[]> {\n return this.getRepository<T>().find(options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n */\n static findBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T[]> {\n return this.getRepository<T>().findBy(where)\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<[T[], number]> {\n return this.getRepository<T>().findAndCount(options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCountBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<[T[], number]> {\n return this.getRepository<T>().findAndCountBy(where)\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n static findByIds<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ids: any[],\n ): Promise<T[]> {\n return this.getRepository<T>().findByIds(ids)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options: FindOneOptions<T>,\n ): Promise<T | null> {\n return this.getRepository<T>().findOne(options)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T | null> {\n return this.getRepository<T>().findOneBy(where)\n }\n\n /**\n * Finds first entity that matches given options.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n static findOneById<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n id: string | number | Date | ObjectId,\n ): Promise<T | null> {\n return this.getRepository<T>().findOneById(id)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options: FindOneOptions<T>,\n ): Promise<T> {\n return this.getRepository<T>().findOneOrFail(options)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneByOrFail<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T> {\n return this.getRepository<T>().findOneByOrFail(where)\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n static query<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n query: string,\n parameters?: any[],\n ): Promise<any> {\n return this.getRepository<T>().query(query, parameters)\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n */\n static clear<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): Promise<void> {\n return this.getRepository<T>().clear()\n }\n}\n"],"sourceRoot":".."}
@@ -1,2 +1,2 @@
1
- import { ObjectID } from "../driver/mongodb/typings";
2
- export type EntityId = string | number | Date | ObjectID;
1
+ import { ObjectId } from "../driver/mongodb/typings";
2
+ export type EntityId = string | number | Date | ObjectId;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/repository/EntityId.ts"],"names":[],"mappings":"","file":"EntityId.js","sourcesContent":["import { ObjectID } from \"../driver/mongodb/typings\"\n\nexport type EntityId = string | number | Date | ObjectID\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/repository/EntityId.ts"],"names":[],"mappings":"","file":"EntityId.js","sourcesContent":["import { ObjectId } from \"../driver/mongodb/typings\"\n\nexport type EntityId = string | number | Date | ObjectId\n"],"sourceRoot":".."}
@@ -1,12 +1,13 @@
1
1
  import { ObjectLiteral } from "../common/ObjectLiteral";
2
2
  import { Repository } from "./Repository";
3
3
  import { MongoFindManyOptions } from "../find-options/mongodb/MongoFindManyOptions";
4
- import { AggregationCursor, BulkWriteOpResultObject, Code, Collection, CollectionAggregationOptions, CollectionBulkWriteOptions, CollectionInsertManyOptions, CollectionInsertOneOptions, CollectionOptions, CollStats, CommandCursor, Cursor, DeleteWriteOpResultObject, FindAndModifyWriteOpResultObject, FindOneAndReplaceOption, GeoHaystackSearchOptions, GeoNearOptions, InsertOneWriteOpResult, InsertWriteOpResult, MapReduceOptions, MongoCountPreferences, MongodbIndexOptions, ObjectID, OrderedBulkOperation, ParallelCollectionScanOptions, ReadPreference, ReplaceOneOptions, UnorderedBulkOperation, UpdateWriteOpResult } from "../driver/mongodb/typings";
5
4
  import { MongoEntityManager } from "../entity-manager/MongoEntityManager";
6
5
  import { QueryRunner } from "../query-runner/QueryRunner";
7
6
  import { SelectQueryBuilder } from "../query-builder/SelectQueryBuilder";
8
7
  import { MongoFindOneOptions } from "../find-options/mongodb/MongoFindOneOptions";
9
8
  import { FindOneOptions } from "../find-options/FindOneOptions";
9
+ import { CreateIndexesOptions, ObjectId, ReplaceOptions, AggregateOptions, AggregationCursor, AnyBulkWriteOperation, BulkWriteOptions, BulkWriteResult, Collection, CollStats, CollStatsOptions, CommandOperationOptions, CountOptions, DeleteOptions, DeleteResult, Document, Filter, FilterOperators, FindCursor, FindOneAndDeleteOptions, FindOneAndReplaceOptions, FindOneAndUpdateOptions, IndexDescription, InsertManyResult, InsertOneOptions, InsertOneResult, ListIndexesCursor, ListIndexesOptions, OrderedBulkOperation, UnorderedBulkOperation, UpdateFilter, UpdateOptions, UpdateResult } from "../driver/mongodb/typings";
10
+ import { FindManyOptions } from "../find-options/FindManyOptions";
10
11
  /**
11
12
  * Repository used to manage mongodb documents of a single entity type.
12
13
  */
@@ -28,7 +29,7 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
28
29
  /**
29
30
  * Finds entities that match given find options or conditions.
30
31
  */
31
- find(options?: MongoFindManyOptions<Entity>): Promise<Entity[]>;
32
+ find(options?: FindManyOptions<Entity> | Partial<Entity> | FilterOperators<Entity>): Promise<Entity[]>;
32
33
  /**
33
34
  * Finds entities that match given find options or conditions.
34
35
  */
@@ -73,7 +74,7 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
73
74
  * id: 1 // where "id" is your primary column name
74
75
  * })
75
76
  */
76
- findOneById(id: string | string[] | number | number[] | Date | Date[] | ObjectID | ObjectID[]): Promise<Entity | null>;
77
+ findOneById(id: string | number | Date | ObjectId): Promise<Entity | null>;
77
78
  /**
78
79
  * Finds first entity by a given find options.
79
80
  * If entity was not found in the database - rejects with error.
@@ -87,61 +88,59 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
87
88
  /**
88
89
  * Creates a cursor for a query that can be used to iterate over results from MongoDB.
89
90
  */
90
- createCursor<T = any>(query?: ObjectLiteral): Cursor<T>;
91
+ createCursor<T = any>(query?: Filter<Entity>): FindCursor<T>;
91
92
  /**
92
93
  * Creates a cursor for a query that can be used to iterate over results from MongoDB.
93
94
  * This returns modified version of cursor that transforms each result into Entity model.
94
95
  */
95
- createEntityCursor(query?: ObjectLiteral): Cursor<Entity>;
96
+ createEntityCursor(query?: Filter<Entity>): FindCursor<Entity>;
96
97
  /**
97
98
  * Execute an aggregation framework pipeline against the collection.
98
99
  */
99
- aggregate<R = any>(pipeline: ObjectLiteral[], options?: CollectionAggregationOptions): AggregationCursor<R>;
100
+ aggregate<R = any>(pipeline: ObjectLiteral[], options?: AggregateOptions): AggregationCursor<Entity>;
100
101
  /**
101
102
  * Execute an aggregation framework pipeline against the collection.
102
103
  * This returns modified version of cursor that transforms each result into Entity model.
103
104
  */
104
- aggregateEntity(pipeline: ObjectLiteral[], options?: CollectionAggregationOptions): AggregationCursor<Entity>;
105
+ aggregateEntity(pipeline: ObjectLiteral[], options?: AggregateOptions): AggregationCursor<Entity>;
105
106
  /**
106
107
  * Perform a bulkWrite operation without a fluent API.
107
108
  */
108
- bulkWrite(operations: ObjectLiteral[], options?: CollectionBulkWriteOptions): Promise<BulkWriteOpResultObject>;
109
+ bulkWrite(operations: AnyBulkWriteOperation[], options?: BulkWriteOptions): Promise<BulkWriteResult>;
109
110
  /**
110
111
  * Count number of matching documents in the db to a query.
111
112
  */
112
- count(query?: ObjectLiteral, options?: MongoCountPreferences): Promise<number>;
113
+ count(query?: ObjectLiteral, options?: CountOptions): Promise<number>;
113
114
  /**
114
115
  * Count number of matching documents in the db to a query.
115
116
  */
116
- countBy(query?: ObjectLiteral, options?: MongoCountPreferences): Promise<number>;
117
+ countBy(query?: ObjectLiteral, options?: CountOptions): Promise<number>;
117
118
  /**
118
119
  * Creates an index on the db and collection.
119
120
  */
120
- createCollectionIndex(fieldOrSpec: string | any, options?: MongodbIndexOptions): Promise<string>;
121
+ createCollectionIndex(fieldOrSpec: string | any, options?: CreateIndexesOptions): Promise<string>;
121
122
  /**
122
123
  * Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher.
123
124
  * Earlier version of MongoDB will throw a command not supported error.
124
125
  * Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/.
125
126
  */
126
- createCollectionIndexes(indexSpecs: ObjectLiteral[]): Promise<void>;
127
+ createCollectionIndexes(indexSpecs: IndexDescription[]): Promise<string[]>;
127
128
  /**
128
129
  * Delete multiple documents on MongoDB.
129
130
  */
130
- deleteMany(query: ObjectLiteral, options?: CollectionOptions): Promise<DeleteWriteOpResultObject>;
131
+ deleteMany(query: ObjectLiteral, options?: DeleteOptions): Promise<DeleteResult>;
131
132
  /**
132
133
  * Delete a document on MongoDB.
133
134
  */
134
- deleteOne(query: ObjectLiteral, options?: CollectionOptions): Promise<DeleteWriteOpResultObject>;
135
+ deleteOne(query: ObjectLiteral, options?: DeleteOptions): Promise<DeleteResult>;
135
136
  /**
136
137
  * The distinct command returns returns a list of distinct values for the given key across a collection.
137
138
  */
138
- distinct(key: string, query: ObjectLiteral, options?: {
139
- readPreference?: ReadPreference | string;
140
- }): Promise<any>;
139
+ distinct(key: string, query: ObjectLiteral, options?: CommandOperationOptions): Promise<any>;
141
140
  /**
142
141
  * Drops an index from this collection.
143
142
  */
144
- dropCollectionIndex(indexName: string, options?: CollectionOptions): Promise<any>;
143
+ dropCollectionIndex(indexName: string, options?: CommandOperationOptions): Promise<any>;
145
144
  /**
146
145
  * Drops all indexes from the collection.
147
146
  */
@@ -149,33 +148,15 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
149
148
  /**
150
149
  * Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
151
150
  */
152
- findOneAndDelete(query: ObjectLiteral, options?: {
153
- projection?: Object;
154
- sort?: Object;
155
- maxTimeMS?: number;
156
- }): Promise<FindAndModifyWriteOpResultObject>;
151
+ findOneAndDelete(query: ObjectLiteral, options?: FindOneAndDeleteOptions): Promise<Document>;
157
152
  /**
158
153
  * Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.
159
154
  */
160
- findOneAndReplace(query: ObjectLiteral, replacement: Object, options?: FindOneAndReplaceOption): Promise<FindAndModifyWriteOpResultObject>;
155
+ findOneAndReplace(query: ObjectLiteral, replacement: Object, options?: FindOneAndReplaceOptions): Promise<Document>;
161
156
  /**
162
157
  * Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
163
158
  */
164
- findOneAndUpdate(query: ObjectLiteral, update: Object, options?: FindOneAndReplaceOption): Promise<FindAndModifyWriteOpResultObject>;
165
- /**
166
- * Execute a geo search using a geo haystack index on a collection.
167
- */
168
- geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise<any>;
169
- /**
170
- * Execute the geoNear command to search for items in the collection.
171
- */
172
- geoNear(x: number, y: number, options?: GeoNearOptions): Promise<any>;
173
- /**
174
- * Run a group command across a collection.
175
- */
176
- group(keys: Object | Array<any> | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options?: {
177
- readPreference?: ReadPreference | string;
178
- }): Promise<any>;
159
+ findOneAndUpdate(query: ObjectLiteral, update: Object, options?: FindOneAndUpdateOptions): Promise<Document>;
179
160
  /**
180
161
  * Retrieve all the indexes on the collection.
181
162
  */
@@ -193,19 +174,19 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
193
174
  /**
194
175
  * Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types.
195
176
  */
196
- initializeOrderedBulkOp(options?: CollectionOptions): OrderedBulkOperation;
177
+ initializeOrderedBulkOp(options?: BulkWriteOptions): OrderedBulkOperation;
197
178
  /**
198
179
  * Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.
199
180
  */
200
- initializeUnorderedBulkOp(options?: CollectionOptions): UnorderedBulkOperation;
181
+ initializeUnorderedBulkOp(options?: BulkWriteOptions): UnorderedBulkOperation;
201
182
  /**
202
183
  * Inserts an array of documents into MongoDB.
203
184
  */
204
- insertMany(docs: ObjectLiteral[], options?: CollectionInsertManyOptions): Promise<InsertWriteOpResult>;
185
+ insertMany(docs: ObjectLiteral[], options?: BulkWriteOptions): Promise<InsertManyResult<Document>>;
205
186
  /**
206
187
  * Inserts a single document into MongoDB.
207
188
  */
208
- insertOne(doc: ObjectLiteral, options?: CollectionInsertOneOptions): Promise<InsertOneWriteOpResult>;
189
+ insertOne(doc: ObjectLiteral, options?: InsertOneOptions): Promise<InsertOneResult>;
209
190
  /**
210
191
  * Returns if the collection is a capped collection.
211
192
  */
@@ -213,50 +194,27 @@ export declare class MongoRepository<Entity extends ObjectLiteral> extends Repos
213
194
  /**
214
195
  * Get the list of all indexes information for the collection.
215
196
  */
216
- listCollectionIndexes(options?: {
217
- batchSize?: number;
218
- readPreference?: ReadPreference | string;
219
- }): CommandCursor;
220
- /**
221
- * Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
222
- */
223
- mapReduce(map: Function | string, reduce: Function | string, options?: MapReduceOptions): Promise<any>;
224
- /**
225
- * Return N number of parallel cursors for a collection allowing parallel reading of entire collection.
226
- * There are no ordering guarantees for returned results.
227
- */
228
- parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise<Cursor<Entity>[]>;
229
- /**
230
- * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
231
- */
232
- reIndex(): Promise<any>;
197
+ listCollectionIndexes(options?: ListIndexesOptions): ListIndexesCursor;
233
198
  /**
234
199
  * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
235
200
  */
236
201
  rename(newName: string, options?: {
237
202
  dropTarget?: boolean;
238
- }): Promise<Collection<any>>;
203
+ }): Promise<Collection<Document>>;
239
204
  /**
240
205
  * Replace a document on MongoDB.
241
206
  */
242
- replaceOne(query: ObjectLiteral, doc: ObjectLiteral, options?: ReplaceOneOptions): Promise<UpdateWriteOpResult>;
207
+ replaceOne(query: ObjectLiteral, doc: ObjectLiteral, options?: ReplaceOptions): Promise<Document | UpdateResult>;
243
208
  /**
244
209
  * Get all the collection statistics.
245
210
  */
246
- stats(options?: {
247
- scale: number;
248
- }): Promise<CollStats>;
211
+ stats(options?: CollStatsOptions): Promise<CollStats>;
249
212
  /**
250
213
  * Update multiple documents on MongoDB.
251
214
  */
252
- updateMany(query: ObjectLiteral, update: ObjectLiteral, options?: {
253
- upsert?: boolean;
254
- w?: any;
255
- wtimeout?: number;
256
- j?: boolean;
257
- }): Promise<UpdateWriteOpResult>;
215
+ updateMany(query: ObjectLiteral, update: UpdateFilter<Document>, options?: UpdateOptions): Promise<Document | UpdateResult>;
258
216
  /**
259
217
  * Update a single document on MongoDB.
260
218
  */
261
- updateOne(query: ObjectLiteral, update: ObjectLiteral, options?: ReplaceOneOptions): Promise<UpdateWriteOpResult>;
219
+ updateOne(query: ObjectLiteral, update: UpdateFilter<Document>, options?: UpdateOptions): Promise<Document | UpdateResult>;
262
220
  }
@@ -145,7 +145,7 @@ class MongoRepository extends Repository_1.Repository {
145
145
  * Count number of matching documents in the db to a query.
146
146
  */
147
147
  countBy(query, options) {
148
- return this.manager.countBy(this.metadata.target, query || {}, options);
148
+ return this.manager.countBy(this.metadata.target, query, options);
149
149
  }
150
150
  /**
151
151
  * Creates an index on the db and collection.
@@ -209,24 +209,6 @@ class MongoRepository extends Repository_1.Repository {
209
209
  findOneAndUpdate(query, update, options) {
210
210
  return this.manager.findOneAndUpdate(this.metadata.tableName, query, update, options);
211
211
  }
212
- /**
213
- * Execute a geo search using a geo haystack index on a collection.
214
- */
215
- geoHaystackSearch(x, y, options) {
216
- return this.manager.geoHaystackSearch(this.metadata.tableName, x, y, options);
217
- }
218
- /**
219
- * Execute the geoNear command to search for items in the collection.
220
- */
221
- geoNear(x, y, options) {
222
- return this.manager.geoNear(this.metadata.tableName, x, y, options);
223
- }
224
- /**
225
- * Run a group command across a collection.
226
- */
227
- group(keys, condition, initial, reduce, finalize, command, options) {
228
- return this.manager.group(this.metadata.tableName, keys, condition, initial, reduce, finalize, command, options);
229
- }
230
212
  /**
231
213
  * Retrieve all the indexes on the collection.
232
214
  */
@@ -281,25 +263,6 @@ class MongoRepository extends Repository_1.Repository {
281
263
  listCollectionIndexes(options) {
282
264
  return this.manager.listCollectionIndexes(this.metadata.tableName, options);
283
265
  }
284
- /**
285
- * Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
286
- */
287
- mapReduce(map, reduce, options) {
288
- return this.manager.mapReduce(this.metadata.tableName, map, reduce, options);
289
- }
290
- /**
291
- * Return N number of parallel cursors for a collection allowing parallel reading of entire collection.
292
- * There are no ordering guarantees for returned results.
293
- */
294
- parallelCollectionScan(options) {
295
- return this.manager.parallelCollectionScan(this.metadata.tableName, options);
296
- }
297
- /**
298
- * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
299
- */
300
- reIndex() {
301
- return this.manager.reIndex(this.metadata.tableName);
302
- }
303
266
  /**
304
267
  * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
305
268
  */