joist-orm 1.294.0 → 2.0.0
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.
- package/build/{drivers/PostgresDriver.d.ts → PostgresDriver.d.ts} +1 -4
- package/build/PostgresDriver.d.ts.map +1 -0
- package/build/{drivers/PostgresDriver.js → PostgresDriver.js} +49 -58
- package/build/PostgresDriver.js.map +1 -0
- package/build/codegen.d.ts +2 -0
- package/build/codegen.d.ts.map +1 -0
- package/build/codegen.js +29 -0
- package/build/codegen.js.map +1 -0
- package/build/graphql-codegen-export.d.ts +2 -0
- package/build/graphql-codegen-export.d.ts.map +1 -0
- package/build/{drivers/index.js → graphql-codegen-export.js} +3 -5
- package/build/graphql-codegen-export.js.map +1 -0
- package/build/graphql-export.d.ts +2 -0
- package/build/graphql-export.d.ts.map +1 -0
- package/build/graphql-export.js +19 -0
- package/build/graphql-export.js.map +1 -0
- package/build/index.d.ts +3 -128
- package/build/index.d.ts.map +1 -1
- package/build/index.js +8 -284
- package/build/index.js.map +1 -1
- package/build/knex-export.d.ts +2 -0
- package/build/knex-export.d.ts.map +1 -0
- package/build/knex-export.js +19 -0
- package/build/knex-export.js.map +1 -0
- package/build/pg-migrate.d.ts +2 -0
- package/build/pg-migrate.d.ts.map +1 -0
- package/build/pg-migrate.js +30 -0
- package/build/pg-migrate.js.map +1 -0
- package/build/postgres-driver.d.ts +2 -0
- package/build/postgres-driver.d.ts.map +1 -0
- package/build/postgres-driver.js +7 -0
- package/build/postgres-driver.js.map +1 -0
- package/build/tests-export.d.ts +2 -0
- package/build/tests-export.d.ts.map +1 -0
- package/build/tests-export.js +19 -0
- package/build/tests-export.js.map +1 -0
- package/package.json +85 -16
- package/build/AliasAssigner.d.ts +0 -7
- package/build/AliasAssigner.d.ts.map +0 -1
- package/build/AliasAssigner.js +0 -30
- package/build/AliasAssigner.js.map +0 -1
- package/build/Aliases.d.ts +0 -110
- package/build/Aliases.d.ts.map +0 -1
- package/build/Aliases.js +0 -456
- package/build/Aliases.js.map +0 -1
- package/build/BaseEntity.d.ts +0 -66
- package/build/BaseEntity.d.ts.map +0 -1
- package/build/BaseEntity.js +0 -120
- package/build/BaseEntity.js.map +0 -1
- package/build/ConditionBuilder.d.ts +0 -50
- package/build/ConditionBuilder.d.ts.map +0 -1
- package/build/ConditionBuilder.js +0 -178
- package/build/ConditionBuilder.js.map +0 -1
- package/build/Entity.d.ts +0 -38
- package/build/Entity.d.ts.map +0 -1
- package/build/Entity.js +0 -8
- package/build/Entity.js.map +0 -1
- package/build/EntityFields.d.ts +0 -37
- package/build/EntityFields.d.ts.map +0 -1
- package/build/EntityFields.js +0 -3
- package/build/EntityFields.js.map +0 -1
- package/build/EntityFilter.d.ts +0 -113
- package/build/EntityFilter.d.ts.map +0 -1
- package/build/EntityFilter.js +0 -3
- package/build/EntityFilter.js.map +0 -1
- package/build/EntityGraphQLFilter.d.ts +0 -51
- package/build/EntityGraphQLFilter.d.ts.map +0 -1
- package/build/EntityGraphQLFilter.js +0 -54
- package/build/EntityGraphQLFilter.js.map +0 -1
- package/build/EntityManager.d.ts +0 -734
- package/build/EntityManager.d.ts.map +0 -1
- package/build/EntityManager.js +0 -2075
- package/build/EntityManager.js.map +0 -1
- package/build/EntityMetadata.d.ts +0 -185
- package/build/EntityMetadata.d.ts.map +0 -1
- package/build/EntityMetadata.js +0 -61
- package/build/EntityMetadata.js.map +0 -1
- package/build/EnumMetadata.d.ts +0 -15
- package/build/EnumMetadata.d.ts.map +0 -1
- package/build/EnumMetadata.js +0 -3
- package/build/EnumMetadata.js.map +0 -1
- package/build/FlushLock.d.ts +0 -26
- package/build/FlushLock.d.ts.map +0 -1
- package/build/FlushLock.js +0 -57
- package/build/FlushLock.js.map +0 -1
- package/build/HintTree.d.ts +0 -42
- package/build/HintTree.d.ts.map +0 -1
- package/build/HintTree.js +0 -64
- package/build/HintTree.js.map +0 -1
- package/build/IndexManager.d.ts +0 -30
- package/build/IndexManager.d.ts.map +0 -1
- package/build/IndexManager.js +0 -206
- package/build/IndexManager.js.map +0 -1
- package/build/InstanceData.d.ts +0 -59
- package/build/InstanceData.d.ts.map +0 -1
- package/build/InstanceData.js +0 -162
- package/build/InstanceData.js.map +0 -1
- package/build/IsLoadedCache.d.ts +0 -32
- package/build/IsLoadedCache.d.ts.map +0 -1
- package/build/IsLoadedCache.js +0 -80
- package/build/IsLoadedCache.js.map +0 -1
- package/build/JoinRows.d.ts +0 -75
- package/build/JoinRows.d.ts.map +0 -1
- package/build/JoinRows.js +0 -246
- package/build/JoinRows.js.map +0 -1
- package/build/PluginManager.d.ts +0 -90
- package/build/PluginManager.d.ts.map +0 -1
- package/build/PluginManager.js +0 -97
- package/build/PluginManager.js.map +0 -1
- package/build/QueryParser.d.ts +0 -271
- package/build/QueryParser.d.ts.map +0 -1
- package/build/QueryParser.js +0 -853
- package/build/QueryParser.js.map +0 -1
- package/build/QueryParser.pruning.d.ts +0 -5
- package/build/QueryParser.pruning.d.ts.map +0 -1
- package/build/QueryParser.pruning.js +0 -118
- package/build/QueryParser.pruning.js.map +0 -1
- package/build/QueryVisitor.d.ts +0 -19
- package/build/QueryVisitor.d.ts.map +0 -1
- package/build/QueryVisitor.js +0 -84
- package/build/QueryVisitor.js.map +0 -1
- package/build/ReactionsManager.d.ts +0 -84
- package/build/ReactionsManager.d.ts.map +0 -1
- package/build/ReactionsManager.js +0 -308
- package/build/ReactionsManager.js.map +0 -1
- package/build/Todo.d.ts +0 -31
- package/build/Todo.d.ts.map +0 -1
- package/build/Todo.js +0 -73
- package/build/Todo.js.map +0 -1
- package/build/caches.d.ts +0 -6
- package/build/caches.d.ts.map +0 -1
- package/build/caches.js +0 -42
- package/build/caches.js.map +0 -1
- package/build/changes.d.ts +0 -79
- package/build/changes.d.ts.map +0 -1
- package/build/changes.js +0 -251
- package/build/changes.js.map +0 -1
- package/build/config.d.ts +0 -237
- package/build/config.d.ts.map +0 -1
- package/build/config.js +0 -298
- package/build/config.js.map +0 -1
- package/build/config.test.d.ts +0 -2
- package/build/config.test.d.ts.map +0 -1
- package/build/config.test.js +0 -53
- package/build/config.test.js.map +0 -1
- package/build/configure.d.ts +0 -13
- package/build/configure.d.ts.map +0 -1
- package/build/configure.js +0 -329
- package/build/configure.js.map +0 -1
- package/build/dataloaders/findByUniqueDataLoader.d.ts +0 -7
- package/build/dataloaders/findByUniqueDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findByUniqueDataLoader.js +0 -47
- package/build/dataloaders/findByUniqueDataLoader.js.map +0 -1
- package/build/dataloaders/findCountDataLoader.d.ts +0 -7
- package/build/dataloaders/findCountDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findCountDataLoader.js +0 -74
- package/build/dataloaders/findCountDataLoader.js.map +0 -1
- package/build/dataloaders/findDataLoader.d.ts +0 -37
- package/build/dataloaders/findDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findDataLoader.js +0 -337
- package/build/dataloaders/findDataLoader.js.map +0 -1
- package/build/dataloaders/findIdsDataLoader.d.ts +0 -7
- package/build/dataloaders/findIdsDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findIdsDataLoader.js +0 -74
- package/build/dataloaders/findIdsDataLoader.js.map +0 -1
- package/build/dataloaders/findOrCreateDataLoader.d.ts +0 -13
- package/build/dataloaders/findOrCreateDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findOrCreateDataLoader.js +0 -174
- package/build/dataloaders/findOrCreateDataLoader.js.map +0 -1
- package/build/dataloaders/lensDataLoader.d.ts +0 -12
- package/build/dataloaders/lensDataLoader.d.ts.map +0 -1
- package/build/dataloaders/lensDataLoader.js +0 -180
- package/build/dataloaders/lensDataLoader.js.map +0 -1
- package/build/dataloaders/loadDataLoader.d.ts +0 -11
- package/build/dataloaders/loadDataLoader.d.ts.map +0 -1
- package/build/dataloaders/loadDataLoader.js +0 -54
- package/build/dataloaders/loadDataLoader.js.map +0 -1
- package/build/dataloaders/manyToManyDataLoader.d.ts +0 -8
- package/build/dataloaders/manyToManyDataLoader.d.ts.map +0 -1
- package/build/dataloaders/manyToManyDataLoader.js +0 -74
- package/build/dataloaders/manyToManyDataLoader.js.map +0 -1
- package/build/dataloaders/manyToManyFindDataLoader.d.ts +0 -8
- package/build/dataloaders/manyToManyFindDataLoader.d.ts.map +0 -1
- package/build/dataloaders/manyToManyFindDataLoader.js +0 -70
- package/build/dataloaders/manyToManyFindDataLoader.js.map +0 -1
- package/build/dataloaders/oneToManyDataLoader.d.ts +0 -7
- package/build/dataloaders/oneToManyDataLoader.d.ts.map +0 -1
- package/build/dataloaders/oneToManyDataLoader.js +0 -60
- package/build/dataloaders/oneToManyDataLoader.js.map +0 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.ts +0 -8
- package/build/dataloaders/oneToManyFindDataLoader.d.ts.map +0 -1
- package/build/dataloaders/oneToManyFindDataLoader.js +0 -71
- package/build/dataloaders/oneToManyFindDataLoader.js.map +0 -1
- package/build/dataloaders/oneToOneDataLoader.d.ts +0 -7
- package/build/dataloaders/oneToOneDataLoader.d.ts.map +0 -1
- package/build/dataloaders/oneToOneDataLoader.js +0 -59
- package/build/dataloaders/oneToOneDataLoader.js.map +0 -1
- package/build/dataloaders/populateDataLoader.d.ts +0 -13
- package/build/dataloaders/populateDataLoader.d.ts.map +0 -1
- package/build/dataloaders/populateDataLoader.js +0 -148
- package/build/dataloaders/populateDataLoader.js.map +0 -1
- package/build/dataloaders/recursiveChildrenDataLoader.d.ts +0 -7
- package/build/dataloaders/recursiveChildrenDataLoader.d.ts.map +0 -1
- package/build/dataloaders/recursiveChildrenDataLoader.js +0 -77
- package/build/dataloaders/recursiveChildrenDataLoader.js.map +0 -1
- package/build/dataloaders/recursiveParentsDataLoader.d.ts +0 -7
- package/build/dataloaders/recursiveParentsDataLoader.d.ts.map +0 -1
- package/build/dataloaders/recursiveParentsDataLoader.js +0 -59
- package/build/dataloaders/recursiveParentsDataLoader.js.map +0 -1
- package/build/defaults.d.ts +0 -54
- package/build/defaults.d.ts.map +0 -1
- package/build/defaults.js +0 -282
- package/build/defaults.js.map +0 -1
- package/build/driverApi.d.ts +0 -19
- package/build/driverApi.d.ts.map +0 -1
- package/build/driverApi.js +0 -17
- package/build/driverApi.js.map +0 -1
- package/build/drivers/Driver.d.ts +0 -26
- package/build/drivers/Driver.d.ts.map +0 -1
- package/build/drivers/Driver.js +0 -3
- package/build/drivers/Driver.js.map +0 -1
- package/build/drivers/EntityWriter.d.ts +0 -64
- package/build/drivers/EntityWriter.d.ts.map +0 -1
- package/build/drivers/EntityWriter.js +0 -237
- package/build/drivers/EntityWriter.js.map +0 -1
- package/build/drivers/IdAssigner.d.ts +0 -50
- package/build/drivers/IdAssigner.d.ts.map +0 -1
- package/build/drivers/IdAssigner.js +0 -133
- package/build/drivers/IdAssigner.js.map +0 -1
- package/build/drivers/PostgresDriver.d.ts.map +0 -1
- package/build/drivers/PostgresDriver.js.map +0 -1
- package/build/drivers/buildRawQuery.d.ts +0 -20
- package/build/drivers/buildRawQuery.d.ts.map +0 -1
- package/build/drivers/buildRawQuery.js +0 -148
- package/build/drivers/buildRawQuery.js.map +0 -1
- package/build/drivers/buildUtils.d.ts +0 -4
- package/build/drivers/buildUtils.d.ts.map +0 -1
- package/build/drivers/buildUtils.js +0 -79
- package/build/drivers/buildUtils.js.map +0 -1
- package/build/drivers/index.d.ts +0 -5
- package/build/drivers/index.d.ts.map +0 -1
- package/build/drivers/index.js.map +0 -1
- package/build/fields.d.ts +0 -24
- package/build/fields.d.ts.map +0 -1
- package/build/fields.js +0 -162
- package/build/fields.js.map +0 -1
- package/build/getProperties.d.ts +0 -28
- package/build/getProperties.d.ts.map +0 -1
- package/build/getProperties.js +0 -141
- package/build/getProperties.js.map +0 -1
- package/build/json.d.ts +0 -77
- package/build/json.d.ts.map +0 -1
- package/build/json.js +0 -116
- package/build/json.js.map +0 -1
- package/build/k.d.ts +0 -2
- package/build/k.d.ts.map +0 -1
- package/build/k.js +0 -9
- package/build/k.js.map +0 -1
- package/build/keys.d.ts +0 -49
- package/build/keys.d.ts.map +0 -1
- package/build/keys.js +0 -195
- package/build/keys.js.map +0 -1
- package/build/keywords.d.ts +0 -5
- package/build/keywords.d.ts.map +0 -1
- package/build/keywords.js +0 -124
- package/build/keywords.js.map +0 -1
- package/build/loadHints.d.ts +0 -112
- package/build/loadHints.d.ts.map +0 -1
- package/build/loadHints.js +0 -75
- package/build/loadHints.js.map +0 -1
- package/build/loadLens.d.ts +0 -66
- package/build/loadLens.d.ts.map +0 -1
- package/build/loadLens.js +0 -287
- package/build/loadLens.js.map +0 -1
- package/build/logging/FactoryLogger.d.ts +0 -24
- package/build/logging/FactoryLogger.d.ts.map +0 -1
- package/build/logging/FactoryLogger.js +0 -77
- package/build/logging/FactoryLogger.js.map +0 -1
- package/build/logging/FieldLogger.d.ts +0 -27
- package/build/logging/FieldLogger.d.ts.map +0 -1
- package/build/logging/FieldLogger.js +0 -69
- package/build/logging/FieldLogger.js.map +0 -1
- package/build/logging/ReactionLogger.d.ts +0 -23
- package/build/logging/ReactionLogger.d.ts.map +0 -1
- package/build/logging/ReactionLogger.js +0 -65
- package/build/logging/ReactionLogger.js.map +0 -1
- package/build/newEntity.d.ts +0 -45
- package/build/newEntity.d.ts.map +0 -1
- package/build/newEntity.js +0 -106
- package/build/newEntity.js.map +0 -1
- package/build/newTestInstance.d.ts +0 -193
- package/build/newTestInstance.d.ts.map +0 -1
- package/build/newTestInstance.js +0 -738
- package/build/newTestInstance.js.map +0 -1
- package/build/normalizeHints.d.ts +0 -16
- package/build/normalizeHints.d.ts.map +0 -1
- package/build/normalizeHints.js +0 -31
- package/build/normalizeHints.js.map +0 -1
- package/build/plugins/ImmutableEntitiesPlugin.d.ts +0 -9
- package/build/plugins/ImmutableEntitiesPlugin.d.ts.map +0 -1
- package/build/plugins/ImmutableEntitiesPlugin.js +0 -21
- package/build/plugins/ImmutableEntitiesPlugin.js.map +0 -1
- package/build/plugins/PreloadPlugin.d.ts +0 -69
- package/build/plugins/PreloadPlugin.d.ts.map +0 -1
- package/build/plugins/PreloadPlugin.js +0 -3
- package/build/plugins/PreloadPlugin.js.map +0 -1
- package/build/preloading/JsonAggregatePreloader.d.ts +0 -16
- package/build/preloading/JsonAggregatePreloader.d.ts.map +0 -1
- package/build/preloading/JsonAggregatePreloader.js +0 -238
- package/build/preloading/JsonAggregatePreloader.js.map +0 -1
- package/build/preloading/canPreload.d.ts +0 -3
- package/build/preloading/canPreload.d.ts.map +0 -1
- package/build/preloading/canPreload.js +0 -21
- package/build/preloading/canPreload.js.map +0 -1
- package/build/preloading/partitionHint.d.ts +0 -5
- package/build/preloading/partitionHint.d.ts.map +0 -1
- package/build/preloading/partitionHint.js +0 -56
- package/build/preloading/partitionHint.js.map +0 -1
- package/build/reactiveHints.d.ts +0 -129
- package/build/reactiveHints.d.ts.map +0 -1
- package/build/reactiveHints.js +0 -458
- package/build/reactiveHints.js.map +0 -1
- package/build/relations/AbstractPropertyImpl.d.ts +0 -8
- package/build/relations/AbstractPropertyImpl.d.ts.map +0 -1
- package/build/relations/AbstractPropertyImpl.js +0 -15
- package/build/relations/AbstractPropertyImpl.js.map +0 -1
- package/build/relations/AbstractRelationImpl.d.ts +0 -36
- package/build/relations/AbstractRelationImpl.d.ts.map +0 -1
- package/build/relations/AbstractRelationImpl.js +0 -19
- package/build/relations/AbstractRelationImpl.js.map +0 -1
- package/build/relations/Collection.d.ts +0 -28
- package/build/relations/Collection.d.ts.map +0 -1
- package/build/relations/Collection.js +0 -18
- package/build/relations/Collection.js.map +0 -1
- package/build/relations/CustomCollection.d.ts +0 -69
- package/build/relations/CustomCollection.d.ts.map +0 -1
- package/build/relations/CustomCollection.js +0 -166
- package/build/relations/CustomCollection.js.map +0 -1
- package/build/relations/CustomReference.d.ts +0 -71
- package/build/relations/CustomReference.d.ts.map +0 -1
- package/build/relations/CustomReference.js +0 -152
- package/build/relations/CustomReference.js.map +0 -1
- package/build/relations/LargeCollection.d.ts +0 -19
- package/build/relations/LargeCollection.d.ts.map +0 -1
- package/build/relations/LargeCollection.js +0 -3
- package/build/relations/LargeCollection.js.map +0 -1
- package/build/relations/ManyToManyCollection.d.ts +0 -44
- package/build/relations/ManyToManyCollection.d.ts.map +0 -1
- package/build/relations/ManyToManyCollection.js +0 -268
- package/build/relations/ManyToManyCollection.js.map +0 -1
- package/build/relations/ManyToManyLargeCollection.d.ts +0 -30
- package/build/relations/ManyToManyLargeCollection.d.ts.map +0 -1
- package/build/relations/ManyToManyLargeCollection.js +0 -119
- package/build/relations/ManyToManyLargeCollection.js.map +0 -1
- package/build/relations/ManyToOneReference.d.ts +0 -121
- package/build/relations/ManyToOneReference.d.ts.map +0 -1
- package/build/relations/ManyToOneReference.js +0 -389
- package/build/relations/ManyToOneReference.js.map +0 -1
- package/build/relations/OneToManyCollection.d.ts +0 -58
- package/build/relations/OneToManyCollection.d.ts.map +0 -1
- package/build/relations/OneToManyCollection.js +0 -347
- package/build/relations/OneToManyCollection.js.map +0 -1
- package/build/relations/OneToManyLargeCollection.d.ts +0 -26
- package/build/relations/OneToManyLargeCollection.d.ts.map +0 -1
- package/build/relations/OneToManyLargeCollection.js +0 -102
- package/build/relations/OneToManyLargeCollection.js.map +0 -1
- package/build/relations/OneToOneReference.d.ts +0 -93
- package/build/relations/OneToOneReference.d.ts.map +0 -1
- package/build/relations/OneToOneReference.js +0 -228
- package/build/relations/OneToOneReference.js.map +0 -1
- package/build/relations/PolymorphicReference.d.ts +0 -89
- package/build/relations/PolymorphicReference.d.ts.map +0 -1
- package/build/relations/PolymorphicReference.js +0 -244
- package/build/relations/PolymorphicReference.js.map +0 -1
- package/build/relations/ReactiveField.d.ts +0 -87
- package/build/relations/ReactiveField.d.ts.map +0 -1
- package/build/relations/ReactiveField.js +0 -149
- package/build/relations/ReactiveField.js.map +0 -1
- package/build/relations/ReactiveGetter.d.ts +0 -30
- package/build/relations/ReactiveGetter.d.ts.map +0 -1
- package/build/relations/ReactiveGetter.js +0 -38
- package/build/relations/ReactiveGetter.js.map +0 -1
- package/build/relations/ReactiveManyToMany.d.ts +0 -56
- package/build/relations/ReactiveManyToMany.d.ts.map +0 -1
- package/build/relations/ReactiveManyToMany.js +0 -243
- package/build/relations/ReactiveManyToMany.js.map +0 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.ts +0 -47
- package/build/relations/ReactiveManyToManyOtherSide.d.ts.map +0 -1
- package/build/relations/ReactiveManyToManyOtherSide.js +0 -155
- package/build/relations/ReactiveManyToManyOtherSide.js.map +0 -1
- package/build/relations/ReactiveQueryField.d.ts +0 -41
- package/build/relations/ReactiveQueryField.d.ts.map +0 -1
- package/build/relations/ReactiveQueryField.js +0 -125
- package/build/relations/ReactiveQueryField.js.map +0 -1
- package/build/relations/ReactiveReference.d.ts +0 -119
- package/build/relations/ReactiveReference.d.ts.map +0 -1
- package/build/relations/ReactiveReference.js +0 -333
- package/build/relations/ReactiveReference.js.map +0 -1
- package/build/relations/ReadOnlyCollection.d.ts +0 -19
- package/build/relations/ReadOnlyCollection.d.ts.map +0 -1
- package/build/relations/ReadOnlyCollection.js +0 -15
- package/build/relations/ReadOnlyCollection.js.map +0 -1
- package/build/relations/RecursiveCollection.d.ts +0 -84
- package/build/relations/RecursiveCollection.d.ts.map +0 -1
- package/build/relations/RecursiveCollection.js +0 -296
- package/build/relations/RecursiveCollection.js.map +0 -1
- package/build/relations/Reference.d.ts +0 -35
- package/build/relations/Reference.d.ts.map +0 -1
- package/build/relations/Reference.js +0 -21
- package/build/relations/Reference.js.map +0 -1
- package/build/relations/Relation.d.ts +0 -14
- package/build/relations/Relation.d.ts.map +0 -1
- package/build/relations/Relation.js +0 -12
- package/build/relations/Relation.js.map +0 -1
- package/build/relations/hasAsyncMethod.d.ts +0 -27
- package/build/relations/hasAsyncMethod.d.ts.map +0 -1
- package/build/relations/hasAsyncMethod.js +0 -47
- package/build/relations/hasAsyncMethod.js.map +0 -1
- package/build/relations/hasAsyncProperty.d.ts +0 -49
- package/build/relations/hasAsyncProperty.d.ts.map +0 -1
- package/build/relations/hasAsyncProperty.js +0 -98
- package/build/relations/hasAsyncProperty.js.map +0 -1
- package/build/relations/hasManyDerived.d.ts +0 -22
- package/build/relations/hasManyDerived.d.ts.map +0 -1
- package/build/relations/hasManyDerived.js +0 -32
- package/build/relations/hasManyDerived.js.map +0 -1
- package/build/relations/hasManyThrough.d.ts +0 -10
- package/build/relations/hasManyThrough.d.ts.map +0 -1
- package/build/relations/hasManyThrough.js +0 -24
- package/build/relations/hasManyThrough.js.map +0 -1
- package/build/relations/hasOneDerived.d.ts +0 -12
- package/build/relations/hasOneDerived.d.ts.map +0 -1
- package/build/relations/hasOneDerived.js +0 -24
- package/build/relations/hasOneDerived.js.map +0 -1
- package/build/relations/hasOneThrough.d.ts +0 -10
- package/build/relations/hasOneThrough.d.ts.map +0 -1
- package/build/relations/hasOneThrough.js +0 -24
- package/build/relations/hasOneThrough.js.map +0 -1
- package/build/relations/index.d.ts +0 -28
- package/build/relations/index.d.ts.map +0 -1
- package/build/relations/index.js +0 -88
- package/build/relations/index.js.map +0 -1
- package/build/rules.d.ts +0 -123
- package/build/rules.d.ts.map +0 -1
- package/build/rules.js +0 -231
- package/build/rules.js.map +0 -1
- package/build/runtimeConfig.d.ts +0 -17
- package/build/runtimeConfig.d.ts.map +0 -1
- package/build/runtimeConfig.js +0 -18
- package/build/runtimeConfig.js.map +0 -1
- package/build/serde.d.ts +0 -277
- package/build/serde.d.ts.map +0 -1
- package/build/serde.js +0 -517
- package/build/serde.js.map +0 -1
- package/build/temporal.d.ts +0 -16
- package/build/temporal.d.ts.map +0 -1
- package/build/temporal.js +0 -48
- package/build/temporal.js.map +0 -1
- package/build/temporalMappers.d.ts +0 -25
- package/build/temporalMappers.d.ts.map +0 -1
- package/build/temporalMappers.js +0 -59
- package/build/temporalMappers.js.map +0 -1
- package/build/typeMap.d.ts +0 -68
- package/build/typeMap.d.ts.map +0 -1
- package/build/typeMap.js +0 -3
- package/build/typeMap.js.map +0 -1
- package/build/unnest.d.ts +0 -13
- package/build/unnest.d.ts.map +0 -1
- package/build/unnest.js +0 -85
- package/build/unnest.js.map +0 -1
- package/build/upsert.d.ts +0 -42
- package/build/upsert.d.ts.map +0 -1
- package/build/upsert.js +0 -265
- package/build/upsert.js.map +0 -1
- package/build/utils.d.ts +0 -58
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js +0 -236
- package/build/utils.js.map +0 -1
- package/build/withLoaded.d.ts +0 -56
- package/build/withLoaded.d.ts.map +0 -1
- package/build/withLoaded.js +0 -76
- package/build/withLoaded.js.map +0 -1
package/build/EntityManager.d.ts
DELETED
|
@@ -1,734 +0,0 @@
|
|
|
1
|
-
import DataLoader, { BatchLoadFn, Options } from "dataloader";
|
|
2
|
-
import { IndexManager } from "./IndexManager";
|
|
3
|
-
import { findByUniqueOperation } from "./dataloaders/findByUniqueDataLoader";
|
|
4
|
-
import { findCountOperation } from "./dataloaders/findCountDataLoader";
|
|
5
|
-
import { findOperation } from "./dataloaders/findDataLoader";
|
|
6
|
-
import { findIdsOperation } from "./dataloaders/findIdsDataLoader";
|
|
7
|
-
import { lensOperation } from "./dataloaders/lensDataLoader";
|
|
8
|
-
import { loadOperation } from "./dataloaders/loadDataLoader";
|
|
9
|
-
import { manyToManyLoadOperation } from "./dataloaders/manyToManyDataLoader";
|
|
10
|
-
import { manyToManyFindOperation } from "./dataloaders/manyToManyFindDataLoader";
|
|
11
|
-
import { oneToManyLoadOperation } from "./dataloaders/oneToManyDataLoader";
|
|
12
|
-
import { oneToManyFindOperation } from "./dataloaders/oneToManyFindDataLoader";
|
|
13
|
-
import { oneToOneLoadOperation } from "./dataloaders/oneToOneDataLoader";
|
|
14
|
-
import { populateOperation } from "./dataloaders/populateDataLoader";
|
|
15
|
-
import { recursiveChildrenOperation } from "./dataloaders/recursiveChildrenDataLoader";
|
|
16
|
-
import { recursiveParentsOperation } from "./dataloaders/recursiveParentsDataLoader";
|
|
17
|
-
import { Driver } from "./drivers";
|
|
18
|
-
import { Entity, Entity as EntityW } from "./Entity";
|
|
19
|
-
import { DeepPartialOrNull, EntityMetadata, ExpressionFilter, FieldLogger, FilterWithAlias, GraphQLFilterWithAlias, InstanceData, Lens, OneToManyCollection, PartialOrNull, Plugin, ReactionLogger, ReactiveHint, Reference, UniqueFilter } from "./index";
|
|
20
|
-
import { IsLoadedCache } from "./IsLoadedCache";
|
|
21
|
-
import { JoinRows, ManyToManyLike } from "./JoinRows";
|
|
22
|
-
import { Loaded, LoadHint, New } from "./loadHints";
|
|
23
|
-
import { PluginManager } from "./PluginManager";
|
|
24
|
-
import { PreloadPlugin } from "./plugins/PreloadPlugin";
|
|
25
|
-
import { ReactionsManager } from "./ReactionsManager";
|
|
26
|
-
import { OptsOf, OrderOf } from "./typeMap";
|
|
27
|
-
import { MaybePromise } from "./utils";
|
|
28
|
-
/**
|
|
29
|
-
* The constructor for concrete entity types.
|
|
30
|
-
*
|
|
31
|
-
* Abstract entity types, like a base `Publisher` class that is marked `abstract`, cannot
|
|
32
|
-
* implement this and instead only have the `AbsEntityConstructor` type.
|
|
33
|
-
*/
|
|
34
|
-
export interface EntityConstructor<T> {
|
|
35
|
-
/** The pseudo-public constructor for entities; only the `EntityManager` should actually instantiate entities. */
|
|
36
|
-
new (em: EntityManager<any, any, any>): T;
|
|
37
|
-
tagName: any;
|
|
38
|
-
metadata: EntityMetadata;
|
|
39
|
-
/** Returns the private `InstanceData` for the given entity. */
|
|
40
|
-
getInstanceData(entity: Entity): InstanceData;
|
|
41
|
-
}
|
|
42
|
-
/** Options for the auto-batchable `em.find` queries, i.e. limit & offset aren't allowed. */
|
|
43
|
-
export interface FindFilterOptions<T extends Entity> {
|
|
44
|
-
conditions?: ExpressionFilter;
|
|
45
|
-
orderBy?: OrderOf<T> | OrderOf<T>[];
|
|
46
|
-
softDeletes?: "include" | "exclude";
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Options for the non-batchable `em.findPaginated` queries, i.e. limit & offset are allowed.
|
|
50
|
-
*
|
|
51
|
-
* We allow `offset` to be optional, b/c sometimes queries will just want to do a `limit`, but we
|
|
52
|
-
* require `limit` to ensure the caller is using `findPaginated` for its intended purpose.
|
|
53
|
-
*/
|
|
54
|
-
export interface FindPaginatedFilterOptions<T extends Entity> extends FindFilterOptions<T> {
|
|
55
|
-
limit: number | undefined;
|
|
56
|
-
offset?: number;
|
|
57
|
-
}
|
|
58
|
-
export interface FindGqlPaginatedFilterOptions<T extends Entity> extends FindFilterOptions<T> {
|
|
59
|
-
limit?: number | null;
|
|
60
|
-
offset?: number | null;
|
|
61
|
-
}
|
|
62
|
-
/** Options for the `findCount`. */
|
|
63
|
-
export interface FindCountFilterOptions<T extends Entity> {
|
|
64
|
-
conditions?: ExpressionFilter;
|
|
65
|
-
softDeletes?: "include" | "exclude";
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Constructors for either concrete or abstract entity types.
|
|
69
|
-
*
|
|
70
|
-
* I.e. this is more like "MaybeAbstractEntityConstructor".
|
|
71
|
-
*/
|
|
72
|
-
export type MaybeAbstractEntityConstructor<T> = abstract new (em: EntityManager<any, any, any>, opts: any) => T;
|
|
73
|
-
/** Pulls the entity's id type out of a given entity type T. */
|
|
74
|
-
export type IdOf<T> = T extends {
|
|
75
|
-
id: infer I;
|
|
76
|
-
} ? I : never;
|
|
77
|
-
export type TaggedId = string;
|
|
78
|
-
export declare function isId(value: any): value is IdOf<unknown>;
|
|
79
|
-
export type EntityManagerHook = "beforeBegin" | "afterBegin" | "beforeCommit" | "afterCommit";
|
|
80
|
-
type HookFn<TX> = (em: EntityManager, txn: TX) => MaybePromise<any>;
|
|
81
|
-
export type LoaderCache = Record<string, DataLoader<any, any>>;
|
|
82
|
-
export interface TimestampFields {
|
|
83
|
-
updatedAt: string | undefined;
|
|
84
|
-
createdAt: string | undefined;
|
|
85
|
-
deletedAt: string | undefined;
|
|
86
|
-
}
|
|
87
|
-
export type EntityManagerOpts<TX = unknown> = ({
|
|
88
|
-
driver: Driver<TX>;
|
|
89
|
-
em?: undefined;
|
|
90
|
-
} | {
|
|
91
|
-
driver?: undefined;
|
|
92
|
-
em: EntityManager<any, any, any>;
|
|
93
|
-
}) & {
|
|
94
|
-
preloadPlugin?: PreloadPlugin;
|
|
95
|
-
};
|
|
96
|
-
export interface FlushOptions {
|
|
97
|
-
/** Skip all validations, including reactive validations, when flushing */
|
|
98
|
-
skipValidation?: boolean;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Describes the EntityManager read/write mode.
|
|
102
|
-
*
|
|
103
|
-
* - `read-only` -- any entity mutations or `em.flush` calls will fail fast
|
|
104
|
-
* - `in-memory-writes` -- allows entity mutations and `em.flush` w/o a `COMMIT`
|
|
105
|
-
* - `writes` -- allows entity mutations and `em.flush` will `COMMIT` writes
|
|
106
|
-
*/
|
|
107
|
-
export type EntityManagerMode = "read-only" | "in-memory-writes" | "writes";
|
|
108
|
-
export type FindOperation = typeof findOperation | "findPaginated" | typeof findByUniqueOperation | typeof findCountOperation | typeof findIdsOperation | typeof lensOperation | typeof loadOperation | typeof manyToManyLoadOperation | typeof manyToManyFindOperation | typeof oneToManyLoadOperation | typeof oneToManyFindOperation | typeof oneToOneLoadOperation | typeof populateOperation | typeof recursiveChildrenOperation | typeof recursiveParentsOperation;
|
|
109
|
-
/**
|
|
110
|
-
* The EntityManager is the primary way nearly all code, i.e. anything that finds/creates/updates/deletes entities,
|
|
111
|
-
* will interact with the database.
|
|
112
|
-
*
|
|
113
|
-
* It acts both an Identity Cache (preventing loading the same row twice into memory as separate entities, and then
|
|
114
|
-
* having drift between the two instances) and as a Unit of Work (tracking all changes to entities and then batch
|
|
115
|
-
* flushing only the entities that have changed).
|
|
116
|
-
*
|
|
117
|
-
* Note that the type parameters (C, I, and Entity) will be filled in by codegen with the values specific to your
|
|
118
|
-
* application, so you can import your app-specific EntityManager like:
|
|
119
|
-
*
|
|
120
|
-
* ```ts
|
|
121
|
-
* import { EntityManager } from "src/entities";
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* @param C The type of your application-specific app-wide/request-wide Context object that will be passed to hooks
|
|
125
|
-
* @typeParam C - the application-specific context (typically the request-level context)
|
|
126
|
-
* @typeParam Entity - the application's based entity type (i.e. with number ids or string ids)
|
|
127
|
-
* @typeParamTX - the application's Transaction type, i.e. `Knex`
|
|
128
|
-
*/
|
|
129
|
-
export declare class EntityManager<C = unknown, Entity extends EntityW = EntityW, TX extends unknown = unknown> {
|
|
130
|
-
#private;
|
|
131
|
-
readonly ctx: C;
|
|
132
|
-
driver: Driver<TX>;
|
|
133
|
-
/** When we're flushing, the connection/transaction. */
|
|
134
|
-
txn: TX | undefined;
|
|
135
|
-
entityLimit: number;
|
|
136
|
-
private __api;
|
|
137
|
-
mode: EntityManagerMode;
|
|
138
|
-
constructor(ctx: C, opts: EntityManagerOpts<TX>);
|
|
139
|
-
constructor(ctx: C, driver: Driver<TX>);
|
|
140
|
-
/** Returns a read-only shallow copy of the currently-loaded entities. */
|
|
141
|
-
get entities(): ReadonlyArray<Entity>;
|
|
142
|
-
/** Returns a read-only list of the currently-loaded entities of `type`. */
|
|
143
|
-
getEntities<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): ReadonlyArray<T>;
|
|
144
|
-
/** Looks up `id` in the list of already-loaded entities. */
|
|
145
|
-
getEntity<T extends Entity & {
|
|
146
|
-
id: string;
|
|
147
|
-
}>(id: IdOf<T>): T | undefined;
|
|
148
|
-
getEntity(id: TaggedId): Entity | undefined;
|
|
149
|
-
/**
|
|
150
|
-
* Finds entities of `type` with the `where` filter, with auto-batching, so this method
|
|
151
|
-
* will not cause N+1s if called in a loop.
|
|
152
|
-
*
|
|
153
|
-
* The `where` filter is one of Joist's "join literals", which can combine both joining into
|
|
154
|
-
* related entities and simple column conditions in a single literal. All conditions are ANDed.
|
|
155
|
-
* For more complex conditions, use the `find` overload that has a `conditions` option.
|
|
156
|
-
*
|
|
157
|
-
* This method is batch-friendly, i.e. if called in a loop, it will be automatically batched
|
|
158
|
-
* to avoid N+1s. Because of this, it cannot be used with queries that want to use `LIMIT`
|
|
159
|
-
* or `OFFSET`; for those, see `findPaginated`.
|
|
160
|
-
*/
|
|
161
|
-
find<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>): Promise<T[]>;
|
|
162
|
-
find<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options?: FindFilterOptions<T> & {
|
|
163
|
-
populate?: H;
|
|
164
|
-
}): Promise<Loaded<T, H>[]>;
|
|
165
|
-
/**
|
|
166
|
-
* Finds entities of `type` with the `where` filter, without auto-batching, so this method
|
|
167
|
-
* may call N+1s if called in a loop.
|
|
168
|
-
*
|
|
169
|
-
* The `where` filter is one of Joist's "join literals", which can combine both joining into
|
|
170
|
-
* related entities and simple column conditions in a single literal. All conditions are ANDed.
|
|
171
|
-
* For more complex conditions, use the `find` overload that has a `conditions` option.
|
|
172
|
-
*
|
|
173
|
-
* This method is *NOT* batch-friendly, i.e. if called in a loop, it will cause N+1s. Because
|
|
174
|
-
* of this, you should prefer using `find`, unless you explicitly pagination support.
|
|
175
|
-
*/
|
|
176
|
-
findPaginated<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options: FindPaginatedFilterOptions<T>): Promise<T[]>;
|
|
177
|
-
findPaginated<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options: FindPaginatedFilterOptions<T> & {
|
|
178
|
-
populate: H;
|
|
179
|
-
}): Promise<Loaded<T, H>[]>;
|
|
180
|
-
private executeFind;
|
|
181
|
-
/**
|
|
182
|
-
* Works exactly like `find` but accepts "less than greatly typed" GraphQL filters.
|
|
183
|
-
*
|
|
184
|
-
* I.e. filtering by `null` on fields that are non-`nullable`.
|
|
185
|
-
*/
|
|
186
|
-
findGql<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: GraphQLFilterWithAlias<T>): Promise<T[]>;
|
|
187
|
-
findGql<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: GraphQLFilterWithAlias<T>, options?: FindFilterOptions<T> & {
|
|
188
|
-
populate?: H;
|
|
189
|
-
}): Promise<Loaded<T, H>[]>;
|
|
190
|
-
/**
|
|
191
|
-
* Works exactly like `findPaginated` but accepts "less than greatly typed" GraphQL filters.
|
|
192
|
-
*
|
|
193
|
-
* I.e. filtering by `null` on fields that are non-`nullable`.
|
|
194
|
-
*/
|
|
195
|
-
findGqlPaginated<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: GraphQLFilterWithAlias<T>, options: FindGqlPaginatedFilterOptions<T>): Promise<T[]>;
|
|
196
|
-
findGqlPaginated<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: GraphQLFilterWithAlias<T>, options: FindGqlPaginatedFilterOptions<T> & {
|
|
197
|
-
populate: H;
|
|
198
|
-
}): Promise<Loaded<T, H>[]>;
|
|
199
|
-
findOne<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>): Promise<T | undefined>;
|
|
200
|
-
findOne<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options?: FindFilterOptions<T> & {
|
|
201
|
-
populate?: H;
|
|
202
|
-
}): Promise<Loaded<T, H> | undefined>;
|
|
203
|
-
/** Executes a given query filter and returns exactly one result, otherwise throws `NotFoundError` or `TooManyError`. */
|
|
204
|
-
findOneOrFail<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>): Promise<T>;
|
|
205
|
-
findOneOrFail<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options: FindFilterOptions<T> & {
|
|
206
|
-
populate?: H;
|
|
207
|
-
}): Promise<Loaded<T, H>>;
|
|
208
|
-
findByUnique<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: UniqueFilter<T>): Promise<T | undefined>;
|
|
209
|
-
findByUnique<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: UniqueFilter<T>, options?: {
|
|
210
|
-
populate?: H;
|
|
211
|
-
softDeletes?: "include" | "exclude";
|
|
212
|
-
}): Promise<Loaded<T, H> | undefined>;
|
|
213
|
-
/**
|
|
214
|
-
* Returns the count of entities that match the `where` clause.
|
|
215
|
-
*
|
|
216
|
-
* The `where` clause, and any options.conditions, matches the same syntax
|
|
217
|
-
* as `em.find`.
|
|
218
|
-
*
|
|
219
|
-
* Note: this method is not currently auto-batched, so it will cause N+1s if called in a loop.
|
|
220
|
-
*/
|
|
221
|
-
findCount<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options?: FindCountFilterOptions<T>): Promise<number>;
|
|
222
|
-
/**
|
|
223
|
-
* Returns the IDs of entities that match the `where` clause.
|
|
224
|
-
*
|
|
225
|
-
* The `where` clause, and any options.conditions, matches the same syntax
|
|
226
|
-
* as `em.find`.
|
|
227
|
-
*/
|
|
228
|
-
findIds<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options?: FindCountFilterOptions<T>): Promise<string[]>;
|
|
229
|
-
/**
|
|
230
|
-
* Looks for entities that match `where`, both in the database and any just-created or just-changed entities.
|
|
231
|
-
*
|
|
232
|
-
* Because we evaluate this `where` clause in memory (against any WIP changes made to entities
|
|
233
|
-
* that have not yet been `em.flush`ed to the database), the `where` clause is limited to fields
|
|
234
|
-
* immediately available on the entity, i.e. primitives, enums, and many-to-ones, without any
|
|
235
|
-
* nested, cross-table joins/conditions.
|
|
236
|
-
*
|
|
237
|
-
* For `m2o` fields, `undefined` will be pruned, just like `em.find`s. I.e. `{ publisher: undefined }` will
|
|
238
|
-
* be pruned and not filter on `publisher` at all, where as `{ publisher: null }` will filter for `publisher`
|
|
239
|
-
* is unset.
|
|
240
|
-
*
|
|
241
|
-
* @param type the entity type to find
|
|
242
|
-
* @param where the fields to look up the existing entity by
|
|
243
|
-
*/
|
|
244
|
-
findWithNewOrChanged<T extends Entity, F extends Partial<OptsOf<T>>>(type: EntityConstructor<T>, where: F): Promise<T[]>;
|
|
245
|
-
findWithNewOrChanged<T extends Entity, F extends Partial<OptsOf<T>>, const H extends LoadHint<T>>(type: EntityConstructor<T>, where: F, options?: {
|
|
246
|
-
populate?: H;
|
|
247
|
-
softDeletes?: "include" | "exclude";
|
|
248
|
-
}): Promise<Loaded<T, H>[]>;
|
|
249
|
-
/**
|
|
250
|
-
* Conditionally finds or creates (or upserts) an Entity.
|
|
251
|
-
*
|
|
252
|
-
* The `where` param is used to find the existing/if any entity; if not found,
|
|
253
|
-
* then one will be created.
|
|
254
|
-
*
|
|
255
|
-
* The `ifNew` param will be used, if no entity is found, for the `em.create` call;
|
|
256
|
-
* it is typed such that it will require all opts necessary for the `em.create` to
|
|
257
|
-
* be valid, _unless_ those opts are already included in either the `where` or
|
|
258
|
-
* `upsert` params.
|
|
259
|
-
*
|
|
260
|
-
* The optional `upsert` param are fields to always set/update, regardless of whether
|
|
261
|
-
* the entity is created or not.
|
|
262
|
-
*
|
|
263
|
-
* @param type the entity type to find/create
|
|
264
|
-
* @param where the fields to look up the existing entity by
|
|
265
|
-
* @param ifNew the fields to set if the entity is new
|
|
266
|
-
* @param upsert the fields to update if the entity is either existing or new
|
|
267
|
-
*/
|
|
268
|
-
findOrCreate<T extends EntityW, F extends Partial<OptsOf<T>>, U extends Partial<OptsOf<T>> | {}, N extends Omit<OptsOf<T>, keyof F | keyof U>>(type: EntityConstructor<T>, where: F, ifNew: N, upsert?: U): Promise<T>;
|
|
269
|
-
findOrCreate<T extends EntityW, F extends Partial<OptsOf<T>>, U extends Partial<OptsOf<T>> | {}, N extends Omit<OptsOf<T>, keyof F | keyof U>, const H extends LoadHint<T>>(type: EntityConstructor<T>, where: F, ifNew: N, upsert?: U, options?: {
|
|
270
|
-
populate?: H;
|
|
271
|
-
softDeletes?: "include" | "exclude";
|
|
272
|
-
}): Promise<Loaded<T, H>>;
|
|
273
|
-
/** Creates a new `type` and marks it as loaded, i.e. we know its collections are all safe to access in memory. */
|
|
274
|
-
create<T extends EntityW, O extends OptsOf<T>>(type: EntityConstructor<T>, opts: O): New<T, O>;
|
|
275
|
-
/**
|
|
276
|
-
* Creates a new `type` but with `opts` that are nullable, to accept partial-update-style input.
|
|
277
|
-
*
|
|
278
|
-
* Note that `createPartial` doesn't support the full upsert behavior, i.e. this method:
|
|
279
|
-
*
|
|
280
|
-
* - always creates,
|
|
281
|
-
* - does not support relation markers like `op`, `delete`, and `remove`,
|
|
282
|
-
* - does not accept deep input, but
|
|
283
|
-
* - fields set to `undefined` will be skipped instead of unset
|
|
284
|
-
*
|
|
285
|
-
* See `upsert` for the upsert/deep upsert behavior.
|
|
286
|
-
*/
|
|
287
|
-
createPartial<T extends EntityW>(type: EntityConstructor<T>, opts: PartialOrNull<OptsOf<T>>): T;
|
|
288
|
-
/**
|
|
289
|
-
* Create or updates `type` based on partial-update-style `input`.
|
|
290
|
-
*
|
|
291
|
-
* This supports upsert behavior, i.e.:
|
|
292
|
-
*
|
|
293
|
-
* - findOrCreate the primary entity being updated (based on the `id` key being provided),
|
|
294
|
-
* - upsert relation markers like `op`, `delete`, and `remove` are supported,
|
|
295
|
-
* - deep input is supported, i.e. `{ firstName: "Bob", books: [{ title: "b1" } ] }`, and
|
|
296
|
-
* - fields set to `undefined` will be skipped instead of unset
|
|
297
|
-
*/
|
|
298
|
-
upsert<T extends EntityW>(type: EntityConstructor<T>, input: DeepPartialOrNull<T>): Promise<T>;
|
|
299
|
-
/**
|
|
300
|
-
* Utility to clone an entity and its nested relations, as determined by a populate hint
|
|
301
|
-
*
|
|
302
|
-
* @param entity - Any entity
|
|
303
|
-
* @param opts - Options to control the clone behaviour
|
|
304
|
-
* @param deep - Populate hint of the nested tree of objects to clone
|
|
305
|
-
* @param skip - Keys that will be skipped in the clone
|
|
306
|
-
* @param skipIf - Predicate for determining if a specific entity should be skipped (and any entities beneath it
|
|
307
|
-
* @param postClone - Function to be called for each original/clone entity for any post-processing needed
|
|
308
|
-
* @returns The `Loaded` cloned entity or fails if the clone could not be made
|
|
309
|
-
*
|
|
310
|
-
* @example
|
|
311
|
-
* // This will duplicate the author
|
|
312
|
-
* const duplicatedAuthor = await em.clone(author)
|
|
313
|
-
*
|
|
314
|
-
* @example
|
|
315
|
-
* // This will duplicate the author and all their related book entities
|
|
316
|
-
* const duplicatedAuthorAndBooks = await em.clone(author, { deep: "books" })
|
|
317
|
-
*
|
|
318
|
-
* @example
|
|
319
|
-
* // This will duplicate the author, all their books, and the images for those books
|
|
320
|
-
* const duplicatedAuthorAndBooksAndImages = await em.clone(author, { deep: { books: "image" } })
|
|
321
|
-
*
|
|
322
|
-
* @example
|
|
323
|
-
* // This will duplicate the author, and rename
|
|
324
|
-
* const duplicatedAuthor = await em.clone(author, { postClone: (_original, clone) => clone.firstName = clone.firstName + " COPY" })
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* // This will duplicate the author, but skip any book where the title includes `sea`
|
|
328
|
-
* const duplicatedAuthor = await em.clone(author, { skipIf: (original) => original.title?.includes("sea") })
|
|
329
|
-
*/
|
|
330
|
-
clone<T extends Entity, H extends LoadHint<T>, const K = ReactiveHint<T>>(entity: T, opts?: {
|
|
331
|
-
deep?: H;
|
|
332
|
-
skip?: K;
|
|
333
|
-
skipIf?: (entity: Entity) => boolean;
|
|
334
|
-
postClone?: (original: Entity, clone: Entity) => void;
|
|
335
|
-
}): Promise<Loaded<T, H>>;
|
|
336
|
-
/**
|
|
337
|
-
* Utility to clone an entity and its nested relations, as determined by a populate hint.
|
|
338
|
-
*
|
|
339
|
-
* @param entities - Any homogeneous list of entities
|
|
340
|
-
* @param opts - Options to control the clone behaviour
|
|
341
|
-
* @param deep - Populate hint of the nested tree of objects to clone
|
|
342
|
-
* @param skip - Keys that will be skipped in the clone
|
|
343
|
-
* @param skipIf - Predicate for determining if a specific entity should be skipped (and any entities beneath it
|
|
344
|
-
* @param postClone - Function to be called for each original/clone entity for any post-processing needed
|
|
345
|
-
* @returns Array of `Loaded` cloned entities from the provided list or empty array if all are skipped
|
|
346
|
-
*
|
|
347
|
-
* @example
|
|
348
|
-
* // This will duplicate the author's books
|
|
349
|
-
* const duplicatedBooks = await em.clone(author.books.get)
|
|
350
|
-
*
|
|
351
|
-
* @example
|
|
352
|
-
* // This will duplicate the author's books, all their books, and the images for those books
|
|
353
|
-
* const duplicatedBooksAndImages = await em.clone(author.books.get, { deep: { books: "image" } })
|
|
354
|
-
*
|
|
355
|
-
* @example
|
|
356
|
-
* // This will duplicate the author's books, and assign them to a different author
|
|
357
|
-
* const duplicatedBooks = await em.clone(author.books.get, { postClone: (_original, clone) => clone.author.set(author2) })
|
|
358
|
-
*
|
|
359
|
-
* @example
|
|
360
|
-
* // This will duplicate the author's books, but skip any book where the title includes `sea`
|
|
361
|
-
* const duplicatedBooks = await em.clone(author.books.get, { skipIf: (original) => original.title.includes("sea") })
|
|
362
|
-
*/
|
|
363
|
-
clone<T extends Entity, H extends LoadHint<T>, const K = ReactiveHint<T>>(entities: readonly T[], opts?: {
|
|
364
|
-
deep?: H;
|
|
365
|
-
skip?: K;
|
|
366
|
-
skipIf?: (entity: Entity) => boolean;
|
|
367
|
-
postClone?: (original: Entity, clone: Entity) => void;
|
|
368
|
-
}): Promise<Loaded<T, H>[]>;
|
|
369
|
-
/**
|
|
370
|
-
* Merges multiple source entities into a target entity by updating all references that point
|
|
371
|
-
* to the source entities to instead point to the target entity.
|
|
372
|
-
*
|
|
373
|
-
* This method loads all relations from the source entities, updates any entity that
|
|
374
|
-
* references a source entity to reference the target entity instead, and then automatically
|
|
375
|
-
* deletes the source entities.
|
|
376
|
-
*
|
|
377
|
-
* @param target - The entity that will become the target of all merged references
|
|
378
|
-
* @param sources - Array of entities whose references will be redirected to the target
|
|
379
|
-
* @param opts - Options to control merge behavior
|
|
380
|
-
* @param autoDelete - Whether to automatically delete source entities (default: true)
|
|
381
|
-
* @returns Promise that resolves when all references have been updated and sources deleted
|
|
382
|
-
*
|
|
383
|
-
* @example
|
|
384
|
-
* // Merge duplicate authors - all books pointing to author2 will now point to author1
|
|
385
|
-
* // author2 will be automatically deleted
|
|
386
|
-
* await em.merge(author1, [author2]);
|
|
387
|
-
*
|
|
388
|
-
* @example
|
|
389
|
-
* // Merge multiple duplicate publishers into one
|
|
390
|
-
* // publisher2 and publisher3 will be automatically deleted
|
|
391
|
-
* await em.merge(publisher1, [publisher2, publisher3]);
|
|
392
|
-
*
|
|
393
|
-
* @example
|
|
394
|
-
* // Merge without auto-deleting sources (for custom cleanup logic)
|
|
395
|
-
* await em.merge(author1, [author2], { autoDelete: false });
|
|
396
|
-
* // Custom logic here...
|
|
397
|
-
* em.delete(author2);
|
|
398
|
-
*/
|
|
399
|
-
merge<T extends Entity>(target: T, sources: T[], opts?: {
|
|
400
|
-
autoDelete?: boolean;
|
|
401
|
-
}): Promise<Entity[]>;
|
|
402
|
-
/** Returns an instance of `type` for the given `id`, resolving to an existing instance if in our Unit of Work. */
|
|
403
|
-
load<T extends EntityW & {
|
|
404
|
-
id: string;
|
|
405
|
-
}>(id: IdOf<T>): Promise<T>;
|
|
406
|
-
load(id: TaggedId): Promise<Entity>;
|
|
407
|
-
load<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, id: IdOf<T> | TaggedId): Promise<T>;
|
|
408
|
-
load<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, id: IdOf<T> | TaggedId, populate: H): Promise<Loaded<T, H>>;
|
|
409
|
-
/** Returns instances of `type` for the given `ids`, resolving to an existing instance if in our Unit of Work. */
|
|
410
|
-
loadAll<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, ids: readonly string[]): Promise<T[]>;
|
|
411
|
-
loadAll<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, ids: readonly string[], populate: H): Promise<Loaded<T, H>[]>;
|
|
412
|
-
/**
|
|
413
|
-
* Returns instances of `type` for the given `ids`, resolving to an existing instance if in our Unit of Work. Ignores
|
|
414
|
-
* IDs that are not found.
|
|
415
|
-
*/
|
|
416
|
-
loadAllIfExists<T extends EntityW>(type: EntityConstructor<T>, ids: readonly string[]): Promise<T[]>;
|
|
417
|
-
loadAllIfExists<T extends EntityW, const H extends LoadHint<T>>(type: EntityConstructor<T>, ids: readonly string[], populate: H): Promise<Loaded<T, H>[]>;
|
|
418
|
-
/**
|
|
419
|
-
* Loads entities found, when starting at `entities`, via the "path" given by the `fn` lens function.
|
|
420
|
-
*
|
|
421
|
-
* Results are unique, i.e. if doing `em.loadLens([b1, b2], b => b.author.publisher)` point to the
|
|
422
|
-
* same `Publisher`, it will only be returned as a single value.
|
|
423
|
-
*/
|
|
424
|
-
loadLens<T extends EntityW, U, V>(entities: readonly T[], fn: (lens: Lens<T>) => Lens<U, V>): Promise<U[]>;
|
|
425
|
-
loadLens<T extends EntityW, U extends EntityW, V, const H extends LoadHint<U>>(entities: readonly T[], fn: (lens: Lens<T>) => Lens<U, V>, populate: H): Promise<Loaded<U, H>[]>;
|
|
426
|
-
/**
|
|
427
|
-
* Loads entities from database rows that were queried directly using a query builder.
|
|
428
|
-
*
|
|
429
|
-
* This overload is synchronous since there is no population/querying to do.
|
|
430
|
-
*/
|
|
431
|
-
loadFromQuery<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, rows: readonly unknown[]): T[];
|
|
432
|
-
/**
|
|
433
|
-
* Loads entities from database rows from a Knex-ish query builder that needs an `await`.
|
|
434
|
-
*
|
|
435
|
-
* This overload is async because it triggers the `rows` query.
|
|
436
|
-
*/
|
|
437
|
-
loadFromQuery<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, rows: PromiseLike<readonly unknown[]>): Promise<T[]>;
|
|
438
|
-
/**
|
|
439
|
-
* Loads & populates entities from database rows that were queried directly using a query builder.
|
|
440
|
-
*/
|
|
441
|
-
loadFromQuery<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, rows: readonly unknown[], populate: H): Promise<Loaded<T, H>[]>;
|
|
442
|
-
/**
|
|
443
|
-
* Loads & populates entities from database rows from a Knex-ish query builder that needs an `await`.
|
|
444
|
-
*/
|
|
445
|
-
loadFromQuery<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, rows: PromiseLike<readonly unknown[]>, populate: H): Promise<Loaded<T, H>[]>;
|
|
446
|
-
/** Loads entities from rows. */
|
|
447
|
-
loadFromRows<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, rows: unknown[]): Promise<T[]>;
|
|
448
|
-
loadFromRows<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, rows: unknown[], populate: H): Promise<Loaded<T, H>[]>;
|
|
449
|
-
/** Given a hint `H` (a field, array of fields, or nested hash), pre-load that data into `entity` for sync access. */
|
|
450
|
-
populate<T extends EntityW, const H extends LoadHint<T>, V = Loaded<T, H>>(entity: T, hint: H, fn?: (entity: Loaded<T, H>) => V): Promise<V>;
|
|
451
|
-
populate<T extends EntityW, const H extends LoadHint<T>, V = Loaded<T, H>>(entity: T, opts: {
|
|
452
|
-
hint: H;
|
|
453
|
-
forceReload?: boolean;
|
|
454
|
-
}, fn?: (entity: Loaded<T, H>) => V): Promise<V>;
|
|
455
|
-
populate<T extends EntityW, const H extends LoadHint<T>>(entities: ReadonlyArray<T>, hint: H): Promise<Loaded<T, H>[]>;
|
|
456
|
-
populate<T extends EntityW, const H extends LoadHint<T>>(entities: ReadonlyArray<T>, opts: {
|
|
457
|
-
hint: H;
|
|
458
|
-
forceReload?: boolean;
|
|
459
|
-
}): Promise<Loaded<T, H>[]>;
|
|
460
|
-
/**
|
|
461
|
-
* Executes `fn` with a transaction, and automatically calls `flush`/`commit` at the end.
|
|
462
|
-
*
|
|
463
|
-
* This ensures both any `.find` and `.flush` operations happen within the same
|
|
464
|
-
* transaction, which is useful for enforcing cross-table/application-level invariants that
|
|
465
|
-
* cannot be enforced with database-level constraints.
|
|
466
|
-
*/
|
|
467
|
-
transaction<T>(fn: (txn: TX) => Promise<T>): Promise<T>;
|
|
468
|
-
/**
|
|
469
|
-
* Marks an instance to be deleted.
|
|
470
|
-
*
|
|
471
|
-
* Any loaded collections that are currently "pointing to" this entity will be updated to
|
|
472
|
-
* no longer include this entity, i.e. if you `em.delete(b1)`, then `author.books` will have
|
|
473
|
-
* `b1` removed (if needed).
|
|
474
|
-
*
|
|
475
|
-
* This is done for all currently-loaded collections; i.e. technically unloaded collections
|
|
476
|
-
* may still point to this entity. We defer unsetting these not-currently-loaded references
|
|
477
|
-
* until `EntityManager.flush`, when we can make the async calls to load-and-unset them.
|
|
478
|
-
*/
|
|
479
|
-
delete(entity: Entity): void;
|
|
480
|
-
/**
|
|
481
|
-
* Marks entities to be deleted.
|
|
482
|
-
*
|
|
483
|
-
* Any loaded collections that are currently "pointing to" this entity will be updated to
|
|
484
|
-
* no longer include this entity, i.e. if you `em.delete(b1)`, then `author.books` will have
|
|
485
|
-
* `b1` removed (if needed).
|
|
486
|
-
*
|
|
487
|
-
* This is done for all currently-loaded collections; i.e. technically unloaded collections
|
|
488
|
-
* may still point to this entity. We defer unsetting these not-currently-loaded references
|
|
489
|
-
* until `EntityManager.flush`, when we can make the async calls to load-and-unset them.
|
|
490
|
-
*/
|
|
491
|
-
delete(entities: Entity[]): void;
|
|
492
|
-
assignNewIds(): Promise<void>;
|
|
493
|
-
/**
|
|
494
|
-
* Immediately assigns async defaults to `entities`.
|
|
495
|
-
*
|
|
496
|
-
* Normally async defaults wait until `em.flush` to run, because their async nature requires
|
|
497
|
-
* an `await` / `Promise` to be evaluated, and `em.create` is synchronous.
|
|
498
|
-
*
|
|
499
|
-
* This `assignDefaults` methods like you move that up, and immediately invoke
|
|
500
|
-
* any default logic against the `entities`.
|
|
501
|
-
*/
|
|
502
|
-
setDefaults(entities: Entity[]): Promise<void>;
|
|
503
|
-
/**
|
|
504
|
-
* Flushes the SQL for any changed entities to the database.
|
|
505
|
-
*
|
|
506
|
-
* If this is run outside of an existing transaction, it will `BEGIN` and `COMMIT`
|
|
507
|
-
* a new transaction on every `.flush()` call so that all of the `INSERT`s/etc.
|
|
508
|
-
* happen atomically.
|
|
509
|
-
*
|
|
510
|
-
* If this is run within an existing transaction, i.e. `EntityManager.transaction`,
|
|
511
|
-
* then it will only issue `INSERT`s/etc. and defer to the caller to `COMMIT`
|
|
512
|
-
* the transaction.
|
|
513
|
-
*
|
|
514
|
-
* It returns entities that have changed (an entity is considered changed if it has been deleted, inserted, or updated)
|
|
515
|
-
*/
|
|
516
|
-
flush(flushOptions?: FlushOptions): Promise<Entity[]>;
|
|
517
|
-
/**
|
|
518
|
-
* A very simple toJSON.
|
|
519
|
-
*
|
|
520
|
-
* This is not really meant to be useful, it's to prevent huge/circular output if
|
|
521
|
-
* an EntityManager accidentally ends up getting logged to something like pino that
|
|
522
|
-
* over-zealous toJSONs anything it touches.
|
|
523
|
-
*/
|
|
524
|
-
toJSON(): string;
|
|
525
|
-
/**
|
|
526
|
-
* For all entities in the current `EntityManager`, load their latest data from the database.
|
|
527
|
-
*
|
|
528
|
-
* This is primarily useful in tests, i.e. having 1 `EntityManager` with some test data, running business
|
|
529
|
-
* logic in a dedicated `EntityManager`, and then `refresh`-ing the test data `EntityManager` to assert
|
|
530
|
-
* against the latest values.
|
|
531
|
-
*
|
|
532
|
-
* This works with primitive fields as well as references and collections.
|
|
533
|
-
*
|
|
534
|
-
* TODO Newly-found collection entries will not have prior load hints applied to this, unless using
|
|
535
|
-
* `deepLoad` which should only be used by tests to avoid loading your entire database in memory.
|
|
536
|
-
*/
|
|
537
|
-
refresh(opts?: {
|
|
538
|
-
deepLoad?: boolean;
|
|
539
|
-
}): Promise<void>;
|
|
540
|
-
refresh(entity: EntityW): Promise<void>;
|
|
541
|
-
refresh(entities: ReadonlyArray<EntityW>): Promise<void>;
|
|
542
|
-
get numberOfEntities(): number;
|
|
543
|
-
findExistingInstance<T extends EntityW>(id: string): T | undefined;
|
|
544
|
-
/**
|
|
545
|
-
* Takes a result `row` from a custom query and maps the db values into a new-or-existing domain object for that row.
|
|
546
|
-
*
|
|
547
|
-
* The `overwriteExisting` controls whether `row`'s values should overwrite the existing fields on
|
|
548
|
-
* an entity. By default this is true, as we assume the user calling this means they know the DB has
|
|
549
|
-
* updated values that should be put into the entities. A few internal callers set this to false,
|
|
550
|
-
* i.e. when we're loading collections and have db results that are potentially stale compared to
|
|
551
|
-
* the WIP entity state.
|
|
552
|
-
*/
|
|
553
|
-
hydrate<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, rows: readonly any[], options?: {
|
|
554
|
-
overwriteExisting?: boolean;
|
|
555
|
-
}): T[];
|
|
556
|
-
/**
|
|
557
|
-
* Mark an entity as needing to be flushed regardless of its state.
|
|
558
|
-
*
|
|
559
|
-
* This will:
|
|
560
|
-
*
|
|
561
|
-
* - Bump the entity's `updated_at` timestamp (if available),
|
|
562
|
-
* - Run `beforeUpdate` and `beforeFlush` hooks.
|
|
563
|
-
*/
|
|
564
|
-
touch(entity: EntityW): void;
|
|
565
|
-
touch(entities: EntityW[]): void;
|
|
566
|
-
/**
|
|
567
|
-
* Recalculates the reactive fields for an entity, and any downstream reactive fields or reactions that depend on them.
|
|
568
|
-
*
|
|
569
|
-
* You shouldn't need to call this unless the derived fields have drifted from the underlying data, which
|
|
570
|
-
* should only happen if:
|
|
571
|
-
*
|
|
572
|
-
* - The underlying data was changed by a raw SQL query, or
|
|
573
|
-
* - You've changed the field's business logic and want to update the database to the latest value.
|
|
574
|
-
*
|
|
575
|
-
* You can also trigger a recalc for specific fields by calling `.load()` on the property, i.e.
|
|
576
|
-
* `author.numberOfBooks.load()`. This `recalc` method is just a helper method to call `load` for
|
|
577
|
-
* all derived fields on the given entity/entities.
|
|
578
|
-
*/
|
|
579
|
-
recalc(entity: EntityW): Promise<void>;
|
|
580
|
-
recalc(entities: EntityW[]): Promise<void>;
|
|
581
|
-
beforeBegin(fn: HookFn<TX>): void;
|
|
582
|
-
afterBegin(fn: HookFn<TX>): void;
|
|
583
|
-
beforeCommit(fn: HookFn<TX>): void;
|
|
584
|
-
afterCommit(fn: HookFn<TX>): void;
|
|
585
|
-
/**
|
|
586
|
-
* Returns an EntityManager-scoped (i.e. request scoped) data loader.
|
|
587
|
-
*
|
|
588
|
-
* @param operation the operation being batched, i.e. `load` or `o2m-load`, to avoid clashing batch keys
|
|
589
|
-
* across fundamentally different operations
|
|
590
|
-
* @param batchKey for a given operation, i.e. `load`, a batch key `Author` to batch all Author loads together
|
|
591
|
-
* @param fn the batch load function, i.e. that will accept all `.load(...)`-d Author ids to load as a single db call
|
|
592
|
-
* @param opts optional DataLoader options
|
|
593
|
-
* @returns a DataLoader scoped to the `operation` + `batchKey` combination
|
|
594
|
-
*/
|
|
595
|
-
getLoader<K, V>(operation: string, batchKey: string, fn: BatchLoadFn<K, V>, opts?: Options<K, V>): DataLoader<K, V>;
|
|
596
|
-
toString(): string;
|
|
597
|
-
/** Recursively cascades any pending deletions. */
|
|
598
|
-
private flushDeletes;
|
|
599
|
-
setReactionLogging(logger: ReactionLogger): void;
|
|
600
|
-
setReactionLogging(enabled: boolean): void;
|
|
601
|
-
/** Accepts `Author` or `Author.firstName,lastName` or `Author.lastName!`. */
|
|
602
|
-
setFieldLogging(spec: string): void;
|
|
603
|
-
/** Accepts `["Author.firstName,lastName", "Book.title"]`. */
|
|
604
|
-
setFieldLogging(spec: string[]): void;
|
|
605
|
-
/** Sets this EntityManager's field logger. */
|
|
606
|
-
setFieldLogging(logger: FieldLogger): void;
|
|
607
|
-
/** Enables/disables field logging for all fields. */
|
|
608
|
-
setFieldLogging(enabled: boolean): void;
|
|
609
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
610
|
-
/** Returns entities matching the filter using indexed search when available. */
|
|
611
|
-
filterEntities<T extends Entity>(cstr: EntityConstructor<T>, where: Partial<OptsOf<T>>): T[];
|
|
612
|
-
/**
|
|
613
|
-
* Creates a new EntityManager that shares the same entities as the current one but allows independent changes.
|
|
614
|
-
*
|
|
615
|
-
* This is useful for scenarios where you want to:
|
|
616
|
-
*
|
|
617
|
-
* - Preload data for use as a cache
|
|
618
|
-
* - Make speculative changes that may or may not be committed
|
|
619
|
-
* - Escape a transaction scope
|
|
620
|
-
*
|
|
621
|
-
* The fork will:
|
|
622
|
-
*
|
|
623
|
-
* - Copy all currently loaded entities to the new EntityManager
|
|
624
|
-
* - Copy any loaded relation data to keep `.isLoaded` / `.get` state consistent
|
|
625
|
-
* - Copy and update references to the EntityManager and its entities in the context, which is itself shallowly copied
|
|
626
|
-
*
|
|
627
|
-
* The fork will NOT:
|
|
628
|
-
*
|
|
629
|
-
* - Copy any pending changes (must call .flush() first)
|
|
630
|
-
* - Share any changes made in either EntityManager with the other
|
|
631
|
-
*
|
|
632
|
-
* @param opts options to control the fork behavior
|
|
633
|
-
* - allowPendingChanges - allows the em being forked to have pending changes and forces the resulting em to have
|
|
634
|
-
* `mode` set to "in-memory-writes". Changes to entities in the original em will be copied to the resulting em.
|
|
635
|
-
* Optional. default: false
|
|
636
|
-
*
|
|
637
|
-
* @throws {Error} If called on an EntityManager with pending changes
|
|
638
|
-
* @returns A new EntityManager with copied entity state
|
|
639
|
-
*/
|
|
640
|
-
fork(opts?: {
|
|
641
|
-
allowPendingChanges?: boolean;
|
|
642
|
-
}): EntityManager<C, Entity, TX>;
|
|
643
|
-
/**
|
|
644
|
-
* Copies an entity from one EntityManager to another, ensuring all relations specified in the hint are
|
|
645
|
-
* also copied.
|
|
646
|
-
*
|
|
647
|
-
* This method is primarily used when you need to move entities between different EntityManager instances
|
|
648
|
-
* while preserving their loaded state and relationships. This is useful for scenarios like:
|
|
649
|
-
*
|
|
650
|
-
* - Moving entities between transaction boundaries
|
|
651
|
-
* - Creating test fixtures that reference entities from a different EntityManager
|
|
652
|
-
* - Sharing entities between different parts of your application
|
|
653
|
-
*
|
|
654
|
-
* The migration process:
|
|
655
|
-
* 1. If the entity already exists in this EntityManager, returns it
|
|
656
|
-
* 2. Otherwise, creates a new instance with the same data
|
|
657
|
-
* 3. Recursively migrates any loaded relations specified in the hint
|
|
658
|
-
*
|
|
659
|
-
* @param source - The entity to migrate from another EntityManager
|
|
660
|
-
* @param hint - The load hint specifying which relations to migrate
|
|
661
|
-
* @returns The migrated entity with all specified relations loaded
|
|
662
|
-
*/
|
|
663
|
-
importEntity<T extends Entity>(original: T): T;
|
|
664
|
-
importEntity<T extends Entity, H extends LoadHint<T>, L extends Loaded<T, H>>(original: L, hint: H): L;
|
|
665
|
-
addPlugin(plugin: Plugin): void;
|
|
666
|
-
getPlugins(): readonly Plugin[];
|
|
667
|
-
get isRefreshing(): boolean;
|
|
668
|
-
get isFlushing(): boolean;
|
|
669
|
-
}
|
|
670
|
-
/** Provides an internal API to the `EntityManager`. */
|
|
671
|
-
export interface EntityManagerInternalApi {
|
|
672
|
-
joinRows: (m2m: ManyToManyLike) => JoinRows;
|
|
673
|
-
/** Map of taggedId -> fieldName -> pending children. */
|
|
674
|
-
pendingChildren: Map<string, Map<string, {
|
|
675
|
-
adds: Entity[];
|
|
676
|
-
removes: Entity[];
|
|
677
|
-
}>>;
|
|
678
|
-
/** List of mutated o2m collections to reset added/removed post-flush. */
|
|
679
|
-
mutatedCollections: Set<OneToManyCollection<any, any>>;
|
|
680
|
-
/** Map of taggedId -> fieldName -> join-loaded data. */
|
|
681
|
-
getPreloadedRelation<U>(taggedId: string, fieldName: string): U[] | undefined;
|
|
682
|
-
setPreloadedRelation<U>(taggedId: string, fieldName: string, children: U[]): void;
|
|
683
|
-
hooks: Record<EntityManagerHook, HookFn<any>[]>;
|
|
684
|
-
rm: ReactionsManager;
|
|
685
|
-
indexManager: IndexManager;
|
|
686
|
-
preloader: PreloadPlugin | undefined;
|
|
687
|
-
isValidating: boolean;
|
|
688
|
-
checkWritesAllowed: () => void;
|
|
689
|
-
isMerging: (entity: Entity) => boolean;
|
|
690
|
-
get fieldLogger(): FieldLogger | undefined;
|
|
691
|
-
get isLoadedCache(): IsLoadedCache;
|
|
692
|
-
pluginManager: PluginManager;
|
|
693
|
-
clearDataloaders(): void;
|
|
694
|
-
clearPreloadedRelations(): void;
|
|
695
|
-
setIsRefreshing(isRefreshing: boolean): void;
|
|
696
|
-
}
|
|
697
|
-
export declare function getEmInternalApi(em: EntityManager): EntityManagerInternalApi;
|
|
698
|
-
export declare function getDefaultEntityLimit(): number;
|
|
699
|
-
export declare function setDefaultEntityLimit(limit: number): void;
|
|
700
|
-
export declare function resetDefaultEntityLimit(): void;
|
|
701
|
-
export declare function isKey(k: any): k is string;
|
|
702
|
-
/** Compares `a` to `b`, where `b` might be an id. */
|
|
703
|
-
export declare function sameEntity(a: Entity | string | number | undefined, b: Entity | string | number | undefined): boolean;
|
|
704
|
-
/** Compares the value `a` to `b`, with handling of new entities w/o ids assigned yet. */
|
|
705
|
-
export declare function sameReference<T extends Entity>(a: Reference<any, T, any>, b: Reference<any, T, any>): boolean;
|
|
706
|
-
/** Thrown by `findOneOrFail`, 'load' & 'loadAll' if an entity is not found. */
|
|
707
|
-
export declare class NotFoundError extends Error {
|
|
708
|
-
}
|
|
709
|
-
/** Thrown by `findOne` and `findOneOrFail` if more than one entity is found. */
|
|
710
|
-
export declare class TooManyError extends Error {
|
|
711
|
-
constructor(message: string);
|
|
712
|
-
}
|
|
713
|
-
export declare function driverBeforeBegin<TXN>(em: EntityManager<any, any, TXN>, txn: TXN): Promise<unknown>;
|
|
714
|
-
export declare function driverAfterBegin<TXN>(em: EntityManager<any, any, TXN>, txn: TXN): Promise<unknown>;
|
|
715
|
-
export declare function driverBeforeCommit<TXN>(em: EntityManager<any, any, TXN>, txn: TXN): Promise<unknown>;
|
|
716
|
-
export declare function driverAfterCommit<TXN>(em: EntityManager<any, any, TXN>, txn: TXN): Promise<unknown>;
|
|
717
|
-
export declare function isDefined<T extends any>(param: T | undefined | null): param is T;
|
|
718
|
-
export declare function setLastNow(now: Date | undefined): void;
|
|
719
|
-
/** An error thrown when `em.mode === "read-only"` but entities are mutated/flushed. */
|
|
720
|
-
export declare class ReadOnlyError extends Error {
|
|
721
|
-
constructor();
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Given an `err` thrown in "a different context", i.e. a database error or dataloader error
|
|
725
|
-
* that doesn't include our stack trace, append our stack for better debugging.
|
|
726
|
-
*
|
|
727
|
-
* See https://github.com/brianc/node-postgres/pull/2983
|
|
728
|
-
*/
|
|
729
|
-
export declare function appendStack(err: unknown, dummy: Error): unknown;
|
|
730
|
-
export declare function createRowFromEntityData(e: Entity, opts?: {
|
|
731
|
-
preferOriginalData?: boolean;
|
|
732
|
-
}): Record<string, any>;
|
|
733
|
-
export {};
|
|
734
|
-
//# sourceMappingURL=EntityManager.d.ts.map
|