@nocobase/database 0.7.0-alpha.34 → 0.7.0-alpha.57
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/collection-importer.js +101 -67
- package/lib/collection.js +339 -210
- package/lib/database.js +488 -304
- package/lib/fields/array-field.js +45 -25
- package/lib/fields/belongs-to-field.js +101 -54
- package/lib/fields/belongs-to-many-field.js +98 -53
- package/lib/fields/boolean-field.js +24 -9
- package/lib/fields/context-field.js +77 -45
- package/lib/fields/date-field.js +24 -9
- package/lib/fields/field.js +114 -75
- package/lib/fields/has-inverse-field.js +4 -2
- package/lib/fields/has-many-field.js +105 -56
- package/lib/fields/has-one-field.js +105 -54
- package/lib/fields/index.js +277 -33
- package/lib/fields/json-field.js +36 -16
- package/lib/fields/number-field.js +53 -26
- package/lib/fields/password-field.js +118 -73
- package/lib/fields/radio-field.js +75 -47
- package/lib/fields/relation-field.js +41 -28
- package/lib/fields/sort-field.js +165 -89
- package/lib/fields/string-field.js +24 -9
- package/lib/fields/text-field.js +24 -9
- package/lib/fields/time-field.js +24 -9
- package/lib/fields/uid-field.js +57 -28
- package/lib/fields/uuid-field.js +36 -12
- package/lib/fields/virtual-field.js +24 -9
- package/lib/filter-parser.js +288 -179
- package/lib/index.js +210 -29
- package/lib/magic-attribute-model.js +123 -71
- package/lib/mock-database.js +68 -34
- package/lib/model-hook.js +101 -59
- package/lib/model.js +116 -81
- package/lib/operators/array.js +136 -96
- package/lib/operators/association.js +30 -14
- package/lib/operators/date.js +78 -34
- package/lib/operators/empty.js +113 -75
- package/lib/operators/index.js +15 -3
- package/lib/operators/ne.js +27 -12
- package/lib/operators/notIn.js +27 -12
- package/lib/operators/string.js +56 -35
- package/lib/operators/utils.js +18 -10
- package/lib/options-parser.js +323 -215
- package/lib/playground.js +66 -53
- package/lib/relation-repository/belongs-to-many-repository.js +281 -198
- package/lib/relation-repository/belongs-to-repository.js +10 -6
- package/lib/relation-repository/hasmany-repository.js +168 -121
- package/lib/relation-repository/hasone-repository.js +10 -6
- package/lib/relation-repository/multiple-relation-repository.js +263 -148
- package/lib/relation-repository/relation-repository.js +155 -97
- package/lib/relation-repository/single-relation-repository.js +138 -99
- package/lib/relation-repository/types.js +4 -2
- package/lib/repository.js +465 -291
- package/lib/transaction-decorator.js +80 -67
- package/lib/update-associations.js +525 -321
- package/lib/update-guard.js +160 -117
- package/package.json +3 -8
- package/src/database.ts +9 -3
- package/src/mock-database.ts +1 -1
- package/esm/collection-importer.d.ts +0 -7
- package/esm/collection-importer.js +0 -49
- package/esm/collection-importer.js.map +0 -1
- package/esm/collection.d.ts +0 -73
- package/esm/collection.js +0 -224
- package/esm/collection.js.map +0 -1
- package/esm/database.d.ts +0 -104
- package/esm/database.js +0 -305
- package/esm/database.js.map +0 -1
- package/esm/fields/array-field.d.ts +0 -11
- package/esm/fields/array-field.js +0 -26
- package/esm/fields/array-field.js.map +0 -1
- package/esm/fields/belongs-to-field.d.ts +0 -12
- package/esm/fields/belongs-to-field.js +0 -57
- package/esm/fields/belongs-to-field.js.map +0 -1
- package/esm/fields/belongs-to-many-field.d.ts +0 -11
- package/esm/fields/belongs-to-many-field.js +0 -55
- package/esm/fields/belongs-to-many-field.js.map +0 -1
- package/esm/fields/boolean-field.d.ts +0 -8
- package/esm/fields/boolean-field.js +0 -8
- package/esm/fields/boolean-field.js.map +0 -1
- package/esm/fields/context-field.d.ts +0 -13
- package/esm/fields/context-field.js +0 -43
- package/esm/fields/context-field.js.map +0 -1
- package/esm/fields/date-field.d.ts +0 -8
- package/esm/fields/date-field.js +0 -8
- package/esm/fields/date-field.js.map +0 -1
- package/esm/fields/field.d.ts +0 -37
- package/esm/fields/field.js +0 -74
- package/esm/fields/field.js.map +0 -1
- package/esm/fields/has-inverse-field.d.ts +0 -4
- package/esm/fields/has-inverse-field.js +0 -2
- package/esm/fields/has-inverse-field.js.map +0 -1
- package/esm/fields/has-many-field.d.ts +0 -64
- package/esm/fields/has-many-field.js +0 -58
- package/esm/fields/has-many-field.js.map +0 -1
- package/esm/fields/has-one-field.d.ts +0 -64
- package/esm/fields/has-one-field.js +0 -57
- package/esm/fields/has-one-field.js.map +0 -1
- package/esm/fields/index.d.ts +0 -42
- package/esm/fields/index.js +0 -22
- package/esm/fields/index.js.map +0 -1
- package/esm/fields/json-field.d.ts +0 -14
- package/esm/fields/json-field.js +0 -17
- package/esm/fields/json-field.js.map +0 -1
- package/esm/fields/number-field.d.ts +0 -32
- package/esm/fields/number-field.js +0 -28
- package/esm/fields/number-field.js.map +0 -1
- package/esm/fields/password-field.d.ts +0 -21
- package/esm/fields/password-field.js +0 -71
- package/esm/fields/password-field.js.map +0 -1
- package/esm/fields/radio-field.d.ts +0 -14
- package/esm/fields/radio-field.js +0 -49
- package/esm/fields/radio-field.js.map +0 -1
- package/esm/fields/relation-field.d.ts +0 -20
- package/esm/fields/relation-field.js +0 -27
- package/esm/fields/relation-field.js.map +0 -1
- package/esm/fields/sort-field.d.ts +0 -16
- package/esm/fields/sort-field.js +0 -90
- package/esm/fields/sort-field.js.map +0 -1
- package/esm/fields/string-field.d.ts +0 -8
- package/esm/fields/string-field.js +0 -8
- package/esm/fields/string-field.js.map +0 -1
- package/esm/fields/text-field.d.ts +0 -8
- package/esm/fields/text-field.js +0 -8
- package/esm/fields/text-field.js.map +0 -1
- package/esm/fields/time-field.d.ts +0 -8
- package/esm/fields/time-field.js +0 -8
- package/esm/fields/time-field.js.map +0 -1
- package/esm/fields/uid-field.d.ts +0 -10
- package/esm/fields/uid-field.js +0 -27
- package/esm/fields/uid-field.js.map +0 -1
- package/esm/fields/uuid-field.d.ts +0 -9
- package/esm/fields/uuid-field.js +0 -11
- package/esm/fields/uuid-field.js.map +0 -1
- package/esm/fields/virtual-field.d.ts +0 -8
- package/esm/fields/virtual-field.js +0 -8
- package/esm/fields/virtual-field.js.map +0 -1
- package/esm/filter-parser.d.ts +0 -27
- package/esm/filter-parser.js +0 -185
- package/esm/filter-parser.js.map +0 -1
- package/esm/index.d.ts +0 -15
- package/esm/index.js +0 -16
- package/esm/index.js.map +0 -1
- package/esm/magic-attribute-model.d.ts +0 -7
- package/esm/magic-attribute-model.js +0 -70
- package/esm/magic-attribute-model.js.map +0 -1
- package/esm/mock-database.d.ts +0 -22
- package/esm/mock-database.js +0 -34
- package/esm/mock-database.js.map +0 -1
- package/esm/model-hook.d.ts +0 -12
- package/esm/model-hook.js +0 -60
- package/esm/model-hook.js.map +0 -1
- package/esm/model.d.ts +0 -15
- package/esm/model.js +0 -80
- package/esm/model.js.map +0 -1
- package/esm/operators/array.d.ts +0 -26
- package/esm/operators/array.js +0 -105
- package/esm/operators/array.js.map +0 -1
- package/esm/operators/association.d.ts +0 -10
- package/esm/operators/association.js +0 -14
- package/esm/operators/association.js.map +0 -1
- package/esm/operators/date.d.ts +0 -34
- package/esm/operators/date.js +0 -35
- package/esm/operators/date.js.map +0 -1
- package/esm/operators/empty.d.ts +0 -28
- package/esm/operators/empty.js +0 -58
- package/esm/operators/empty.js.map +0 -1
- package/esm/operators/index.d.ts +0 -2
- package/esm/operators/index.js +0 -2
- package/esm/operators/index.js.map +0 -1
- package/esm/operators/ne.d.ts +0 -10
- package/esm/operators/ne.js +0 -12
- package/esm/operators/ne.js.map +0 -1
- package/esm/operators/notIn.d.ts +0 -10
- package/esm/operators/notIn.js +0 -12
- package/esm/operators/notIn.js.map +0 -1
- package/esm/operators/string.d.ts +0 -21
- package/esm/operators/string.js +0 -35
- package/esm/operators/string.js.map +0 -1
- package/esm/operators/utils.d.ts +0 -4
- package/esm/operators/utils.js +0 -11
- package/esm/operators/utils.js.map +0 -1
- package/esm/options-parser.d.ts +0 -31
- package/esm/options-parser.js +0 -225
- package/esm/options-parser.js.map +0 -1
- package/esm/playground.d.ts +0 -1
- package/esm/playground.js +0 -53
- package/esm/playground.js.map +0 -1
- package/esm/relation-repository/belongs-to-many-repository.d.ts +0 -36
- package/esm/relation-repository/belongs-to-many-repository.js +0 -199
- package/esm/relation-repository/belongs-to-many-repository.js.map +0 -1
- package/esm/relation-repository/belongs-to-repository.d.ts +0 -17
- package/esm/relation-repository/belongs-to-repository.js +0 -4
- package/esm/relation-repository/belongs-to-repository.js.map +0 -1
- package/esm/relation-repository/hasmany-repository.d.ts +0 -23
- package/esm/relation-repository/hasmany-repository.js +0 -125
- package/esm/relation-repository/hasmany-repository.js.map +0 -1
- package/esm/relation-repository/hasone-repository.d.ts +0 -17
- package/esm/relation-repository/hasone-repository.js +0 -4
- package/esm/relation-repository/hasone-repository.js.map +0 -1
- package/esm/relation-repository/multiple-relation-repository.d.ts +0 -23
- package/esm/relation-repository/multiple-relation-repository.js +0 -149
- package/esm/relation-repository/multiple-relation-repository.js.map +0 -1
- package/esm/relation-repository/relation-repository.d.ts +0 -32
- package/esm/relation-repository/relation-repository.js +0 -95
- package/esm/relation-repository/relation-repository.js.map +0 -1
- package/esm/relation-repository/single-relation-repository.d.ts +0 -23
- package/esm/relation-repository/single-relation-repository.js +0 -96
- package/esm/relation-repository/single-relation-repository.js.map +0 -1
- package/esm/relation-repository/types.d.ts +0 -7
- package/esm/relation-repository/types.js +0 -2
- package/esm/relation-repository/types.js.map +0 -1
- package/esm/repository.d.ts +0 -165
- package/esm/repository.js +0 -276
- package/esm/repository.js.map +0 -1
- package/esm/transaction-decorator.d.ts +0 -1
- package/esm/transaction-decorator.js +0 -63
- package/esm/transaction-decorator.js.map +0 -1
- package/esm/update-associations.d.ts +0 -60
- package/esm/update-associations.js +0 -362
- package/esm/update-associations.js.map +0 -1
- package/esm/update-guard.d.ts +0 -26
- package/esm/update-guard.js +0 -122
- package/esm/update-guard.js.map +0 -1
- package/lib/collection-importer.js.map +0 -1
- package/lib/collection.js.map +0 -1
- package/lib/database.js.map +0 -1
- package/lib/fields/array-field.js.map +0 -1
- package/lib/fields/belongs-to-field.js.map +0 -1
- package/lib/fields/belongs-to-many-field.js.map +0 -1
- package/lib/fields/boolean-field.js.map +0 -1
- package/lib/fields/context-field.js.map +0 -1
- package/lib/fields/date-field.js.map +0 -1
- package/lib/fields/field.js.map +0 -1
- package/lib/fields/has-inverse-field.js.map +0 -1
- package/lib/fields/has-many-field.js.map +0 -1
- package/lib/fields/has-one-field.js.map +0 -1
- package/lib/fields/index.js.map +0 -1
- package/lib/fields/json-field.js.map +0 -1
- package/lib/fields/number-field.js.map +0 -1
- package/lib/fields/password-field.js.map +0 -1
- package/lib/fields/radio-field.js.map +0 -1
- package/lib/fields/relation-field.js.map +0 -1
- package/lib/fields/sort-field.js.map +0 -1
- package/lib/fields/string-field.js.map +0 -1
- package/lib/fields/text-field.js.map +0 -1
- package/lib/fields/time-field.js.map +0 -1
- package/lib/fields/uid-field.js.map +0 -1
- package/lib/fields/uuid-field.js.map +0 -1
- package/lib/fields/virtual-field.js.map +0 -1
- package/lib/filter-parser.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/magic-attribute-model.js.map +0 -1
- package/lib/mock-database.js.map +0 -1
- package/lib/model-hook.js.map +0 -1
- package/lib/model.js.map +0 -1
- package/lib/operators/array.js.map +0 -1
- package/lib/operators/association.js.map +0 -1
- package/lib/operators/date.js.map +0 -1
- package/lib/operators/empty.js.map +0 -1
- package/lib/operators/index.js.map +0 -1
- package/lib/operators/ne.js.map +0 -1
- package/lib/operators/notIn.js.map +0 -1
- package/lib/operators/string.js.map +0 -1
- package/lib/operators/utils.js.map +0 -1
- package/lib/options-parser.js.map +0 -1
- package/lib/playground.js.map +0 -1
- package/lib/relation-repository/belongs-to-many-repository.js.map +0 -1
- package/lib/relation-repository/belongs-to-repository.js.map +0 -1
- package/lib/relation-repository/hasmany-repository.js.map +0 -1
- package/lib/relation-repository/hasone-repository.js.map +0 -1
- package/lib/relation-repository/multiple-relation-repository.js.map +0 -1
- package/lib/relation-repository/relation-repository.js.map +0 -1
- package/lib/relation-repository/single-relation-repository.js.map +0 -1
- package/lib/relation-repository/types.js.map +0 -1
- package/lib/repository.js.map +0 -1
- package/lib/transaction-decorator.js.map +0 -1
- package/lib/update-associations.js.map +0 -1
- package/lib/update-guard.js.map +0 -1
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multiple-relation-repository.js","sourceRoot":"","sources":["../../src/relation-repository/multiple-relation-repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAA6B,EAAE,EAAE,SAAS,EAAe,MAAM,WAAW,CAAC;AAalF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAUxE,MAAM,OAAgB,0BAA2B,SAAQ,kBAAkB;IACzE,iBAAiB,CAAC,WAAW;QAC3B,OAAO,WAAW,CAAC;IACrB,CAAC;IAEK,IAAI,CAAC,OAAqB;;YAC9B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAEvD,MAAM,WAAW,mCACZ,IAAI,CAAC,iBAAiB,CACvB,IAAI,CAAC,iBAAiB,mBACjB,OAAO,EACV,CACH,KACD,QAAQ,EAAE,KAAK,GAChB,CAAC;YAEF,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC;YACzC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;YAE3D,IAAI,WAAW,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gBACzD,MAAM,GAAG,GAAG,CACV,MAAM,WAAW,CAAC,WAAW,CAAC,iCACzB,WAAW,KACd,uBAAuB,EAAE,KAAK,EAC9B,UAAU,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,EAC9B,KAAK,EAAE,G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,IAAI,CAAC,IAAI,CAAC;gBAChC,MAAM,EAAE,MAAM;gBACd,WAAW;aACZ,CAAC,CAAC;YAEH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC;gBACxB,UAAU,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;gBAC5F,WAAW;aACZ,CAAC,CAAC;QACL,CAAC;KAAA;IAES,gBAAgB,CAAC,MAAc,EAAE,OAAa;QACtD,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACvD,OAAO,YAAY,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IACjE,CAAC;IAES,SAAS;QACjB,OAAkC,KAAK,CAAC,SAAS,EAAE,CAAC;IACtD,CAAC;CACF;AAzEC;IANC,WAAW,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE;QACjC,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;YACX,WAAW;SACZ,CAAC;IACJ,CAAC,CAAC;wDAcD;AAGD;IADC,WAAW,EAAE;wDAgCb","sourcesContent":["import { omit } from 'lodash';\nimport { MultiAssociationAccessors, Op, Sequelize, Transaction } from 'sequelize';\nimport {\n CommonFindOptions,\n CountOptions,\n DestroyOptions,\n Filter,\n FilterByTk,\n FindOptions,\n TargetKey,\n TK,\n TransactionAble,\n UpdateOptions\n} from '../repository';\nimport { updateModelByValues } from '../update-associations';\nimport { UpdateGuard } from '../update-guard';\nimport { RelationRepository, transaction } from './relation-repository';\n\nexport interface FindAndCountOptions extends CommonFindOptions {}\n\nexport interface FindOneOptions extends CommonFindOptions, FilterByTk {}\n\nexport interface AssociatedOptions extends TransactionAble {\n tk?: TK;\n}\n\nexport abstract class MultipleRelationRepository extends RelationRepository {\n extendFindOptions(findOptions) {\n return findOptions;\n }\n\n async find(options?: FindOptions): Promise<any> {\n const transaction = await this.getTransaction(options);\n\n const findOptions = {\n ...this.extendFindOptions(\n this.buildQueryOptions({\n ...options,\n }),\n ),\n subQuery: false,\n };\n\n const getAccessor = this.accessors().get;\n const sourceModel = await this.getSourceModel(transaction);\n\n if (findOptions.include && findOptions.include.length > 0) {\n const ids = (\n await sourceModel[getAccessor]({\n ...findOptions,\n includeIgnoreAttributes: false,\n attributes: [this.targetKey()],\n group: `${this.targetModel.name}.${this.targetKey()}`,\n transaction,\n })\n ).map((row) => row.get(this.targetKey()));\n\n return await sourceModel[getAccessor]({\n ...omit(findOptions, ['limit', 'offset']),\n where: {\n [this.targetKey()]: {\n [Op.in]: ids,\n },\n },\n transaction,\n });\n }\n\n return await sourceModel[getAccessor]({\n ...findOptions,\n transaction,\n });\n }\n\n async findAndCount(options?: FindAndCountOptions): Promise<[any[], number]> {\n const transaction = await this.getTransaction(options, false);\n return [\n await this.find({\n ...options,\n transaction,\n }),\n await this.count({\n ...options,\n transaction,\n }),\n ];\n }\n\n async count(options?: CountOptions) {\n const transaction = await this.getTransaction(options);\n\n const sourceModel = await this.getSourceModel(transaction);\n const queryOptions = this.buildQueryOptions(options);\n\n const count = await sourceModel[this.accessors().get]({\n where: queryOptions.where,\n include: queryOptions.include,\n includeIgnoreAttributes: false,\n attributes: [\n [\n Sequelize.fn(\n 'COUNT',\n Sequelize.fn('DISTINCT', Sequelize.col(`${this.targetModel.name}.${this.targetKey()}`)),\n ),\n 'count',\n ],\n ],\n raw: true,\n plain: true,\n transaction,\n });\n\n return parseInt(count.count);\n }\n\n async findOne(options?: FindOneOptions): Promise<any> {\n const transaction = await this.getTransaction(options, false);\n const rows = await this.find({ ...options, limit: 1, transaction });\n return rows.length == 1 ? rows[0] : null;\n }\n\n @transaction((args, transaction) => {\n return {\n tk: args[0],\n transaction,\n };\n })\n async remove(options: TargetKey | TargetKey[] | AssociatedOptions): Promise<void> {\n const transaction = await this.getTransaction(options);\n let handleKeys = options['tk'];\n\n if (!Array.isArray(handleKeys)) {\n handleKeys = [handleKeys];\n }\n\n const sourceModel = await this.getSourceModel(transaction);\n await sourceModel[this.accessors().removeMultiple](handleKeys, {\n transaction,\n });\n return;\n }\n\n @transaction()\n async update(options?: UpdateOptions): Promise<any> {\n const transaction = await this.getTransaction(options);\n\n const guard = UpdateGuard.fromOptions(this.targetModel, options);\n\n const values = guard.sanitize(options.values);\n\n const queryOptions = this.buildQueryOptions(options as any);\n\n const instances = await this.find({\n ...queryOptions,\n transaction,\n });\n\n for (const instance of instances) {\n await updateModelByValues(instance, values, {\n ...options,\n sanitized: true,\n sourceModel: this.sourceInstance,\n transaction,\n });\n }\n\n for (const instance of instances) {\n if (options.hooks !== false) {\n await this.db.emitAsync(`${this.targetCollection.name}.afterUpdateWithAssociations`, instance, {...options, transaction});\n await this.db.emitAsync(`${this.targetCollection.name}.afterSaveWithAssociations`, instance, {...options, transaction});\n }\n }\n\n return instances;\n }\n\n async destroy(options?: TK | DestroyOptions): Promise<Boolean> {\n return false;\n }\n\n protected async destroyByFilter(filter: Filter, transaction?: Transaction) {\n const instances = await this.find({\n filter: filter,\n transaction,\n });\n\n return await this.destroy({\n filterByTk: instances.map((instance) => instance.get(this.targetCollection.filterTargetKey)),\n transaction,\n });\n }\n\n protected filterHasInclude(filter: Filter, options?: any) {\n const filterResult = this.parseFilter(filter, options);\n return filterResult.include && filterResult.include.length > 0;\n }\n\n protected accessors() {\n return <MultiAssociationAccessors>super.accessors();\n }\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Association, ModelCtor, Transaction } from 'sequelize';
|
|
2
|
-
import { Collection } from '../collection';
|
|
3
|
-
import Database from '../database';
|
|
4
|
-
import { RelationField } from '../fields/relation-field';
|
|
5
|
-
import { Model } from '../model';
|
|
6
|
-
import { CreateOptions, Filter, FindOptions } from '../repository';
|
|
7
|
-
export declare const transaction: (transactionInjector?: any) => (target: any, name: any, descriptor: any) => any;
|
|
8
|
-
export declare abstract class RelationRepository {
|
|
9
|
-
sourceCollection: Collection;
|
|
10
|
-
association: Association;
|
|
11
|
-
targetModel: ModelCtor<any>;
|
|
12
|
-
targetCollection: Collection;
|
|
13
|
-
associationName: string;
|
|
14
|
-
associationField: RelationField;
|
|
15
|
-
sourceKeyValue: string | number;
|
|
16
|
-
sourceInstance: Model;
|
|
17
|
-
db: Database;
|
|
18
|
-
constructor(sourceCollection: Collection, association: string, sourceKeyValue: string | number);
|
|
19
|
-
targetKey(): any;
|
|
20
|
-
protected accessors(): import("sequelize").SingleAssociationAccessors | import("sequelize").MultiAssociationAccessors;
|
|
21
|
-
create(options?: CreateOptions): Promise<any>;
|
|
22
|
-
getSourceModel(transaction?: Transaction): Promise<Model<any, any>>;
|
|
23
|
-
protected buildQueryOptions(options: FindOptions): any;
|
|
24
|
-
protected parseFilter(filter: Filter, options?: any): {
|
|
25
|
-
where?: undefined;
|
|
26
|
-
include?: undefined;
|
|
27
|
-
} | {
|
|
28
|
-
where: {};
|
|
29
|
-
include: any[];
|
|
30
|
-
};
|
|
31
|
-
protected getTransaction(options: any, autoGen?: boolean): Promise<Transaction | null>;
|
|
32
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import lodash from 'lodash';
|
|
11
|
-
import FilterParser from '../filter-parser';
|
|
12
|
-
import { OptionsParser } from '../options-parser';
|
|
13
|
-
import { transactionWrapperBuilder } from '../transaction-decorator';
|
|
14
|
-
import { updateAssociations } from '../update-associations';
|
|
15
|
-
import { UpdateGuard } from '../update-guard';
|
|
16
|
-
export const transaction = transactionWrapperBuilder(function () {
|
|
17
|
-
return this.sourceCollection.model.sequelize.transaction();
|
|
18
|
-
});
|
|
19
|
-
export class RelationRepository {
|
|
20
|
-
constructor(sourceCollection, association, sourceKeyValue) {
|
|
21
|
-
this.db = sourceCollection.context.database;
|
|
22
|
-
this.sourceCollection = sourceCollection;
|
|
23
|
-
this.sourceKeyValue = sourceKeyValue;
|
|
24
|
-
this.associationName = association;
|
|
25
|
-
this.association = this.sourceCollection.model.associations[association];
|
|
26
|
-
this.associationField = this.sourceCollection.getField(association);
|
|
27
|
-
this.targetModel = this.association.target;
|
|
28
|
-
this.targetCollection = this.sourceCollection.context.database.modelCollection.get(this.targetModel);
|
|
29
|
-
}
|
|
30
|
-
targetKey() {
|
|
31
|
-
return this.associationField.targetKey;
|
|
32
|
-
}
|
|
33
|
-
accessors() {
|
|
34
|
-
return this.association.accessors;
|
|
35
|
-
}
|
|
36
|
-
create(options) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const createAccessor = this.accessors().create;
|
|
39
|
-
const guard = UpdateGuard.fromOptions(this.targetModel, options);
|
|
40
|
-
const values = options.values;
|
|
41
|
-
const transaction = yield this.getTransaction(options);
|
|
42
|
-
const sourceModel = yield this.getSourceModel(transaction);
|
|
43
|
-
const instance = yield sourceModel[createAccessor](guard.sanitize(options.values), Object.assign(Object.assign({}, options), { transaction }));
|
|
44
|
-
yield updateAssociations(instance, values, Object.assign(Object.assign({}, options), { transaction }));
|
|
45
|
-
if (options.hooks !== false) {
|
|
46
|
-
yield this.db.emitAsync(`${this.targetCollection.name}.afterCreateWithAssociations`, instance, Object.assign(Object.assign({}, options), { transaction }));
|
|
47
|
-
const eventName = `${this.targetCollection.name}.afterSaveWithAssociations`;
|
|
48
|
-
yield this.db.emitAsync(eventName, instance, Object.assign(Object.assign({}, options), { transaction }));
|
|
49
|
-
}
|
|
50
|
-
return instance;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
getSourceModel(transaction) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
if (!this.sourceInstance) {
|
|
56
|
-
this.sourceInstance = yield this.sourceCollection.model.findOne({
|
|
57
|
-
where: {
|
|
58
|
-
[this.associationField.sourceKey]: this.sourceKeyValue,
|
|
59
|
-
},
|
|
60
|
-
transaction,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return this.sourceInstance;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
buildQueryOptions(options) {
|
|
67
|
-
const parser = new OptionsParser(options, {
|
|
68
|
-
collection: this.targetCollection,
|
|
69
|
-
targetKey: this.targetKey(),
|
|
70
|
-
});
|
|
71
|
-
const params = parser.toSequelizeParams();
|
|
72
|
-
return Object.assign(Object.assign({}, options), params);
|
|
73
|
-
}
|
|
74
|
-
parseFilter(filter, options) {
|
|
75
|
-
const parser = new FilterParser(filter, {
|
|
76
|
-
collection: this.targetCollection,
|
|
77
|
-
app: {
|
|
78
|
-
ctx: options === null || options === void 0 ? void 0 : options.context,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
return parser.toSequelizeParams();
|
|
82
|
-
}
|
|
83
|
-
getTransaction(options, autoGen = false) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
if (lodash.isPlainObject(options) && options.transaction) {
|
|
86
|
-
return options.transaction;
|
|
87
|
-
}
|
|
88
|
-
if (autoGen) {
|
|
89
|
-
return yield this.sourceCollection.model.sequelize.transaction();
|
|
90
|
-
}
|
|
91
|
-
return null;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
//# sourceMappingURL=relation-repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|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association, BelongsTo, BelongsToMany, HasMany, HasOne, ModelCtor, Transaction } from 'sequelize';\nimport { Collection } from '../collection';\nimport Database from '../database';\nimport { RelationField } from '../fields/relation-field';\nimport FilterParser from '../filter-parser';\nimport { Model } from '../model';\nimport { OptionsParser } from '../options-parser';\nimport { CreateOptions, Filter, FindOptions } from '../repository';\nimport { transactionWrapperBuilder } from '../transaction-decorator';\nimport { updateAssociations } from '../update-associations';\nimport { UpdateGuard } from '../update-guard';\n\nexport const transaction = transactionWrapperBuilder(function () {\n return this.sourceCollection.model.sequelize.transaction();\n});\n\nexport abstract class RelationRepository {\n sourceCollection: Collection;\n association: Association;\n targetModel: ModelCtor<any>;\n targetCollection: Collection;\n associationName: string;\n associationField: RelationField;\n sourceKeyValue: string | number;\n sourceInstance: Model;\n db: Database;\n\n constructor(sourceCollection: Collection, association: string, sourceKeyValue: string | number) {\n this.db = sourceCollection.context.database;\n\n this.sourceCollection = sourceCollection;\n this.sourceKeyValue = sourceKeyValue;\n this.associationName = association;\n this.association = this.sourceCollection.model.associations[association];\n\n this.associationField = this.sourceCollection.getField(association);\n\n this.targetModel = this.association.target;\n this.targetCollection = this.sourceCollection.context.database.modelCollection.get(this.targetModel);\n }\n\n targetKey() {\n return this.associationField.targetKey;\n }\n\n protected accessors() {\n return (<BelongsTo | HasOne | HasMany | BelongsToMany>this.association).accessors;\n }\n\n async create(options?: CreateOptions): Promise<any> {\n const createAccessor = this.accessors().create;\n\n const guard = UpdateGuard.fromOptions(this.targetModel, options);\n const values = options.values;\n const transaction = await this.getTransaction(options);\n\n const sourceModel = await this.getSourceModel(transaction);\n\n const instance = await sourceModel[createAccessor](guard.sanitize(options.values), { ...options, transaction });\n\n await updateAssociations(instance, values, { ...options, transaction });\n\n if (options.hooks !== false) {\n await this.db.emitAsync(`${this.targetCollection.name}.afterCreateWithAssociations`, instance, {\n ...options,\n transaction,\n });\n const eventName = `${this.targetCollection.name}.afterSaveWithAssociations`;\n await this.db.emitAsync(eventName, instance, { ...options, transaction });\n }\n\n return instance;\n }\n\n async getSourceModel(transaction?: Transaction) {\n if (!this.sourceInstance) {\n this.sourceInstance = await this.sourceCollection.model.findOne({\n where: {\n [this.associationField.sourceKey]: this.sourceKeyValue,\n },\n transaction,\n });\n }\n\n return this.sourceInstance;\n }\n\n protected buildQueryOptions(options: FindOptions) {\n const parser = new OptionsParser(options, {\n collection: this.targetCollection,\n targetKey: this.targetKey(),\n });\n const params = parser.toSequelizeParams();\n return { ...options, ...params };\n }\n\n protected parseFilter(filter: Filter, options?: any) {\n const parser = new FilterParser(filter, {\n collection: this.targetCollection,\n app: {\n ctx: options?.context,\n },\n });\n return parser.toSequelizeParams();\n }\n\n protected async getTransaction(options: any, autoGen = false): Promise<Transaction | null> {\n if (lodash.isPlainObject(options) && options.transaction) {\n return options.transaction;\n }\n\n if (autoGen) {\n return await this.sourceCollection.model.sequelize.transaction();\n }\n\n return null;\n }\n}\n"]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SingleAssociationAccessors } from 'sequelize';
|
|
2
|
-
import { Model } from '../model';
|
|
3
|
-
import { Appends, Except, Fields, Filter, TargetKey, TransactionAble, UpdateOptions } from '../repository';
|
|
4
|
-
import { RelationRepository } from './relation-repository';
|
|
5
|
-
export interface SingleRelationFindOption extends TransactionAble {
|
|
6
|
-
fields?: Fields;
|
|
7
|
-
except?: Except;
|
|
8
|
-
appends?: Appends;
|
|
9
|
-
filter?: Filter;
|
|
10
|
-
}
|
|
11
|
-
interface SetOption extends TransactionAble {
|
|
12
|
-
tk?: TargetKey;
|
|
13
|
-
}
|
|
14
|
-
export declare abstract class SingleRelationRepository extends RelationRepository {
|
|
15
|
-
remove(options?: TransactionAble): Promise<void>;
|
|
16
|
-
set(options: TargetKey | SetOption): Promise<void>;
|
|
17
|
-
find(options?: SingleRelationFindOption): Promise<Model<any>>;
|
|
18
|
-
findOne(options?: SingleRelationFindOption): Promise<Model<any>>;
|
|
19
|
-
destroy(options?: TransactionAble): Promise<Boolean>;
|
|
20
|
-
update(options: UpdateOptions): Promise<any>;
|
|
21
|
-
accessors(): SingleAssociationAccessors;
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
import lodash from 'lodash';
|
|
17
|
-
import { updateModelByValues } from '../update-associations';
|
|
18
|
-
import { RelationRepository, transaction } from './relation-repository';
|
|
19
|
-
export class SingleRelationRepository extends RelationRepository {
|
|
20
|
-
remove(options) {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const transaction = yield this.getTransaction(options);
|
|
23
|
-
const sourceModel = yield this.getSourceModel(transaction);
|
|
24
|
-
return yield sourceModel[this.accessors().set](null, {
|
|
25
|
-
transaction,
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
set(options) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const transaction = yield this.getTransaction(options);
|
|
32
|
-
let handleKey = lodash.isPlainObject(options) ? options.tk : options;
|
|
33
|
-
const sourceModel = yield this.getSourceModel(transaction);
|
|
34
|
-
return yield sourceModel[this.accessors().set](handleKey, {
|
|
35
|
-
transaction,
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
find(options) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const transaction = yield this.getTransaction(options);
|
|
42
|
-
const findOptions = this.buildQueryOptions(Object.assign({}, options));
|
|
43
|
-
const getAccessor = this.accessors().get;
|
|
44
|
-
const sourceModel = yield this.getSourceModel(transaction);
|
|
45
|
-
return yield sourceModel[getAccessor](Object.assign(Object.assign({}, findOptions), { transaction }));
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
findOne(options) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
return this.find(options);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
destroy(options) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const transaction = yield this.getTransaction(options);
|
|
56
|
-
const target = yield this.find({
|
|
57
|
-
transaction,
|
|
58
|
-
});
|
|
59
|
-
yield target.destroy({
|
|
60
|
-
transaction,
|
|
61
|
-
});
|
|
62
|
-
return true;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
update(options) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
const transaction = yield this.getTransaction(options);
|
|
68
|
-
const target = yield this.find({
|
|
69
|
-
transaction,
|
|
70
|
-
});
|
|
71
|
-
yield updateModelByValues(target, options === null || options === void 0 ? void 0 : options.values, Object.assign(Object.assign({}, lodash.omit(options, 'values')), { transaction }));
|
|
72
|
-
return target;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
accessors() {
|
|
76
|
-
return super.accessors();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
__decorate([
|
|
80
|
-
transaction()
|
|
81
|
-
], SingleRelationRepository.prototype, "remove", null);
|
|
82
|
-
__decorate([
|
|
83
|
-
transaction((args, transaction) => {
|
|
84
|
-
return {
|
|
85
|
-
tk: args[0],
|
|
86
|
-
transaction,
|
|
87
|
-
};
|
|
88
|
-
})
|
|
89
|
-
], SingleRelationRepository.prototype, "set", null);
|
|
90
|
-
__decorate([
|
|
91
|
-
transaction()
|
|
92
|
-
], SingleRelationRepository.prototype, "destroy", null);
|
|
93
|
-
__decorate([
|
|
94
|
-
transaction()
|
|
95
|
-
], SingleRelationRepository.prototype, "update", null);
|
|
96
|
-
//# sourceMappingURL=single-relation-repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"single-relation-repository.js","sourceRoot":"","sources":["../../src/relation-repository/single-relation-repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAaxE,MAAM,OAAgB,wBAAyB,SAAQ,kBAAkB;IAEjE,MAAM,CAAC,OAAyB;;YACpC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YACvD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;YAC3D,OAAO,MAAM,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;gBACnD,WAAW;aACZ,CAAC,CAAC;QACL,CAAC;KAAA;IAQK,GAAG,CAAC,OAA8B;;YACtC,MAAM,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AM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAEvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;gBAC7B,WAAW;aACZ,CAAC,CAAC;YAEH,MAAM,mBAAmB,CAAC,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,kCAC5C,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,KACjC,WAAW,IACX,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;IAED,SAAS;QACP,OAAmC,KAAK,CAAC,SAAS,EAAE,CAAC;IACvD,CAAC;CACF;AA9EC;IADC,WAAW,EAAE;sDAOb;AAQD;IANC,WAAW,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE;QACjC,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;YACX,WAAW;SACZ,CAAC;IACJ,CAAC,CAAC;mDAUD;AAsBD;IADC,WAAW,EAAE;uDAab;AAGD;IADC,WAAW,EAAE;sDAcb","sourcesContent":["import lodash from 'lodash';\nimport { SingleAssociationAccessors } from 'sequelize';\nimport { Model } from '../model';\nimport { Appends, Except, Fields, Filter, TargetKey, TransactionAble, UpdateOptions } from '../repository';\nimport { updateModelByValues } from '../update-associations';\nimport { RelationRepository, transaction } from './relation-repository';\n\nexport interface SingleRelationFindOption extends TransactionAble {\n fields?: Fields;\n except?: Except;\n appends?: Appends;\n filter?: Filter;\n}\n\ninterface SetOption extends TransactionAble {\n tk?: TargetKey;\n}\n\nexport abstract class SingleRelationRepository extends RelationRepository {\n @transaction()\n async remove(options?: TransactionAble): Promise<void> {\n const transaction = await this.getTransaction(options);\n const sourceModel = await this.getSourceModel(transaction);\n return await sourceModel[this.accessors().set](null, {\n transaction,\n });\n }\n\n @transaction((args, transaction) => {\n return {\n tk: args[0],\n transaction,\n };\n })\n async set(options: TargetKey | SetOption): Promise<void> {\n const transaction = await this.getTransaction(options);\n let handleKey = lodash.isPlainObject(options) ? (<SetOption>options).tk : options;\n\n const sourceModel = await this.getSourceModel(transaction);\n\n return await sourceModel[this.accessors().set](handleKey, {\n transaction,\n });\n }\n\n async find(options?: SingleRelationFindOption): Promise<Model<any>> {\n const transaction = await this.getTransaction(options);\n const findOptions = this.buildQueryOptions({\n ...options,\n });\n\n const getAccessor = this.accessors().get;\n const sourceModel = await this.getSourceModel(transaction);\n\n return await sourceModel[getAccessor]({\n ...findOptions,\n transaction,\n });\n }\n\n async findOne(options?: SingleRelationFindOption): Promise<Model<any>> {\n return this.find(options);\n }\n\n @transaction()\n async destroy(options?: TransactionAble): Promise<Boolean> {\n const transaction = await this.getTransaction(options);\n\n const target = await this.find({\n transaction,\n });\n\n await target.destroy({\n transaction,\n });\n\n return true;\n }\n\n @transaction()\n async update(options: UpdateOptions): Promise<any> {\n const transaction = await this.getTransaction(options);\n\n const target = await this.find({\n transaction,\n });\n\n await updateModelByValues(target, options?.values, {\n ...lodash.omit(options, 'values'),\n transaction,\n });\n\n return target;\n }\n\n accessors() {\n return <SingleAssociationAccessors>super.accessors();\n }\n}\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { TargetKey, Values } from '../repository';
|
|
2
|
-
import { Transactionable } from 'sequelize';
|
|
3
|
-
export declare type PrimaryKeyWithThroughValues = [TargetKey, Values];
|
|
4
|
-
export interface AssociatedOptions extends Transactionable {
|
|
5
|
-
tk?: TargetKey | TargetKey[] | PrimaryKeyWithThroughValues | PrimaryKeyWithThroughValues[];
|
|
6
|
-
}
|
|
7
|
-
export declare type setAssociationOptions = TargetKey | TargetKey[] | PrimaryKeyWithThroughValues | PrimaryKeyWithThroughValues[] | AssociatedOptions;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/relation-repository/types.ts"],"names":[],"mappings":"","sourcesContent":["import { TargetKey, Values } from '../repository';\nimport { Transactionable } from 'sequelize';\n\nexport type PrimaryKeyWithThroughValues = [TargetKey, Values];\n\nexport interface AssociatedOptions extends Transactionable {\n tk?: TargetKey | TargetKey[] | PrimaryKeyWithThroughValues | PrimaryKeyWithThroughValues[];\n}\n\nexport type setAssociationOptions =\n | TargetKey\n | TargetKey[]\n | PrimaryKeyWithThroughValues\n | PrimaryKeyWithThroughValues[]\n | AssociatedOptions;\n"]}
|
package/esm/repository.d.ts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { Association, BulkCreateOptions, CreateOptions as SequelizeCreateOptions, DestroyOptions as SequelizeDestroyOptions, FindAndCountOptions as SequelizeAndCountOptions, FindOptions as SequelizeFindOptions, ModelCtor, Transaction, UpdateOptions as SequelizeUpdateOptions } from 'sequelize';
|
|
2
|
-
import { Collection } from './collection';
|
|
3
|
-
import { Database } from './database';
|
|
4
|
-
import { Model } from './model';
|
|
5
|
-
import { BelongsToManyRepository } from './relation-repository/belongs-to-many-repository';
|
|
6
|
-
import { BelongsToRepository } from './relation-repository/belongs-to-repository';
|
|
7
|
-
import { HasManyRepository } from './relation-repository/hasmany-repository';
|
|
8
|
-
import { HasOneRepository } from './relation-repository/hasone-repository';
|
|
9
|
-
import { RelationRepository } from './relation-repository/relation-repository';
|
|
10
|
-
export interface IRepository {
|
|
11
|
-
}
|
|
12
|
-
interface CreateManyOptions extends BulkCreateOptions {
|
|
13
|
-
records: Values[];
|
|
14
|
-
}
|
|
15
|
-
export interface TransactionAble {
|
|
16
|
-
transaction?: Transaction;
|
|
17
|
-
}
|
|
18
|
-
export interface FilterAble {
|
|
19
|
-
filter: Filter;
|
|
20
|
-
}
|
|
21
|
-
export declare type TargetKey = string | number;
|
|
22
|
-
export declare type TK = TargetKey | TargetKey[];
|
|
23
|
-
export declare type Filter = any;
|
|
24
|
-
export declare type Appends = string[];
|
|
25
|
-
export declare type Except = string[];
|
|
26
|
-
export declare type Fields = string[];
|
|
27
|
-
export declare type Sort = string[] | string;
|
|
28
|
-
export declare type WhiteList = string[];
|
|
29
|
-
export declare type BlackList = string[];
|
|
30
|
-
export declare type AssociationKeysToBeUpdate = string[];
|
|
31
|
-
export declare type Values = any;
|
|
32
|
-
export interface CountOptions extends Omit<SequelizeCreateOptions, 'distinct' | 'where' | 'include'>, TransactionAble {
|
|
33
|
-
fields?: Fields;
|
|
34
|
-
filter?: Filter;
|
|
35
|
-
}
|
|
36
|
-
export interface FilterByTk {
|
|
37
|
-
filterByTk?: TargetKey;
|
|
38
|
-
}
|
|
39
|
-
export interface FindOptions extends SequelizeFindOptions, CommonFindOptions, FilterByTk {
|
|
40
|
-
}
|
|
41
|
-
export interface CommonFindOptions extends TransactionAble {
|
|
42
|
-
filter?: Filter;
|
|
43
|
-
fields?: Fields;
|
|
44
|
-
appends?: Appends;
|
|
45
|
-
except?: Except;
|
|
46
|
-
sort?: Sort;
|
|
47
|
-
context?: any;
|
|
48
|
-
}
|
|
49
|
-
interface FindOneOptions extends FindOptions, CommonFindOptions {
|
|
50
|
-
}
|
|
51
|
-
export interface DestroyOptions extends SequelizeDestroyOptions {
|
|
52
|
-
filter?: Filter;
|
|
53
|
-
filterByTk?: TargetKey | TargetKey[];
|
|
54
|
-
truncate?: boolean;
|
|
55
|
-
context?: any;
|
|
56
|
-
}
|
|
57
|
-
interface FindAndCountOptions extends Omit<SequelizeAndCountOptions, 'where' | 'include' | 'order'> {
|
|
58
|
-
filter?: Filter;
|
|
59
|
-
fields?: Fields;
|
|
60
|
-
except?: Except;
|
|
61
|
-
appends?: Appends;
|
|
62
|
-
sort?: Sort;
|
|
63
|
-
}
|
|
64
|
-
export interface CreateOptions extends SequelizeCreateOptions {
|
|
65
|
-
values?: Values;
|
|
66
|
-
whitelist?: WhiteList;
|
|
67
|
-
blacklist?: BlackList;
|
|
68
|
-
updateAssociationValues?: AssociationKeysToBeUpdate;
|
|
69
|
-
context?: any;
|
|
70
|
-
}
|
|
71
|
-
export interface UpdateOptions extends Omit<SequelizeUpdateOptions, 'where'> {
|
|
72
|
-
values: Values;
|
|
73
|
-
filter?: Filter;
|
|
74
|
-
filterByTk?: TargetKey;
|
|
75
|
-
whitelist?: WhiteList;
|
|
76
|
-
blacklist?: BlackList;
|
|
77
|
-
updateAssociationValues?: AssociationKeysToBeUpdate;
|
|
78
|
-
context?: any;
|
|
79
|
-
}
|
|
80
|
-
declare class RelationRepositoryBuilder<R extends RelationRepository> {
|
|
81
|
-
collection: Collection;
|
|
82
|
-
associationName: string;
|
|
83
|
-
association: Association;
|
|
84
|
-
builderMap: {
|
|
85
|
-
HasOne: typeof HasOneRepository;
|
|
86
|
-
BelongsTo: typeof BelongsToRepository;
|
|
87
|
-
BelongsToMany: typeof BelongsToManyRepository;
|
|
88
|
-
HasMany: typeof HasManyRepository;
|
|
89
|
-
};
|
|
90
|
-
constructor(collection: Collection, associationName: string);
|
|
91
|
-
protected builder(): {
|
|
92
|
-
HasOne: typeof HasOneRepository;
|
|
93
|
-
BelongsTo: typeof BelongsToRepository;
|
|
94
|
-
BelongsToMany: typeof BelongsToManyRepository;
|
|
95
|
-
HasMany: typeof HasManyRepository;
|
|
96
|
-
};
|
|
97
|
-
of(id: string | number): R;
|
|
98
|
-
}
|
|
99
|
-
export declare class Repository<TModelAttributes extends {} = any, TCreationAttributes extends {} = TModelAttributes> implements IRepository {
|
|
100
|
-
database: Database;
|
|
101
|
-
collection: Collection;
|
|
102
|
-
model: ModelCtor<Model>;
|
|
103
|
-
constructor(collection: Collection);
|
|
104
|
-
/**
|
|
105
|
-
* return count by filter
|
|
106
|
-
*/
|
|
107
|
-
count(countOptions?: CountOptions): Promise<number>;
|
|
108
|
-
/**
|
|
109
|
-
* find
|
|
110
|
-
* @param options
|
|
111
|
-
*/
|
|
112
|
-
find(options?: FindOptions): Promise<Model<any, any>[]>;
|
|
113
|
-
/**
|
|
114
|
-
* find and count
|
|
115
|
-
* @param options
|
|
116
|
-
*/
|
|
117
|
-
findAndCount(options?: FindAndCountOptions): Promise<[Model[], number]>;
|
|
118
|
-
/**
|
|
119
|
-
* Find By Id
|
|
120
|
-
*
|
|
121
|
-
*/
|
|
122
|
-
findById(id: string | number): Promise<Model<any, any>>;
|
|
123
|
-
/**
|
|
124
|
-
* Find one record from database
|
|
125
|
-
*
|
|
126
|
-
* @param options
|
|
127
|
-
*/
|
|
128
|
-
findOne(options?: FindOneOptions): Promise<Model<any, any>>;
|
|
129
|
-
/**
|
|
130
|
-
* Save instance to database
|
|
131
|
-
*
|
|
132
|
-
* @param values
|
|
133
|
-
* @param options
|
|
134
|
-
*/
|
|
135
|
-
create<M extends Model>(options: CreateOptions): Promise<M>;
|
|
136
|
-
/**
|
|
137
|
-
* Save Many instances to database
|
|
138
|
-
*
|
|
139
|
-
* @param records
|
|
140
|
-
* @param options
|
|
141
|
-
*/
|
|
142
|
-
createMany(options: CreateManyOptions): Promise<any[]>;
|
|
143
|
-
/**
|
|
144
|
-
* Update model value
|
|
145
|
-
*
|
|
146
|
-
* @param values
|
|
147
|
-
* @param options
|
|
148
|
-
*/
|
|
149
|
-
update(options: UpdateOptions): Promise<Model<any, any>[]>;
|
|
150
|
-
destroy(options?: TargetKey | TargetKey[] | DestroyOptions): any;
|
|
151
|
-
/**
|
|
152
|
-
* @param association target association
|
|
153
|
-
*/
|
|
154
|
-
relation<R extends RelationRepository>(association: string): RelationRepositoryBuilder<R>;
|
|
155
|
-
protected buildQueryOptions(options: any): any;
|
|
156
|
-
protected parseFilter(filter: Filter, options?: any): {
|
|
157
|
-
where?: undefined;
|
|
158
|
-
include?: undefined;
|
|
159
|
-
} | {
|
|
160
|
-
where: {};
|
|
161
|
-
include: any[];
|
|
162
|
-
};
|
|
163
|
-
protected getTransaction(options: any, autoGen?: boolean): Promise<any>;
|
|
164
|
-
}
|
|
165
|
-
export {};
|