@common-stack/store-mongo 8.2.5-alpha.0 → 8.2.5-alpha.6
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/lib/module.d.ts
CHANGED
|
@@ -12,10 +12,10 @@ export declare class BaseService2<SchemaType, C = CreateType<SchemaType>, U = Up
|
|
|
12
12
|
getByName(name: string): Promise<AsDomainType<SchemaType> | null>;
|
|
13
13
|
getAll(options: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]>;
|
|
14
14
|
getByIds(ids: string[]): Promise<AsDomainType<SchemaType>[]>;
|
|
15
|
-
create
|
|
16
|
-
bulkCreate
|
|
17
|
-
update
|
|
18
|
-
insert
|
|
15
|
+
create(data: C): Promise<AsDomainType<SchemaType>>;
|
|
16
|
+
bulkCreate(data: C[]): Promise<AsDomainType<SchemaType>[]>;
|
|
17
|
+
update(id: string, data: Partial<U>, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
|
|
18
|
+
insert(data: (C | U) & {
|
|
19
19
|
id?: string;
|
|
20
20
|
}, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
|
|
21
21
|
delete(id: string | FilterQuery<SchemaType>): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseService.js","sources":["../../src/services/BaseService.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\n/* eslint-disable import/no-unresolved */\n/* eslint-disable no-useless-catch */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-useless-constructor */\n/* eslint-disable no-empty-function */\nimport { FilterQuery } from 'mongoose';\nimport { injectable } from 'inversify';\nimport { GetAllArgs, IBaseMongoRepository, IBaseService, AsDomainType, CreateType, UpdateType } from 'common/server';\n\n@injectable()\nexport class BaseService2<SchemaType, C = CreateType<SchemaType>, U = UpdateType<SchemaType>>\n implements IBaseService<SchemaType, C, U>\n{\n constructor(protected repository: IBaseMongoRepository<SchemaType>) {}\n\n async getAllWithCount(\n options: GetAllArgs<SchemaType>,\n ): Promise<{ data: AsDomainType<SchemaType>[]; totalCount: number }> {\n return this.repository.getAllWithCount(options);\n }\n\n count(conditions?: FilterQuery<SchemaType>): Promise<number> {\n return this.repository.count(conditions);\n }\n\n get(conditions: string | FilterQuery<SchemaType>): Promise<AsDomainType<SchemaType> | null> {\n if (typeof conditions === 'string') {\n return this.repository.get({ id: conditions } as FilterQuery<SchemaType>);\n }\n return this.repository.get(conditions);\n }\n\n getByName(name: string): Promise<AsDomainType<SchemaType> | null> {\n return this.repository.get({ name } as any);\n }\n\n getAll(options: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.getAll(options);\n }\n\n getByIds(ids: string[]): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.bulkGet(ids);\n }\n\n create
|
|
1
|
+
{"version":3,"file":"BaseService.js","sources":["../../src/services/BaseService.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\n/* eslint-disable import/no-unresolved */\n/* eslint-disable no-useless-catch */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-useless-constructor */\n/* eslint-disable no-empty-function */\nimport { FilterQuery } from 'mongoose';\nimport { injectable } from 'inversify';\nimport { GetAllArgs, IBaseMongoRepository, IBaseService, AsDomainType, CreateType, UpdateType } from 'common/server';\n\n@injectable()\nexport class BaseService2<SchemaType, C = CreateType<SchemaType>, U = UpdateType<SchemaType>>\n implements IBaseService<SchemaType, C, U>\n{\n constructor(protected repository: IBaseMongoRepository<SchemaType>) {}\n\n async getAllWithCount(\n options: GetAllArgs<SchemaType>,\n ): Promise<{ data: AsDomainType<SchemaType>[]; totalCount: number }> {\n return this.repository.getAllWithCount(options);\n }\n\n count(conditions?: FilterQuery<SchemaType>): Promise<number> {\n return this.repository.count(conditions);\n }\n\n get(conditions: string | FilterQuery<SchemaType>): Promise<AsDomainType<SchemaType> | null> {\n if (typeof conditions === 'string') {\n return this.repository.get({ id: conditions } as FilterQuery<SchemaType>);\n }\n return this.repository.get(conditions);\n }\n\n getByName(name: string): Promise<AsDomainType<SchemaType> | null> {\n return this.repository.get({ name } as any);\n }\n\n getAll(options: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.getAll(options);\n }\n\n getByIds(ids: string[]): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.bulkGet(ids);\n }\n\n create(data: C): Promise<AsDomainType<SchemaType>> {\n return this.repository.create(data);\n }\n\n bulkCreate(data: C[]): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.bulkCreate(data);\n }\n\n async update(id: string, data: Partial<U>, overwrite = false): Promise<AsDomainType<SchemaType>> {\n return this.repository.update({ id } as any, data, { overwrite });\n }\n\n async insert(data: (C | U) & { id?: string }, overwrite = true): Promise<AsDomainType<SchemaType>> {\n const { id, ...rest } = data as (C | U) & { id?: string };\n\n if (id) {\n try {\n const existing = await this.repository.get({ id } as any);\n if (existing) {\n return this.update(id, rest as any, overwrite);\n }\n } catch (error) {\n // If not found, continue to create\n }\n }\n\n return this.create(rest as C);\n }\n\n delete(id: string | FilterQuery<SchemaType>): Promise<boolean> {\n if (typeof id === 'string') {\n return this.repository.delete({ id } as any);\n }\n return this.repository.delete(id);\n }\n\n bulkDelete(criteria: FilterQuery<SchemaType>): Promise<number> {\n return this.repository.bulkDelete(criteria);\n }\n}\n"],"names":[],"mappings":";AAWa,IAAA,YAAY,GAAlB,MAAM,YAAY,CAAA;AAGC,IAAA,UAAA,CAAA;AAAtB,IAAA,WAAA,CAAsB,UAA4C,EAAA;QAA5C,IAAU,CAAA,UAAA,GAAV,UAAU,CAAkC;KAAI;IAEtE,MAAM,eAAe,CACjB,OAA+B,EAAA;QAE/B,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;KACnD;AAED,IAAA,KAAK,CAAC,UAAoC,EAAA;QACtC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,UAA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QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,EAAS,CAAC,CAAC;gBAC1D,IAAI,QAAQ,EAAE;oBACV,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAW,EAAE,SAAS,CAAC,CAAC;iBAClD;aACJ;YAAC,OAAO,KAAK,EAAE;;aAEf;SACJ;AAED,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAS,CAAC,CAAC;KACjC;AAED,IAAA,MAAM,CAAC,EAAoC,EAAA;AACvC,QAAA,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;YACxB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,EAAS,CAAC,CAAC;SAChD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;KACrC;AAED,IAAA,UAAU,CAAC,QAAiC,EAAA;QACxC,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;KAC/C;EACJ;AAzEY,YAAY,GAAA,UAAA,CAAA;AADxB,IAAA,UAAU,EAAE;AAIyB,IAAA,UAAA,CAAA,mBAAA,EAAA,CAAA,QAAA,EAAA,GAAA,OAAA,oBAAoB,oBAApB,oBAAoB,CAAA,KAAA,UAAA,GAAA,EAAA,GAAA,MAAA,CAAA,CAAA;AAH7C,CAAA,EAAA,YAAY,CAyExB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/store-mongo",
|
|
3
|
-
"version": "8.2.5-alpha.
|
|
3
|
+
"version": "8.2.5-alpha.6",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
]
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "3d0c42062a88fa4c9cdefe4a1e7b5d27a5e17ffe",
|
|
60
60
|
"typescript": {
|
|
61
61
|
"definition": "lib/index.d.ts"
|
|
62
62
|
}
|