@punks/backend-entity-manager 0.0.402 → 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 +15 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/repository.d.ts +5 -0
- package/dist/cjs/types/integrations/repository/typeorm/repository.d.ts +5 -0
- package/dist/cjs/types/testing/mocks/repository.d.ts +5 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/repository.d.ts +5 -0
- package/dist/esm/types/integrations/repository/typeorm/repository.d.ts +5 -0
- package/dist/esm/types/testing/mocks/repository.d.ts +5 -0
- package/dist/index.d.ts +8 -0
- 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;
|
|
@@ -19,4 +20,8 @@ export interface IEntityRepository<TEntity, TEntityId, TGetConditions, TFindCond
|
|
|
19
20
|
update(id: TEntityId, entity: DeepPartial<TEntity>): Promise<TEntity>;
|
|
20
21
|
updateBy(entity: DeepPartial<TEntity>, condition: TUpdateCondition): Promise<TEntity[]>;
|
|
21
22
|
upsert(id: TEntityId, entity: DeepPartial<TEntity>): Promise<TEntity>;
|
|
23
|
+
upsertBy({ data, filter, }: {
|
|
24
|
+
data: Partial<TEntity>;
|
|
25
|
+
filter: TFindCondition;
|
|
26
|
+
}): Promise<EntityReference<string>>;
|
|
22
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>> {
|
|
@@ -27,4 +28,8 @@ export declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId>
|
|
|
27
28
|
update(id: TEntityId, entity: Partial<TEntity>): Promise<TEntity>;
|
|
28
29
|
updateBy(entity: Partial<TEntity>, condition: UpdateCriteria<TEntity>): Promise<TEntity[]>;
|
|
29
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>>;
|
|
30
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>;
|
|
@@ -18,6 +19,10 @@ export declare class InMemoryRepository<TEntity> implements IEntityRepository<TE
|
|
|
18
19
|
update(id: string, entity: Partial<TEntity>): Promise<TEntity>;
|
|
19
20
|
updateBy(entity: Partial<TEntity>, condition: FilterExpression<TEntity>): Promise<TEntity[]>;
|
|
20
21
|
upsert(id: string, entity: TEntity): Promise<TEntity>;
|
|
22
|
+
upsertBy({ data, filter, }: {
|
|
23
|
+
data: Partial<TEntity>;
|
|
24
|
+
filter: FilterExpression<TEntity>;
|
|
25
|
+
}): Promise<EntityReference<string>>;
|
|
21
26
|
private getId;
|
|
22
27
|
private filterEntities;
|
|
23
28
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -932,6 +932,10 @@ interface IEntityRepository<TEntity, TEntityId, TGetConditions, TFindCondition,
|
|
|
932
932
|
update(id: TEntityId, entity: DeepPartial<TEntity>): Promise<TEntity>;
|
|
933
933
|
updateBy(entity: DeepPartial<TEntity>, condition: TUpdateCondition): Promise<TEntity[]>;
|
|
934
934
|
upsert(id: TEntityId, entity: DeepPartial<TEntity>): Promise<TEntity>;
|
|
935
|
+
upsertBy({ data, filter, }: {
|
|
936
|
+
data: Partial<TEntity>;
|
|
937
|
+
filter: TFindCondition;
|
|
938
|
+
}): Promise<EntityReference<string>>;
|
|
935
939
|
}
|
|
936
940
|
|
|
937
941
|
interface IEntitiesSearchQuery<TEntity, TEntitySearchParameters extends IEntitySearchParameters<TEntity, TSorting, TCursor>, TSorting extends SortingType, TCursor, TFacets extends IEntityFacets> {
|
|
@@ -3082,6 +3086,10 @@ declare class TypeOrmRepository<TEntity extends ObjectLiteral, TEntityId> implem
|
|
|
3082
3086
|
update(id: TEntityId, entity: Partial<TEntity>): Promise<TEntity>;
|
|
3083
3087
|
updateBy(entity: Partial<TEntity>, condition: UpdateCriteria<TEntity>): Promise<TEntity[]>;
|
|
3084
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>>;
|
|
3085
3093
|
}
|
|
3086
3094
|
|
|
3087
3095
|
type NumericFilter = {
|