@nocobase/database 0.5.0-alpha.38 → 0.7.0-alpha.10
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/LICENSE +201 -21
- package/esm/collection-importer.d.ts +7 -0
- package/esm/collection-importer.js +49 -0
- package/esm/collection-importer.js.map +1 -0
- package/esm/collection.d.ts +73 -0
- package/esm/collection.js +224 -0
- package/esm/collection.js.map +1 -0
- package/esm/database.d.ts +101 -0
- package/esm/database.js +275 -0
- package/esm/database.js.map +1 -0
- package/esm/fields/array-field.d.ts +11 -0
- package/esm/fields/array-field.js +26 -0
- package/esm/fields/array-field.js.map +1 -0
- package/esm/fields/belongs-to-field.d.ts +12 -0
- package/esm/fields/belongs-to-field.js +57 -0
- package/esm/fields/belongs-to-field.js.map +1 -0
- package/esm/fields/belongs-to-many-field.d.ts +11 -0
- package/esm/fields/belongs-to-many-field.js +55 -0
- package/esm/fields/belongs-to-many-field.js.map +1 -0
- package/esm/fields/boolean-field.d.ts +8 -0
- package/esm/fields/boolean-field.js +8 -0
- package/esm/fields/boolean-field.js.map +1 -0
- package/esm/fields/context-field.d.ts +13 -0
- package/esm/fields/context-field.js +43 -0
- package/esm/fields/context-field.js.map +1 -0
- package/esm/fields/date-field.d.ts +8 -0
- package/esm/fields/date-field.js +8 -0
- package/esm/fields/date-field.js.map +1 -0
- package/esm/fields/field.d.ts +37 -0
- package/esm/fields/field.js +74 -0
- package/esm/fields/field.js.map +1 -0
- package/esm/fields/has-inverse-field.d.ts +4 -0
- package/esm/fields/has-inverse-field.js +2 -0
- package/esm/fields/has-inverse-field.js.map +1 -0
- package/esm/fields/has-many-field.d.ts +64 -0
- package/esm/fields/has-many-field.js +58 -0
- package/esm/fields/has-many-field.js.map +1 -0
- package/esm/fields/has-one-field.d.ts +64 -0
- package/esm/fields/has-one-field.js +57 -0
- package/esm/fields/has-one-field.js.map +1 -0
- package/esm/fields/index.d.ts +40 -0
- package/esm/fields/index.js +21 -0
- package/esm/fields/index.js.map +1 -0
- package/esm/fields/json-field.d.ts +14 -0
- package/esm/fields/json-field.js +17 -0
- package/esm/fields/json-field.js.map +1 -0
- package/esm/fields/number-field.d.ts +32 -0
- package/esm/fields/number-field.js +28 -0
- package/esm/fields/number-field.js.map +1 -0
- package/esm/fields/password-field.d.ts +21 -0
- package/esm/fields/password-field.js +71 -0
- package/esm/fields/password-field.js.map +1 -0
- package/esm/fields/radio-field.d.ts +14 -0
- package/esm/fields/radio-field.js +49 -0
- package/esm/fields/radio-field.js.map +1 -0
- package/esm/fields/relation-field.d.ts +20 -0
- package/esm/fields/relation-field.js +27 -0
- package/esm/fields/relation-field.js.map +1 -0
- package/esm/fields/sort-field.d.ts +16 -0
- package/esm/fields/sort-field.js +90 -0
- package/esm/fields/sort-field.js.map +1 -0
- package/esm/fields/string-field.d.ts +8 -0
- package/esm/fields/string-field.js +8 -0
- package/esm/fields/string-field.js.map +1 -0
- package/esm/fields/text-field.d.ts +8 -0
- package/esm/fields/text-field.js +8 -0
- package/esm/fields/text-field.js.map +1 -0
- package/esm/fields/time-field.d.ts +8 -0
- package/esm/fields/time-field.js +8 -0
- package/esm/fields/time-field.js.map +1 -0
- package/esm/fields/uid-field.d.ts +10 -0
- package/esm/fields/uid-field.js +27 -0
- package/esm/fields/uid-field.js.map +1 -0
- package/esm/fields/virtual-field.d.ts +8 -0
- package/esm/fields/virtual-field.js +8 -0
- package/esm/fields/virtual-field.js.map +1 -0
- package/esm/filter-parser.d.ts +27 -0
- package/esm/filter-parser.js +185 -0
- package/esm/filter-parser.js.map +1 -0
- package/esm/index.d.ts +15 -0
- package/esm/index.js +16 -0
- package/esm/index.js.map +1 -0
- package/esm/magic-attribute-model.d.ts +7 -0
- package/esm/magic-attribute-model.js +70 -0
- package/esm/magic-attribute-model.js.map +1 -0
- package/esm/mock-database.d.ts +22 -0
- package/esm/mock-database.js +34 -0
- package/esm/mock-database.js.map +1 -0
- package/esm/model-hook.d.ts +12 -0
- package/esm/model-hook.js +61 -0
- package/esm/model-hook.js.map +1 -0
- package/esm/model.d.ts +15 -0
- package/esm/model.js +80 -0
- package/esm/model.js.map +1 -0
- package/esm/operators/array.d.ts +26 -0
- package/esm/operators/array.js +105 -0
- package/esm/operators/array.js.map +1 -0
- package/esm/operators/association.d.ts +10 -0
- package/esm/operators/association.js +14 -0
- package/esm/operators/association.js.map +1 -0
- package/esm/operators/date.d.ts +34 -0
- package/esm/operators/date.js +35 -0
- package/esm/operators/date.js.map +1 -0
- package/esm/operators/empty.d.ts +28 -0
- package/esm/operators/empty.js +58 -0
- package/esm/operators/empty.js.map +1 -0
- package/esm/operators/index.d.ts +2 -0
- package/esm/operators/index.js +2 -0
- package/esm/operators/index.js.map +1 -0
- package/esm/operators/ne.d.ts +10 -0
- package/esm/operators/ne.js +12 -0
- package/esm/operators/ne.js.map +1 -0
- package/esm/operators/string.d.ts +21 -0
- package/esm/operators/string.js +35 -0
- package/esm/operators/string.js.map +1 -0
- package/esm/operators/utils.d.ts +4 -0
- package/esm/operators/utils.js +11 -0
- package/esm/operators/utils.js.map +1 -0
- package/esm/options-parser.d.ts +31 -0
- package/esm/options-parser.js +225 -0
- package/esm/options-parser.js.map +1 -0
- package/esm/playground.d.ts +1 -0
- package/esm/playground.js +53 -0
- package/esm/playground.js.map +1 -0
- package/esm/relation-repository/belongs-to-many-repository.d.ts +36 -0
- package/esm/relation-repository/belongs-to-many-repository.js +199 -0
- package/esm/relation-repository/belongs-to-many-repository.js.map +1 -0
- package/esm/relation-repository/belongs-to-repository.d.ts +17 -0
- package/esm/relation-repository/belongs-to-repository.js +4 -0
- package/esm/relation-repository/belongs-to-repository.js.map +1 -0
- package/esm/relation-repository/hasmany-repository.d.ts +23 -0
- package/esm/relation-repository/hasmany-repository.js +125 -0
- package/esm/relation-repository/hasmany-repository.js.map +1 -0
- package/esm/relation-repository/hasone-repository.d.ts +17 -0
- package/esm/relation-repository/hasone-repository.js +4 -0
- package/esm/relation-repository/hasone-repository.js.map +1 -0
- package/esm/relation-repository/multiple-relation-repository.d.ts +23 -0
- package/esm/relation-repository/multiple-relation-repository.js +149 -0
- package/esm/relation-repository/multiple-relation-repository.js.map +1 -0
- package/esm/relation-repository/relation-repository.d.ts +32 -0
- package/esm/relation-repository/relation-repository.js +93 -0
- package/esm/relation-repository/relation-repository.js.map +1 -0
- package/esm/relation-repository/single-relation-repository.d.ts +23 -0
- package/esm/relation-repository/single-relation-repository.js +96 -0
- package/esm/relation-repository/single-relation-repository.js.map +1 -0
- package/esm/relation-repository/types.d.ts +7 -0
- package/esm/relation-repository/types.js +2 -0
- package/esm/relation-repository/types.js.map +1 -0
- package/esm/repository.d.ts +165 -0
- package/esm/repository.js +276 -0
- package/esm/repository.js.map +1 -0
- package/esm/transaction-decorator.d.ts +1 -0
- package/esm/transaction-decorator.js +63 -0
- package/esm/transaction-decorator.js.map +1 -0
- package/esm/update-associations.d.ts +60 -0
- package/esm/update-associations.js +362 -0
- package/esm/update-associations.js.map +1 -0
- package/esm/update-guard.d.ts +26 -0
- package/esm/update-guard.js +122 -0
- package/esm/update-guard.js.map +1 -0
- package/lib/collection-importer.d.ts +7 -0
- package/lib/collection-importer.js +75 -0
- package/lib/collection-importer.js.map +1 -0
- package/lib/collection.d.ts +73 -0
- package/lib/collection.js +231 -0
- package/lib/collection.js.map +1 -0
- package/lib/database.d.ts +93 -43
- package/lib/database.js +277 -471
- package/lib/database.js.map +1 -1
- package/lib/fields/array-field.d.ts +11 -0
- package/lib/fields/array-field.js +30 -0
- package/lib/fields/array-field.js.map +1 -0
- package/lib/fields/belongs-to-field.d.ts +12 -0
- package/lib/fields/belongs-to-field.js +61 -0
- package/lib/fields/belongs-to-field.js.map +1 -0
- package/lib/fields/belongs-to-many-field.d.ts +11 -0
- package/lib/fields/belongs-to-many-field.js +59 -0
- package/lib/fields/belongs-to-many-field.js.map +1 -0
- package/lib/fields/boolean-field.d.ts +8 -0
- package/lib/fields/boolean-field.js +12 -0
- package/lib/fields/boolean-field.js.map +1 -0
- package/lib/fields/context-field.d.ts +13 -0
- package/lib/fields/context-field.js +50 -0
- package/lib/fields/context-field.js.map +1 -0
- package/lib/fields/date-field.d.ts +8 -0
- package/lib/fields/date-field.js +12 -0
- package/lib/fields/date-field.js.map +1 -0
- package/lib/fields/field.d.ts +37 -0
- package/lib/fields/field.js +81 -0
- package/lib/fields/field.js.map +1 -0
- package/lib/fields/has-inverse-field.d.ts +4 -0
- package/lib/fields/has-inverse-field.js +3 -0
- package/lib/fields/has-inverse-field.js.map +1 -0
- package/lib/fields/has-many-field.d.ts +64 -0
- package/lib/fields/has-many-field.js +62 -0
- package/lib/fields/has-many-field.js.map +1 -0
- package/lib/fields/has-one-field.d.ts +64 -0
- package/lib/fields/has-one-field.js +61 -0
- package/lib/fields/has-one-field.js.map +1 -0
- package/lib/fields/index.d.ts +40 -10
- package/lib/fields/index.js +31 -138
- package/lib/fields/index.js.map +1 -1
- package/lib/fields/json-field.d.ts +14 -0
- package/lib/fields/json-field.js +22 -0
- package/lib/fields/json-field.js.map +1 -0
- package/lib/fields/number-field.d.ts +32 -0
- package/lib/fields/number-field.js +36 -0
- package/lib/fields/number-field.js.map +1 -0
- package/lib/fields/password-field.d.ts +21 -0
- package/lib/fields/password-field.js +78 -0
- package/lib/fields/password-field.js.map +1 -0
- package/lib/fields/radio-field.d.ts +14 -0
- package/lib/fields/radio-field.js +53 -0
- package/lib/fields/radio-field.js.map +1 -0
- package/lib/fields/relation-field.d.ts +20 -0
- package/lib/fields/relation-field.js +31 -0
- package/lib/fields/relation-field.js.map +1 -0
- package/lib/fields/sort-field.d.ts +16 -0
- package/lib/fields/sort-field.js +94 -0
- package/lib/fields/sort-field.js.map +1 -0
- package/lib/fields/string-field.d.ts +8 -0
- package/lib/fields/string-field.js +12 -0
- package/lib/fields/string-field.js.map +1 -0
- package/lib/fields/text-field.d.ts +8 -0
- package/lib/fields/text-field.js +12 -0
- package/lib/fields/text-field.js.map +1 -0
- package/lib/fields/time-field.d.ts +8 -0
- package/lib/fields/time-field.js +12 -0
- package/lib/fields/time-field.js.map +1 -0
- package/lib/fields/uid-field.d.ts +10 -0
- package/lib/fields/uid-field.js +31 -0
- package/lib/fields/uid-field.js.map +1 -0
- package/lib/fields/virtual-field.d.ts +8 -0
- package/lib/fields/virtual-field.js +12 -0
- package/lib/fields/virtual-field.js.map +1 -0
- package/lib/filter-parser.d.ts +27 -0
- package/lib/filter-parser.js +191 -0
- package/lib/filter-parser.js.map +1 -0
- package/lib/index.d.ts +13 -6
- package/lib/index.js +27 -60
- package/lib/index.js.map +1 -1
- package/lib/magic-attribute-model.d.ts +7 -0
- package/lib/magic-attribute-model.js +77 -0
- package/lib/magic-attribute-model.js.map +1 -0
- package/lib/mock-database.d.ts +22 -0
- package/lib/mock-database.js +40 -0
- package/lib/mock-database.js.map +1 -0
- package/lib/model-hook.d.ts +12 -0
- package/lib/model-hook.js +68 -0
- package/lib/model-hook.js.map +1 -0
- package/lib/model.d.ts +11 -45
- package/lib/model.js +76 -452
- package/lib/model.js.map +1 -1
- package/lib/operators/array.d.ts +26 -0
- package/lib/operators/array.js +107 -0
- package/lib/operators/array.js.map +1 -0
- package/lib/operators/association.d.ts +10 -0
- package/lib/operators/association.js +16 -0
- package/lib/operators/association.js.map +1 -0
- package/lib/operators/date.d.ts +34 -0
- package/lib/operators/date.js +40 -0
- package/lib/operators/date.js.map +1 -0
- package/lib/operators/empty.d.ts +28 -0
- package/lib/operators/empty.js +82 -0
- package/lib/operators/empty.js.map +1 -0
- package/lib/operators/index.d.ts +2 -0
- package/lib/operators/index.js +4 -0
- package/lib/operators/index.js.map +1 -0
- package/lib/operators/ne.d.ts +10 -0
- package/lib/operators/ne.js +14 -0
- package/lib/operators/ne.js.map +1 -0
- package/lib/operators/string.d.ts +21 -0
- package/lib/operators/string.js +37 -0
- package/lib/operators/string.js.map +1 -0
- package/lib/operators/utils.d.ts +4 -0
- package/lib/operators/utils.js +16 -0
- package/lib/operators/utils.js.map +1 -0
- package/lib/options-parser.d.ts +31 -0
- package/lib/options-parser.js +232 -0
- package/lib/options-parser.js.map +1 -0
- package/lib/playground.d.ts +1 -0
- package/lib/playground.js +55 -0
- package/lib/playground.js.map +1 -0
- package/lib/relation-repository/belongs-to-many-repository.d.ts +36 -0
- package/lib/relation-repository/belongs-to-many-repository.js +206 -0
- package/lib/relation-repository/belongs-to-many-repository.js.map +1 -0
- package/lib/relation-repository/belongs-to-repository.d.ts +17 -0
- package/lib/relation-repository/belongs-to-repository.js +8 -0
- package/lib/relation-repository/belongs-to-repository.js.map +1 -0
- package/lib/relation-repository/hasmany-repository.d.ts +23 -0
- package/lib/relation-repository/hasmany-repository.js +129 -0
- package/lib/relation-repository/hasmany-repository.js.map +1 -0
- package/lib/relation-repository/hasone-repository.d.ts +17 -0
- package/lib/relation-repository/hasone-repository.js +8 -0
- package/lib/relation-repository/hasone-repository.js.map +1 -0
- package/lib/relation-repository/multiple-relation-repository.d.ts +23 -0
- package/lib/relation-repository/multiple-relation-repository.js +153 -0
- package/lib/relation-repository/multiple-relation-repository.js.map +1 -0
- package/lib/relation-repository/relation-repository.d.ts +32 -0
- package/lib/relation-repository/relation-repository.js +100 -0
- package/lib/relation-repository/relation-repository.js.map +1 -0
- package/lib/relation-repository/single-relation-repository.d.ts +23 -0
- package/lib/relation-repository/single-relation-repository.js +103 -0
- package/lib/relation-repository/single-relation-repository.js.map +1 -0
- package/lib/relation-repository/types.d.ts +7 -0
- package/lib/relation-repository/types.js +3 -0
- package/lib/relation-repository/types.js.map +1 -0
- package/lib/repository.d.ts +165 -0
- package/lib/repository.js +302 -0
- package/lib/repository.js.map +1 -0
- package/lib/transaction-decorator.d.ts +1 -0
- package/lib/transaction-decorator.js +70 -0
- package/lib/transaction-decorator.js.map +1 -0
- package/lib/update-associations.d.ts +60 -0
- package/lib/update-associations.js +374 -0
- package/lib/update-associations.js.map +1 -0
- package/lib/update-guard.d.ts +26 -0
- package/lib/update-guard.js +129 -0
- package/lib/update-guard.js.map +1 -0
- package/package.json +17 -5
- package/src/__tests__/collection-importer.test.ts +21 -0
- package/src/__tests__/collection.sortable.test.ts +65 -0
- package/src/__tests__/collection.test.ts +218 -0
- package/src/__tests__/database.import.test.ts +33 -0
- package/src/__tests__/database.test.ts +229 -0
- package/src/__tests__/field-options/hidden.test.ts +302 -0
- package/src/__tests__/field-options/sort-by.test.ts +220 -0
- package/src/__tests__/fields/belongs-to-field.test.ts +162 -0
- package/src/__tests__/fields/belongs-to-many-field.test.ts +61 -0
- package/src/__tests__/fields/context-field.test.ts +140 -0
- package/src/__tests__/fields/has-many-field.test.ts +152 -0
- package/src/__tests__/fields/has-one-field.test.ts +67 -0
- package/src/__tests__/fields/password-field.test.ts +30 -0
- package/src/__tests__/fields/sort-field.test.ts +133 -0
- package/src/__tests__/fields/string-field.test.ts +77 -0
- package/src/__tests__/filter-parser.test.ts +104 -0
- package/src/__tests__/fixtures/c0/a.ts +6 -0
- package/src/__tests__/fixtures/c1/b.ts +6 -0
- package/src/__tests__/fixtures/c2/a.ts +6 -0
- package/src/__tests__/fixtures/collections/delay-extend.ts +6 -0
- package/src/__tests__/fixtures/collections/delay-extend2.ts +6 -0
- package/src/__tests__/fixtures/collections/extend.ts +6 -0
- package/src/__tests__/fixtures/collections/extend2.ts +6 -0
- package/src/__tests__/fixtures/collections/posts.ts +4 -0
- package/src/__tests__/fixtures/collections/tags.js +4 -0
- package/src/__tests__/fixtures/collections/test.jpg +0 -0
- package/src/__tests__/fixtures/collections/user.json +9 -0
- package/src/__tests__/index.ts +1 -0
- package/src/__tests__/magic-attribute-model.test.ts +103 -0
- package/src/__tests__/model.test.ts +60 -0
- package/src/__tests__/operator/array-operator.test.ts +268 -0
- package/src/__tests__/operator/association-operator.test.ts +263 -0
- package/src/__tests__/operator/date-operator.test.ts +165 -0
- package/src/__tests__/operator/empty-operator.test.ts +77 -0
- package/src/__tests__/operator/ne.test.ts +33 -0
- package/src/__tests__/operator/string-operator.test.ts +62 -0
- package/src/__tests__/option-parser.test.ts +185 -0
- package/src/__tests__/relation-repository/belongs-to-many-repository.test.ts +697 -0
- package/src/__tests__/relation-repository/has-many-repository.test.ts +414 -0
- package/src/__tests__/relation-repository/hasone-repository.test.ts +77 -0
- package/src/__tests__/repository/count.test.ts +180 -0
- package/src/__tests__/repository/create.test.ts +163 -0
- package/src/__tests__/repository/destroy.test.ts +196 -0
- package/src/__tests__/repository/find.test.ts +247 -0
- package/src/__tests__/repository/update.test.ts +60 -0
- package/src/__tests__/repository.test.ts +438 -0
- package/src/__tests__/update-associations.test.ts +412 -0
- package/src/__tests__/update-guard.test.ts +376 -0
- package/src/collection-importer.ts +49 -0
- package/src/collection.ts +282 -0
- package/src/database.ts +340 -0
- package/src/fields/array-field.ts +35 -0
- package/src/fields/belongs-to-field.ts +76 -0
- package/src/fields/belongs-to-many-field.ts +77 -0
- package/src/fields/boolean-field.ts +12 -0
- package/src/fields/context-field.ts +45 -0
- package/src/fields/date-field.ts +12 -0
- package/src/fields/field.ts +105 -0
- package/src/fields/has-inverse-field.ts +5 -0
- package/src/fields/has-many-field.ts +143 -0
- package/src/fields/has-one-field.ts +136 -0
- package/src/fields/index.ts +72 -0
- package/src/fields/json-field.ts +25 -0
- package/src/fields/number-field.ts +52 -0
- package/src/fields/password-field.ts +72 -0
- package/src/fields/radio-field.ts +50 -0
- package/src/fields/relation-field.ts +37 -0
- package/src/fields/sort-field.ts +96 -0
- package/src/fields/string-field.ts +12 -0
- package/src/fields/text-field.ts +12 -0
- package/src/fields/time-field.ts +12 -0
- package/src/fields/uid-field.ts +24 -0
- package/src/fields/virtual-field.ts +12 -0
- package/src/filter-parser.ts +243 -0
- package/src/index.ts +16 -0
- package/src/magic-attribute-model.ts +62 -0
- package/src/mock-database.ts +42 -0
- package/src/model-hook.ts +69 -0
- package/src/model.ts +114 -0
- package/src/operators/array.ts +145 -0
- package/src/operators/association.ts +14 -0
- package/src/operators/date.ts +41 -0
- package/src/operators/empty.ts +75 -0
- package/src/operators/index.ts +8 -0
- package/src/operators/ne.ts +12 -0
- package/src/operators/string.ts +40 -0
- package/src/operators/utils.ts +13 -0
- package/src/options-parser.ts +285 -0
- package/src/playground.ts +52 -0
- package/src/relation-repository/belongs-to-many-repository.ts +240 -0
- package/src/relation-repository/belongs-to-repository.ts +23 -0
- package/src/relation-repository/hasmany-repository.ts +145 -0
- package/src/relation-repository/hasone-repository.ts +23 -0
- package/src/relation-repository/multiple-relation-repository.ts +198 -0
- package/src/relation-repository/relation-repository.ts +114 -0
- package/src/relation-repository/single-relation-repository.ts +99 -0
- package/src/relation-repository/types.ts +15 -0
- package/src/repository.ts +478 -0
- package/src/transaction-decorator.ts +58 -0
- package/src/update-associations.ts +478 -0
- package/src/update-guard.ts +167 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +5 -0
- package/examples/index.ts +0 -125
- package/examples/plugins/db-driven/index.ts +0 -25
- package/examples/plugins/db-driven/tables/fields.ts +0 -78
- package/examples/plugins/db-driven/tables/tables.ts +0 -53
- package/examples/tables/bar.js +0 -26
- package/examples/tables/comments.ts +0 -19
- package/examples/tables/foo.json +0 -3
- package/examples/tables/posts.ts +0 -28
- package/examples/tables/profiles.ts +0 -23
- package/examples/tables/tags.ts +0 -15
- package/examples/tables/users.ts +0 -34
- package/lib/database.d.ts.map +0 -1
- package/lib/fields/field-types.d.ts +0 -419
- package/lib/fields/field-types.d.ts.map +0 -1
- package/lib/fields/field-types.js +0 -1222
- package/lib/fields/field-types.js.map +0 -1
- package/lib/fields/index.d.ts.map +0 -1
- package/lib/fields/option-types.d.ts +0 -105
- package/lib/fields/option-types.d.ts.map +0 -1
- package/lib/fields/option-types.js +0 -18
- package/lib/fields/option-types.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/model.d.ts.map +0 -1
- package/lib/op.d.ts +0 -45
- package/lib/op.d.ts.map +0 -1
- package/lib/op.js +0 -225
- package/lib/op.js.map +0 -1
- package/lib/table.d.ts +0 -56
- package/lib/table.d.ts.map +0 -1
- package/lib/table.js +0 -456
- package/lib/table.js.map +0 -1
- package/lib/utils.d.ts +0 -26
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js +0 -438
- package/lib/utils.js.map +0 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Op, Sequelize } from 'sequelize';
|
|
2
|
+
import { isPg, isMySQL } from './utils';
|
|
3
|
+
const getFieldName = (ctx) => {
|
|
4
|
+
const fieldName = ctx.fieldName;
|
|
5
|
+
return fieldName;
|
|
6
|
+
};
|
|
7
|
+
const escape = (value, ctx) => {
|
|
8
|
+
const sequelize = ctx.db.sequelize;
|
|
9
|
+
return sequelize.escape(value);
|
|
10
|
+
};
|
|
11
|
+
const sqliteExistQuery = (value, ctx) => {
|
|
12
|
+
const fieldName = getFieldName(ctx);
|
|
13
|
+
const sqlArray = `(${value.map((v) => `'${v}'`).join(', ')})`;
|
|
14
|
+
const subQuery = `exists (select * from json_each(${fieldName}) where json_each.value in ${sqlArray})`;
|
|
15
|
+
return subQuery;
|
|
16
|
+
};
|
|
17
|
+
const emptyQuery = (ctx, operator) => {
|
|
18
|
+
const fieldName = getFieldName(ctx);
|
|
19
|
+
let funcName = 'json_array_length';
|
|
20
|
+
let ifNull = 'IFNULL';
|
|
21
|
+
if (isPg(ctx)) {
|
|
22
|
+
funcName = 'jsonb_array_length';
|
|
23
|
+
ifNull = 'coalesce';
|
|
24
|
+
}
|
|
25
|
+
if (isMySQL(ctx)) {
|
|
26
|
+
funcName = 'json_length';
|
|
27
|
+
}
|
|
28
|
+
return `(select ${ifNull}(${funcName}(${fieldName}), 0) ${operator} 0)`;
|
|
29
|
+
};
|
|
30
|
+
export default {
|
|
31
|
+
$match(value, ctx) {
|
|
32
|
+
const fieldName = getFieldName(ctx);
|
|
33
|
+
if (isPg(ctx)) {
|
|
34
|
+
return {
|
|
35
|
+
[Op.contained]: value,
|
|
36
|
+
[Op.contains]: value,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
value = escape(JSON.stringify(value.sort()), ctx);
|
|
40
|
+
if (isMySQL(ctx)) {
|
|
41
|
+
return Sequelize.literal(`JSON_CONTAINS(${fieldName}, ${value}) AND JSON_CONTAINS(${value}, ${fieldName})`);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
[Op.eq]: Sequelize.literal(`json(${value})`),
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
$notMatch(value, ctx) {
|
|
48
|
+
const fieldName = getFieldName(ctx);
|
|
49
|
+
value = escape(JSON.stringify(value), ctx);
|
|
50
|
+
if (isPg(ctx)) {
|
|
51
|
+
return Sequelize.literal(`not (${fieldName} <@ ${value}::JSONB and ${fieldName} @> ${value}::JSONB)`);
|
|
52
|
+
}
|
|
53
|
+
if (isMySQL(ctx)) {
|
|
54
|
+
return Sequelize.literal(`not (JSON_CONTAINS(${fieldName}, ${value}) AND JSON_CONTAINS(${value}, ${fieldName}))`);
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
[Op.ne]: Sequelize.literal(`json(${value})`),
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
$anyOf(value, ctx) {
|
|
61
|
+
const fieldName = getFieldName(ctx);
|
|
62
|
+
if (isPg(ctx)) {
|
|
63
|
+
return Sequelize.literal(`${fieldName} ?| ${escape(value.map((i) => `${i}`), ctx)}`);
|
|
64
|
+
}
|
|
65
|
+
if (isMySQL(ctx)) {
|
|
66
|
+
value = escape(JSON.stringify(value), ctx);
|
|
67
|
+
return Sequelize.literal(`JSON_OVERLAPS(${fieldName}, ${value})`);
|
|
68
|
+
}
|
|
69
|
+
const subQuery = sqliteExistQuery(value, ctx);
|
|
70
|
+
return Sequelize.literal(subQuery);
|
|
71
|
+
},
|
|
72
|
+
$noneOf(value, ctx) {
|
|
73
|
+
let where;
|
|
74
|
+
if (isPg(ctx)) {
|
|
75
|
+
const fieldName = getFieldName(ctx);
|
|
76
|
+
// pg single quote
|
|
77
|
+
where = Sequelize.literal(`not (${fieldName} ?| ${escape(value.map((i) => `${i}`), ctx)})`);
|
|
78
|
+
}
|
|
79
|
+
else if (isMySQL(ctx)) {
|
|
80
|
+
const fieldName = getFieldName(ctx);
|
|
81
|
+
value = escape(JSON.stringify(value), ctx);
|
|
82
|
+
where = Sequelize.literal(`NOT JSON_OVERLAPS(${fieldName}, ${value})`);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const subQuery = sqliteExistQuery(value, ctx);
|
|
86
|
+
where = Sequelize.literal(`not ${subQuery}`);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
[Op.or]: [where, { [Op.is]: null }],
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
$arrayEmpty(value, ctx) {
|
|
93
|
+
const subQuery = emptyQuery(ctx, '=');
|
|
94
|
+
return {
|
|
95
|
+
[Op.and]: [Sequelize.literal(`${subQuery}`)],
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
$arrayNotEmpty(value, ctx) {
|
|
99
|
+
const subQuery = emptyQuery(ctx, '>');
|
|
100
|
+
return {
|
|
101
|
+
[Op.and]: [Sequelize.literal(`${subQuery}`)],
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/operators/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,EAAE;IAC3B,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IAChC,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC5B,MAAM,SAAS,GAAc,GAAG,CAAC,EAAE,C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OAAO;YACL,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC;SACpC,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,KAAK,EAAE,GAAG;QACpB,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAEtC,OAAO;YACL,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,QAAQ,EAAE,CAAC,CAAC;SAC7C,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,KAAK,EAAE,GAAG;QACvB,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAEtC,OAAO;YACL,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,QAAQ,EAAE,CAAC,CAAC;SAC7C,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { Op, Sequelize } from 'sequelize';\nimport { isPg, isMySQL } from './utils';\n\nconst getFieldName = (ctx) => {\n const fieldName = ctx.fieldName;\n return fieldName;\n};\n\nconst escape = (value, ctx) => {\n const sequelize: Sequelize = ctx.db.sequelize;\n return sequelize.escape(value);\n};\n\nconst sqliteExistQuery = (value, ctx) => {\n const fieldName = getFieldName(ctx);\n\n const sqlArray = `(${value.map((v) => `'${v}'`).join(', ')})`;\n\n const subQuery = `exists (select * from json_each(${fieldName}) where json_each.value in ${sqlArray})`;\n\n return subQuery;\n};\n\nconst emptyQuery = (ctx, operator: '=' | '>') => {\n const fieldName = getFieldName(ctx);\n\n let funcName = 'json_array_length';\n let ifNull = 'IFNULL';\n\n if (isPg(ctx)) {\n funcName = 'jsonb_array_length';\n ifNull = 'coalesce';\n }\n\n if (isMySQL(ctx)) {\n funcName = 'json_length';\n }\n\n return `(select ${ifNull}(${funcName}(${fieldName}), 0) ${operator} 0)`;\n};\n\nexport default {\n $match(value, ctx) {\n const fieldName = getFieldName(ctx);\n\n if (isPg(ctx)) {\n return {\n [Op.contained]: value,\n [Op.contains]: value,\n };\n }\n\n value = escape(JSON.stringify(value.sort()), ctx);\n\n if (isMySQL(ctx)) {\n return Sequelize.literal(`JSON_CONTAINS(${fieldName}, ${value}) AND JSON_CONTAINS(${value}, ${fieldName})`);\n }\n\n return {\n [Op.eq]: Sequelize.literal(`json(${value})`),\n };\n },\n\n $notMatch(value, ctx) {\n const fieldName = getFieldName(ctx);\n value = escape(JSON.stringify(value), ctx);\n\n if (isPg(ctx)) {\n return Sequelize.literal(`not (${fieldName} <@ ${value}::JSONB and ${fieldName} @> ${value}::JSONB)`);\n }\n\n if (isMySQL(ctx)) {\n return Sequelize.literal(`not (JSON_CONTAINS(${fieldName}, ${value}) AND JSON_CONTAINS(${value}, ${fieldName}))`);\n }\n return {\n [Op.ne]: Sequelize.literal(`json(${value})`),\n };\n },\n\n $anyOf(value, ctx) {\n const fieldName = getFieldName(ctx);\n\n if (isPg(ctx)) {\n return Sequelize.literal(\n `${fieldName} ?| ${escape(\n value.map((i) => `${i}`),\n ctx,\n )}`,\n );\n }\n\n if (isMySQL(ctx)) {\n value = escape(JSON.stringify(value), ctx);\n\n return Sequelize.literal(`JSON_OVERLAPS(${fieldName}, ${value})`);\n }\n\n const subQuery = sqliteExistQuery(value, ctx);\n\n return Sequelize.literal(subQuery);\n },\n\n $noneOf(value, ctx) {\n let where;\n\n if (isPg(ctx)) {\n const fieldName = getFieldName(ctx);\n // pg single quote\n where = Sequelize.literal(\n `not (${fieldName} ?| ${escape(\n value.map((i) => `${i}`),\n ctx,\n )})`,\n );\n } else if (isMySQL(ctx)) {\n const fieldName = getFieldName(ctx);\n value = escape(JSON.stringify(value), ctx);\n where = Sequelize.literal(`NOT JSON_OVERLAPS(${fieldName}, ${value})`);\n } else {\n const subQuery = sqliteExistQuery(value, ctx);\n\n where = Sequelize.literal(`not ${subQuery}`);\n }\n\n return {\n [Op.or]: [where, { [Op.is]: null }],\n };\n },\n\n $arrayEmpty(value, ctx) {\n const subQuery = emptyQuery(ctx, '=');\n\n return {\n [Op.and]: [Sequelize.literal(`${subQuery}`)],\n };\n },\n\n $arrayNotEmpty(value, ctx) {\n const subQuery = emptyQuery(ctx, '>');\n\n return {\n [Op.and]: [Sequelize.literal(`${subQuery}`)],\n };\n },\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"association.js","sourceRoot":"","sources":["../../src/operators/association.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAa,MAAM,WAAW,CAAC;AAE1C,eAAe;IACb,OAAO,CAAC,KAAK,EAAE,GAAG;QAChB,OAAO;YACL,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;IACD,UAAU,CAAC,KAAK,EAAE,GAAG;QACnB,OAAO;YACL,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { Op, Sequelize } from 'sequelize';\n\nexport default {\n $exists(value, ctx) {\n return {\n [Op.not]: null,\n };\n },\n $notExists(value, ctx) {\n return {\n [Op.is]: null,\n };\n },\n};\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Op } from 'sequelize';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
$dateOn(value: any): {
|
|
4
|
+
[Op.and]: ({
|
|
5
|
+
[Op.gte]: Date;
|
|
6
|
+
[Op.lt]?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
[Op.lt]: Date;
|
|
9
|
+
[Op.gte]?: undefined;
|
|
10
|
+
})[];
|
|
11
|
+
};
|
|
12
|
+
$dateNotOn(value: any): {
|
|
13
|
+
[Op.or]: ({
|
|
14
|
+
[Op.lt]: Date;
|
|
15
|
+
[Op.gte]?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
[Op.gte]: Date;
|
|
18
|
+
[Op.lt]?: undefined;
|
|
19
|
+
})[];
|
|
20
|
+
};
|
|
21
|
+
$dateBefore(value: any): {
|
|
22
|
+
[Op.lt]: Date;
|
|
23
|
+
};
|
|
24
|
+
$dateNotBefore(value: any): {
|
|
25
|
+
[Op.gte]: Date;
|
|
26
|
+
};
|
|
27
|
+
$dateAfter(value: any): {
|
|
28
|
+
[Op.gte]: Date;
|
|
29
|
+
};
|
|
30
|
+
$dateNotAfter(value: any): {
|
|
31
|
+
[Op.lt]: Date;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Op } from 'sequelize';
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
function stringToDate(value) {
|
|
4
|
+
return moment(value).toDate();
|
|
5
|
+
}
|
|
6
|
+
function getNextDay(value) {
|
|
7
|
+
return moment(value).add(1, 'd').toDate();
|
|
8
|
+
}
|
|
9
|
+
export default {
|
|
10
|
+
$dateOn(value) {
|
|
11
|
+
return {
|
|
12
|
+
[Op.and]: [{ [Op.gte]: stringToDate(value) }, { [Op.lt]: getNextDay(value) }],
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
$dateNotOn(value) {
|
|
16
|
+
return {
|
|
17
|
+
[Op.or]: [{ [Op.lt]: stringToDate(value) }, { [Op.gte]: getNextDay(value) }],
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
$dateBefore(value) {
|
|
21
|
+
return { [Op.lt]: stringToDate(value) };
|
|
22
|
+
},
|
|
23
|
+
$dateNotBefore(value) {
|
|
24
|
+
return {
|
|
25
|
+
[Op.gte]: stringToDate(value),
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
$dateAfter(value) {
|
|
29
|
+
return { [Op.gte]: getNextDay(value) };
|
|
30
|
+
},
|
|
31
|
+
$dateNotAfter(value) {
|
|
32
|
+
return { [Op.lt]: getNextDay(value) };
|
|
33
|
+
},
|
|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CAAC;SAC9B,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,KAAK;QACd,OAAO,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;IACzC,CAAC;IAED,aAAa,CAAC,KAAK;QACjB,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;IACxC,CAAC;CACF,CAAC","sourcesContent":["import { Op } from 'sequelize';\nimport moment, { MomentInput } from 'moment';\nfunction stringToDate(value: string): Date {\n return moment(value).toDate();\n}\n\nfunction getNextDay(value: MomentInput): Date {\n return moment(value).add(1, 'd').toDate();\n}\n\nexport default {\n $dateOn(value) {\n return {\n [Op.and]: [{ [Op.gte]: stringToDate(value) }, { [Op.lt]: getNextDay(value) }],\n };\n },\n\n $dateNotOn(value) {\n return {\n [Op.or]: [{ [Op.lt]: stringToDate(value) }, { [Op.gte]: getNextDay(value) }],\n };\n },\n\n $dateBefore(value) {\n return { [Op.lt]: stringToDate(value) };\n },\n\n $dateNotBefore(value) {\n return {\n [Op.gte]: stringToDate(value),\n };\n },\n\n $dateAfter(value) {\n return { [Op.gte]: getNextDay(value) };\n },\n\n $dateNotAfter(value) {\n return { [Op.lt]: getNextDay(value) };\n },\n};\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Op } from 'sequelize';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
$empty(_: any, ctx: any): {
|
|
4
|
+
[Op.and]: import("sequelize/types/lib/utils").Literal[];
|
|
5
|
+
} | {
|
|
6
|
+
[Op.or]: {
|
|
7
|
+
[Op.is]: any;
|
|
8
|
+
[Op.eq]: string;
|
|
9
|
+
};
|
|
10
|
+
[Op.is]?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
[Op.is]: any;
|
|
13
|
+
[Op.or]?: undefined;
|
|
14
|
+
};
|
|
15
|
+
$notEmpty(_: any, ctx: any): {
|
|
16
|
+
[Op.and]: import("sequelize/types/lib/utils").Literal[];
|
|
17
|
+
} | {
|
|
18
|
+
[Op.and]: {
|
|
19
|
+
[Op.not]: any;
|
|
20
|
+
[Op.ne]: string;
|
|
21
|
+
};
|
|
22
|
+
[Op.not]?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
[Op.not]: any;
|
|
25
|
+
[Op.and]?: undefined;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Op } from 'sequelize';
|
|
2
|
+
import { ArrayField, StringField } from '../fields';
|
|
3
|
+
import arrayOperators from './array';
|
|
4
|
+
import lodash, { parseInt } from 'lodash';
|
|
5
|
+
const findFilterFieldType = (ctx) => {
|
|
6
|
+
const db = ctx.db;
|
|
7
|
+
let path = ctx.path.split('.');
|
|
8
|
+
// remove operators
|
|
9
|
+
path.pop();
|
|
10
|
+
const fieldName = path.pop();
|
|
11
|
+
let model = ctx.model;
|
|
12
|
+
const associationPath = path;
|
|
13
|
+
for (const association of associationPath) {
|
|
14
|
+
if (lodash.isNumber(parseInt(association)) || association.startsWith('$')) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
model = model.associations[association].target;
|
|
18
|
+
}
|
|
19
|
+
const collection = db.modelCollection.get(model);
|
|
20
|
+
return collection.getField(fieldName);
|
|
21
|
+
};
|
|
22
|
+
export default {
|
|
23
|
+
$empty(_, ctx) {
|
|
24
|
+
const field = findFilterFieldType(ctx);
|
|
25
|
+
if (field instanceof StringField) {
|
|
26
|
+
return {
|
|
27
|
+
[Op.or]: {
|
|
28
|
+
[Op.is]: null,
|
|
29
|
+
[Op.eq]: '',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (field instanceof ArrayField) {
|
|
34
|
+
return arrayOperators.$arrayEmpty(_, ctx);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
[Op.is]: null,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
$notEmpty(_, ctx) {
|
|
41
|
+
const field = findFilterFieldType(ctx);
|
|
42
|
+
if (field instanceof StringField) {
|
|
43
|
+
return {
|
|
44
|
+
[Op.and]: {
|
|
45
|
+
[Op.not]: null,
|
|
46
|
+
[Op.ne]: '',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (field instanceof ArrayField) {
|
|
51
|
+
return arrayOperators.$arrayNotEmpty(_, ctx);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
[Op.not]: null,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=empty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty.js","sourceRoot":"","sources":["../../src/operators/empty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,EAAE,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,cAAc,MAAM,SAAS,CAAC;AACrC,OAAO,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAE1C,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,EAAE;IAClC,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;IAElB,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE/B,mBAAmB;IACnB,IAAI,CAAC,GAAG,EAAE,CAAC;IAEX,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;IAEtB,MAAM,eAAe,GAAG,IAAI,CAAC;IAE7B,KAAK,MAAM,WAAW,IAAI,eAAe,EAAE;QACzC,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAA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AAE,CAAC,GAAG,CAAC,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { DataTypes, Op } from 'sequelize';\nimport { ArrayField, StringField } from '../fields';\nimport arrayOperators from './array';\nimport lodash, { parseInt } from 'lodash';\n\nconst findFilterFieldType = (ctx) => {\n const db = ctx.db;\n\n let path = ctx.path.split('.');\n\n // remove operators\n path.pop();\n\n const fieldName = path.pop();\n\n let model = ctx.model;\n\n const associationPath = path;\n\n for (const association of associationPath) {\n if (lodash.isNumber(parseInt(association)) || association.startsWith('$')) {\n continue;\n }\n\n model = model.associations[association].target;\n }\n\n const collection = db.modelCollection.get(model);\n\n return collection.getField(fieldName);\n};\n\nexport default {\n $empty(_, ctx) {\n const field = findFilterFieldType(ctx);\n\n if (field instanceof StringField) {\n return {\n [Op.or]: {\n [Op.is]: null,\n [Op.eq]: '',\n },\n };\n }\n\n if (field instanceof ArrayField) {\n return arrayOperators.$arrayEmpty(_, ctx);\n }\n\n return {\n [Op.is]: null,\n };\n },\n\n $notEmpty(_, ctx) {\n const field = findFilterFieldType(ctx);\n\n if (field instanceof StringField) {\n return {\n [Op.and]: {\n [Op.not]: null,\n [Op.ne]: '',\n },\n };\n }\n\n if (field instanceof ArrayField) {\n return arrayOperators.$arrayNotEmpty(_, ctx);\n }\n\n return {\n [Op.not]: null,\n };\n },\n};\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export default Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, require('./association').default), require('./date').default), require('./array').default), require('./empty').default), require('./string').default), require('./ne').default);
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/operators/index.ts"],"names":[],"mappings":"AAAA,uGACK,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,GAChC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,GACzB,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,GAC1B,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,GAC1B,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,GAC3B,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,EAC1B","sourcesContent":["export default {\n ...require('./association').default,\n ...require('./date').default,\n ...require('./array').default,\n ...require('./empty').default,\n ...require('./string').default,\n ...require('./ne').default,\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ne.js","sourceRoot":"","sources":["../../src/operators/ne.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAE/B,eAAe;IACb,GAAG,CAAC,GAAG,EAAE,GAAG;QACV,OAAO;YACL,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;gBACP,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG;gBACZ,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI;aACd;SACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { Op } from 'sequelize';\n\nexport default {\n $ne(val, ctx) {\n return {\n [Op.or]: {\n [Op.ne]: val,\n [Op.is]: null,\n },\n };\n },\n};\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
$includes(value: any, ctx: any): {
|
|
3
|
+
[x: symbol]: string;
|
|
4
|
+
};
|
|
5
|
+
$notIncludes(value: any, ctx: any): {
|
|
6
|
+
[x: symbol]: string;
|
|
7
|
+
};
|
|
8
|
+
$startsWith(value: any, ctx: any): {
|
|
9
|
+
[x: symbol]: string;
|
|
10
|
+
};
|
|
11
|
+
$notStartsWith(value: any, ctx: any): {
|
|
12
|
+
[x: symbol]: string;
|
|
13
|
+
};
|
|
14
|
+
$endWith(value: any, ctx: any): {
|
|
15
|
+
[x: symbol]: string;
|
|
16
|
+
};
|
|
17
|
+
$notEndWith(value: any, ctx: any): {
|
|
18
|
+
[x: symbol]: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isPg } from './utils';
|
|
2
|
+
import { Op } from 'sequelize';
|
|
3
|
+
export default {
|
|
4
|
+
$includes(value, ctx) {
|
|
5
|
+
return {
|
|
6
|
+
[isPg(ctx) ? Op.iLike : Op.like]: `%${value}%`,
|
|
7
|
+
};
|
|
8
|
+
},
|
|
9
|
+
$notIncludes(value, ctx) {
|
|
10
|
+
return {
|
|
11
|
+
[isPg(ctx) ? Op.notILike : Op.notLike]: `%${value}%`,
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
$startsWith(value, ctx) {
|
|
15
|
+
return {
|
|
16
|
+
[isPg(ctx) ? Op.iLike : Op.like]: `${value}%`,
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
$notStartsWith(value, ctx) {
|
|
20
|
+
return {
|
|
21
|
+
[isPg(ctx) ? Op.notILike : Op.notLike]: `${value}%`,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
$endWith(value, ctx) {
|
|
25
|
+
return {
|
|
26
|
+
[isPg(ctx) ? Op.iLike : Op.like]: `%${value}`,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
$notEndWith(value, ctx) {
|
|
30
|
+
return {
|
|
31
|
+
[isPg(ctx) ? Op.notILike : Op.notLike]: `%${value}`,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/operators/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAE/B,eAAe;IACb,SAAS,CAAC,KAAK,EAAE,GAAG;QAClB,OAAO;YACL,CAAC,IAAI,CA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op } from 'sequelize';\n\nexport default {\n $includes(value, ctx) {\n return {\n [isPg(ctx) ? Op.iLike : Op.like]: `%${value}%`,\n };\n },\n\n $notIncludes(value, ctx) {\n return {\n [isPg(ctx) ? Op.notILike : Op.notLike]: `%${value}%`,\n };\n },\n\n $startsWith(value, ctx) {\n return {\n [isPg(ctx) ? Op.iLike : Op.like]: `${value}%`,\n };\n },\n\n $notStartsWith(value, ctx) {\n return {\n [isPg(ctx) ? Op.notILike : Op.notLike]: `${value}%`,\n };\n },\n\n $endWith(value, ctx) {\n return {\n [isPg(ctx) ? Op.iLike : Op.like]: `%${value}`,\n };\n },\n\n $notEndWith(value, ctx) {\n return {\n [isPg(ctx) ? Op.notILike : Op.notLike]: `%${value}`,\n };\n },\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const getDialect = (ctx) => {
|
|
2
|
+
return ctx.db.sequelize.getDialect();
|
|
3
|
+
};
|
|
4
|
+
const isPg = (ctx) => {
|
|
5
|
+
return getDialect(ctx) === 'postgres';
|
|
6
|
+
};
|
|
7
|
+
const isMySQL = (ctx) => {
|
|
8
|
+
return getDialect(ctx) === 'mysql';
|
|
9
|
+
};
|
|
10
|
+
export { getDialect, isPg, isMySQL };
|
|
11
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/operators/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,EAAE;IACzB,OAAO,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,UAAU,CAAC,GAAG,CAAC,KAAK,UAAU,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,EAAE;IACtB,OAAO,UAAU,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC;AACrC,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC","sourcesContent":["const getDialect = (ctx) => {\n return ctx.db.sequelize.getDialect();\n};\n\nconst isPg = (ctx) => {\n return getDialect(ctx) === 'postgres';\n};\n\nconst isMySQL = (ctx) => {\n return getDialect(ctx) === 'mysql';\n};\n\nexport { getDialect, isPg, isMySQL };\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ModelCtor } from 'sequelize';
|
|
2
|
+
import { Collection } from './collection';
|
|
3
|
+
import { Database } from './database';
|
|
4
|
+
import FilterParser from './filter-parser';
|
|
5
|
+
import { Appends, Except, FindOptions } from './repository';
|
|
6
|
+
interface OptionsParserContext {
|
|
7
|
+
collection: Collection;
|
|
8
|
+
targetKey?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class OptionsParser {
|
|
11
|
+
options: FindOptions;
|
|
12
|
+
database: Database;
|
|
13
|
+
collection: Collection;
|
|
14
|
+
model: ModelCtor<any>;
|
|
15
|
+
filterParser: FilterParser;
|
|
16
|
+
context: OptionsParserContext;
|
|
17
|
+
constructor(options: FindOptions, context: OptionsParserContext);
|
|
18
|
+
isAssociation(key: string): boolean;
|
|
19
|
+
isAssociationPath(path: string): boolean;
|
|
20
|
+
toSequelizeParams(): any;
|
|
21
|
+
/**
|
|
22
|
+
* parser sort options
|
|
23
|
+
* @param filterParams
|
|
24
|
+
* @protected
|
|
25
|
+
*/
|
|
26
|
+
protected parseSort(filterParams: any): any;
|
|
27
|
+
protected parseFields(filterParams: any): any;
|
|
28
|
+
protected parseExcept(except: Except, filterParams: any): any;
|
|
29
|
+
protected parseAppends(appends: Appends, filterParams: any): any;
|
|
30
|
+
}
|
|
31
|
+
export {};
|