@punks/backend-entity-manager 0.0.401 → 0.0.404
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/dist/cjs/index.js +23 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/repository.d.ts +7 -0
- package/dist/cjs/types/integrations/repository/typeorm/repository.d.ts +7 -1
- package/dist/cjs/types/testing/mocks/repository.d.ts +7 -0
- package/dist/esm/index.js +23 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/repository.d.ts +7 -0
- package/dist/esm/types/integrations/repository/typeorm/repository.d.ts +7 -1
- package/dist/esm/types/testing/mocks/repository.d.ts +7 -0
- package/dist/index.d.ts +12 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EntityReference } from "../models";
|
|
1
2
|
import { DeepPartial } from "../types";
|
|
2
3
|
export interface IEntitiesDeleteResult {
|
|
3
4
|
deletedCount: number;
|
|
@@ -9,6 +10,8 @@ export interface IEntityRepository<TEntity, TEntityId, TGetConditions, TFindCond
|
|
|
9
10
|
getBy(condition: TGetConditions): Promise<TEntity | undefined>;
|
|
10
11
|
all(): Promise<TEntity[]>;
|
|
11
12
|
find(condition: TFindCondition): Promise<TEntity[]>;
|
|
13
|
+
findOne(condition: TFindCondition): Promise<TEntity | undefined>;
|
|
14
|
+
findOneOrFail(condition: TFindCondition): Promise<TEntity>;
|
|
12
15
|
findById(id: TEntityId[]): Promise<TEntity[]>;
|
|
13
16
|
count(condition: TFindCondition): Promise<number>;
|
|
14
17
|
delete(id: TEntityId): Promise<void>;
|
|
@@ -17,4 +20,8 @@ export interface IEntityRepository<TEntity, TEntityId, TGetConditions, TFindCond
|
|
|
17
20
|
update(id: TEntityId, entity: DeepPartial<TEntity>): Promise<TEntity>;
|
|
18
21
|
updateBy(entity: DeepPartial<TEntity>, condition: TUpdateCondition): Promise<TEntity[]>;
|
|
19
22
|
upsert(id: TEntityId, entity: DeepPartial<TEntity>): Promise<TEntity>;
|
|
23
|
+
upsertBy({ data, filter, }: {
|
|
24
|
+
data: Partial<TEntity>;
|
|
25
|
+
filter: TFindCondition;
|
|
26
|
+
}): Promise<EntityReference<string>>;
|
|
20
27
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FindManyOptions, FindOneOptions, FindOptionsRelations, FindOptionsWhere, ObjectId, ObjectLiteral, Repository } from "typeorm";
|
|
2
2
|
import { IEntityRepository } from "../../../abstractions";
|
|
3
3
|
import { IEntitiesDeleteResult } from "../../../abstractions/repository";
|
|
4
|
+
import { EntityReference } from "../../../models";
|
|
4
5
|
export type UpdateCriteria<TEntity extends ObjectLiteral> = string | string[] | number | number[] | Date | Date[] | ObjectId | ObjectId[] | FindOptionsWhere<TEntity>;
|
|
5
6
|
export type DeleteCriteria<TEntity extends ObjectLiteral> = string | string[] | number | number[] | Date | Date[] | ObjectId | ObjectId[] | FindOptionsWhere<TEntity>;
|
|
6
7
|
export declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId> implements IEntityRepository<TEntity, TEntityId, FindOneOptions<TEntity>, FindManyOptions<TEntity>, UpdateCriteria<TEntity>, DeleteCriteria<TEntity>> {
|
|
@@ -18,7 +19,8 @@ export declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId>
|
|
|
18
19
|
all(): Promise<TEntity[]>;
|
|
19
20
|
count(condition: FindManyOptions<TEntity>): Promise<number>;
|
|
20
21
|
find(condition: FindManyOptions<TEntity>): Promise<TEntity[]>;
|
|
21
|
-
findOne(condition: FindManyOptions<TEntity>): Promise<TEntity>;
|
|
22
|
+
findOne(condition: FindManyOptions<TEntity>): Promise<TEntity | undefined>;
|
|
23
|
+
findOneOrFail(condition: FindManyOptions<TEntity>): Promise<TEntity>;
|
|
22
24
|
findById(id: TEntityId[]): Promise<TEntity[]>;
|
|
23
25
|
delete(id: TEntityId): Promise<void>;
|
|
24
26
|
deleteBy(condition: DeleteCriteria<TEntity>): Promise<IEntitiesDeleteResult>;
|
|
@@ -26,4 +28,8 @@ export declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId>
|
|
|
26
28
|
update(id: TEntityId, entity: Partial<TEntity>): Promise<TEntity>;
|
|
27
29
|
updateBy(entity: Partial<TEntity>, condition: UpdateCriteria<TEntity>): Promise<TEntity[]>;
|
|
28
30
|
upsert(id: TEntityId, entity: Partial<TEntity>): Promise<TEntity>;
|
|
31
|
+
upsertBy({ data, filter, }: {
|
|
32
|
+
data: Partial<TEntity>;
|
|
33
|
+
filter: FindManyOptions<TEntity>;
|
|
34
|
+
}): Promise<EntityReference<string>>;
|
|
29
35
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FilterExpression } from "../../abstractions/filters";
|
|
2
2
|
import { IEntitiesDeleteResult, IEntityRepository } from "../../abstractions/repository";
|
|
3
|
+
import { EntityReference } from "../../models";
|
|
3
4
|
export declare class InMemoryRepository<TEntity> implements IEntityRepository<TEntity, string, FilterExpression<TEntity>, FilterExpression<TEntity>, FilterExpression<TEntity>, FilterExpression<TEntity>> {
|
|
4
5
|
private entities;
|
|
5
6
|
exists(id: string): Promise<boolean>;
|
|
@@ -8,6 +9,8 @@ export declare class InMemoryRepository<TEntity> implements IEntityRepository<TE
|
|
|
8
9
|
getBy(condition: FilterExpression<TEntity>): Promise<TEntity | undefined>;
|
|
9
10
|
all(): Promise<TEntity[]>;
|
|
10
11
|
find(condition: FilterExpression<TEntity>): Promise<TEntity[]>;
|
|
12
|
+
findOne(condition: FilterExpression<TEntity>): Promise<TEntity | undefined>;
|
|
13
|
+
findOneOrFail(condition: FilterExpression<TEntity>): Promise<TEntity>;
|
|
11
14
|
count(condition: FilterExpression<TEntity>): Promise<number>;
|
|
12
15
|
findById(id: string[]): Promise<TEntity[]>;
|
|
13
16
|
delete(id: string): Promise<void>;
|
|
@@ -16,6 +19,10 @@ export declare class InMemoryRepository<TEntity> implements IEntityRepository<TE
|
|
|
16
19
|
update(id: string, entity: Partial<TEntity>): Promise<TEntity>;
|
|
17
20
|
updateBy(entity: Partial<TEntity>, condition: FilterExpression<TEntity>): Promise<TEntity[]>;
|
|
18
21
|
upsert(id: string, entity: TEntity): Promise<TEntity>;
|
|
22
|
+
upsertBy({ data, filter, }: {
|
|
23
|
+
data: Partial<TEntity>;
|
|
24
|
+
filter: FilterExpression<TEntity>;
|
|
25
|
+
}): Promise<EntityReference<string>>;
|
|
19
26
|
private getId;
|
|
20
27
|
private filterEntities;
|
|
21
28
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -922,6 +922,8 @@ interface IEntityRepository<TEntity, TEntityId, TGetConditions, TFindCondition,
|
|
|
922
922
|
getBy(condition: TGetConditions): Promise<TEntity | undefined>;
|
|
923
923
|
all(): Promise<TEntity[]>;
|
|
924
924
|
find(condition: TFindCondition): Promise<TEntity[]>;
|
|
925
|
+
findOne(condition: TFindCondition): Promise<TEntity | undefined>;
|
|
926
|
+
findOneOrFail(condition: TFindCondition): Promise<TEntity>;
|
|
925
927
|
findById(id: TEntityId[]): Promise<TEntity[]>;
|
|
926
928
|
count(condition: TFindCondition): Promise<number>;
|
|
927
929
|
delete(id: TEntityId): Promise<void>;
|
|
@@ -930,6 +932,10 @@ interface IEntityRepository<TEntity, TEntityId, TGetConditions, TFindCondition,
|
|
|
930
932
|
update(id: TEntityId, entity: DeepPartial<TEntity>): Promise<TEntity>;
|
|
931
933
|
updateBy(entity: DeepPartial<TEntity>, condition: TUpdateCondition): Promise<TEntity[]>;
|
|
932
934
|
upsert(id: TEntityId, entity: DeepPartial<TEntity>): Promise<TEntity>;
|
|
935
|
+
upsertBy({ data, filter, }: {
|
|
936
|
+
data: Partial<TEntity>;
|
|
937
|
+
filter: TFindCondition;
|
|
938
|
+
}): Promise<EntityReference<string>>;
|
|
933
939
|
}
|
|
934
940
|
|
|
935
941
|
interface IEntitiesSearchQuery<TEntity, TEntitySearchParameters extends IEntitySearchParameters<TEntity, TSorting, TCursor>, TSorting extends SortingType, TCursor, TFacets extends IEntityFacets> {
|
|
@@ -3071,7 +3077,8 @@ declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId> implem
|
|
|
3071
3077
|
all(): Promise<TEntity[]>;
|
|
3072
3078
|
count(condition: FindManyOptions<TEntity>): Promise<number>;
|
|
3073
3079
|
find(condition: FindManyOptions<TEntity>): Promise<TEntity[]>;
|
|
3074
|
-
findOne(condition: FindManyOptions<TEntity>): Promise<TEntity>;
|
|
3080
|
+
findOne(condition: FindManyOptions<TEntity>): Promise<TEntity | undefined>;
|
|
3081
|
+
findOneOrFail(condition: FindManyOptions<TEntity>): Promise<TEntity>;
|
|
3075
3082
|
findById(id: TEntityId[]): Promise<TEntity[]>;
|
|
3076
3083
|
delete(id: TEntityId): Promise<void>;
|
|
3077
3084
|
deleteBy(condition: DeleteCriteria<TEntity>): Promise<IEntitiesDeleteResult>;
|
|
@@ -3079,6 +3086,10 @@ declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId> implem
|
|
|
3079
3086
|
update(id: TEntityId, entity: Partial<TEntity>): Promise<TEntity>;
|
|
3080
3087
|
updateBy(entity: Partial<TEntity>, condition: UpdateCriteria<TEntity>): Promise<TEntity[]>;
|
|
3081
3088
|
upsert(id: TEntityId, entity: Partial<TEntity>): Promise<TEntity>;
|
|
3089
|
+
upsertBy({ data, filter, }: {
|
|
3090
|
+
data: Partial<TEntity>;
|
|
3091
|
+
filter: FindManyOptions<TEntity>;
|
|
3092
|
+
}): Promise<EntityReference<string>>;
|
|
3082
3093
|
}
|
|
3083
3094
|
|
|
3084
3095
|
type NumericFilter = {
|