@warlock.js/cascade 4.0.48 → 4.0.58
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/cjs/context/database-data-source-context.d.ts +29 -0
- package/cjs/context/database-data-source-context.d.ts.map +1 -0
- package/cjs/context/database-data-source-context.js +28 -0
- package/cjs/context/database-data-source-context.js.map +1 -0
- package/cjs/context/database-transaction-context.d.ts +31 -0
- package/cjs/context/database-transaction-context.d.ts.map +1 -0
- package/cjs/context/database-transaction-context.js +34 -0
- package/cjs/context/database-transaction-context.js.map +1 -0
- package/cjs/contracts/database-driver.contract.d.ts +143 -0
- package/cjs/contracts/database-driver.contract.d.ts.map +1 -0
- package/cjs/contracts/database-id-generator.contract.d.ts +109 -0
- package/cjs/contracts/database-id-generator.contract.d.ts.map +1 -0
- package/cjs/contracts/database-remover.contract.d.ts +104 -0
- package/cjs/contracts/database-remover.contract.d.ts.map +1 -0
- package/cjs/contracts/database-restorer.contract.d.ts +143 -0
- package/cjs/contracts/database-restorer.contract.d.ts.map +1 -0
- package/cjs/contracts/database-writer.contract.d.ts +119 -0
- package/cjs/contracts/database-writer.contract.d.ts.map +1 -0
- package/cjs/contracts/driver-blueprint.contract.d.ts +45 -0
- package/cjs/contracts/driver-blueprint.contract.d.ts.map +1 -0
- package/cjs/contracts/index.d.ts +10 -0
- package/cjs/contracts/index.d.ts.map +1 -0
- package/cjs/contracts/migration-driver.contract.d.ts +365 -0
- package/cjs/contracts/migration-driver.contract.d.ts.map +1 -0
- package/cjs/contracts/query-builder.contract.d.ts +1128 -0
- package/cjs/contracts/query-builder.contract.d.ts.map +1 -0
- package/cjs/contracts/sync-adapter.contract.d.ts +58 -0
- package/cjs/contracts/sync-adapter.contract.d.ts.map +1 -0
- package/cjs/data-source/data-source-registry.d.ts +104 -0
- package/cjs/data-source/data-source-registry.d.ts.map +1 -0
- package/cjs/data-source/data-source-registry.js +138 -0
- package/cjs/data-source/data-source-registry.js.map +1 -0
- package/cjs/data-source/data-source.d.ts +106 -0
- package/cjs/data-source/data-source.d.ts.map +1 -0
- package/cjs/data-source/data-source.js +77 -0
- package/cjs/data-source/data-source.js.map +1 -0
- package/cjs/database-dirty-tracker.d.ts +253 -0
- package/cjs/database-dirty-tracker.d.ts.map +1 -0
- package/cjs/database-dirty-tracker.js +389 -0
- package/cjs/database-dirty-tracker.js.map +1 -0
- package/cjs/drivers/mongo/mongo-id-generator.d.ts +116 -0
- package/cjs/drivers/mongo/mongo-id-generator.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-id-generator.js +149 -0
- package/cjs/drivers/mongo/mongo-id-generator.js.map +1 -0
- package/cjs/drivers/mongo/mongo-migration-driver.d.ts +228 -0
- package/cjs/drivers/mongo/mongo-migration-driver.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-migration-driver.js +524 -0
- package/cjs/drivers/mongo/mongo-migration-driver.js.map +1 -0
- package/cjs/drivers/mongo/mongo-query-builder.d.ts +922 -0
- package/cjs/drivers/mongo/mongo-query-builder.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-query-builder.js +1740 -0
- package/cjs/drivers/mongo/mongo-query-builder.js.map +1 -0
- package/cjs/drivers/mongo/mongo-query-operations.d.ts +226 -0
- package/cjs/drivers/mongo/mongo-query-operations.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-query-operations.js +270 -0
- package/cjs/drivers/mongo/mongo-query-operations.js.map +1 -0
- package/cjs/drivers/mongo/mongo-query-parser.d.ts +262 -0
- package/cjs/drivers/mongo/mongo-query-parser.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-query-parser.js +1351 -0
- package/cjs/drivers/mongo/mongo-query-parser.js.map +1 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.d.ts +79 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.js +146 -0
- package/cjs/drivers/mongo/mongo-sync-adapter.js.map +1 -0
- package/cjs/drivers/mongo/mongodb-blueprint.d.ts +30 -0
- package/cjs/drivers/mongo/mongodb-blueprint.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongodb-blueprint.js +51 -0
- package/cjs/drivers/mongo/mongodb-blueprint.js.map +1 -0
- package/cjs/drivers/mongo/mongodb-driver.d.ts +188 -0
- package/cjs/drivers/mongo/mongodb-driver.d.ts.map +1 -0
- package/cjs/drivers/mongo/mongodb-driver.js +411 -0
- package/cjs/drivers/mongo/mongodb-driver.js.map +1 -0
- package/cjs/drivers/mongo/types.d.ts +43 -0
- package/cjs/drivers/mongo/types.d.ts.map +1 -0
- package/cjs/errors/missing-data-source.error.d.ts +22 -0
- package/cjs/errors/missing-data-source.error.d.ts.map +1 -0
- package/cjs/errors/missing-data-source.error.js +29 -0
- package/cjs/errors/missing-data-source.error.js.map +1 -0
- package/cjs/events/model-events.d.ts +231 -0
- package/cjs/events/model-events.d.ts.map +1 -0
- package/cjs/events/model-events.js +259 -0
- package/cjs/events/model-events.js.map +1 -0
- package/cjs/expressions/aggregate-expressions.d.ts +215 -0
- package/cjs/expressions/aggregate-expressions.d.ts.map +1 -0
- package/cjs/expressions/aggregate-expressions.js +221 -0
- package/cjs/expressions/aggregate-expressions.js.map +1 -0
- package/cjs/expressions/index.d.ts +2 -0
- package/cjs/expressions/index.d.ts.map +1 -0
- package/cjs/index.d.ts +41 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +1 -267
- package/cjs/index.js.map +1 -1
- package/cjs/migration/column-builder.d.ts +167 -0
- package/cjs/migration/column-builder.d.ts.map +1 -0
- package/cjs/migration/column-builder.js +217 -0
- package/cjs/migration/column-builder.js.map +1 -0
- package/cjs/migration/foreign-key-builder.d.ts +110 -0
- package/cjs/migration/foreign-key-builder.d.ts.map +1 -0
- package/cjs/migration/foreign-key-builder.js +129 -0
- package/cjs/migration/foreign-key-builder.js.map +1 -0
- package/cjs/migration/index.d.ts +6 -0
- package/cjs/migration/index.d.ts.map +1 -0
- package/cjs/migration/migration-runner.d.ts +231 -0
- package/cjs/migration/migration-runner.d.ts.map +1 -0
- package/cjs/migration/migration-runner.js +443 -0
- package/cjs/migration/migration-runner.js.map +1 -0
- package/cjs/migration/migration.js +1346 -0
- package/cjs/migration/migration.js.map +1 -0
- package/cjs/migration/types.d.ts +132 -0
- package/cjs/migration/types.d.ts.map +1 -0
- package/cjs/model/model.d.ts +1267 -0
- package/cjs/model/model.d.ts.map +1 -0
- package/cjs/model/model.js +1463 -0
- package/cjs/model/model.js.map +1 -0
- package/cjs/model/register-model.d.ts +80 -0
- package/cjs/model/register-model.d.ts.map +1 -0
- package/cjs/model/register-model.js +91 -0
- package/cjs/model/register-model.js.map +1 -0
- package/cjs/remover/database-remover.d.ts +100 -0
- package/cjs/remover/database-remover.d.ts.map +1 -0
- package/cjs/remover/database-remover.js +209 -0
- package/cjs/remover/database-remover.js.map +1 -0
- package/cjs/restorer/database-restorer.d.ts +131 -0
- package/cjs/restorer/database-restorer.d.ts.map +1 -0
- package/cjs/restorer/database-restorer.js +425 -0
- package/cjs/restorer/database-restorer.js.map +1 -0
- package/cjs/sync/index.d.ts +12 -0
- package/cjs/sync/index.d.ts.map +1 -0
- package/cjs/sync/model-events.d.ts +62 -0
- package/cjs/sync/model-events.d.ts.map +1 -0
- package/cjs/sync/model-events.js +49 -0
- package/cjs/sync/model-events.js.map +1 -0
- package/cjs/sync/model-sync-operation.d.ts +163 -0
- package/cjs/sync/model-sync-operation.d.ts.map +1 -0
- package/cjs/sync/model-sync-operation.js +292 -0
- package/cjs/sync/model-sync-operation.js.map +1 -0
- package/cjs/sync/model-sync.d.ts +130 -0
- package/cjs/sync/model-sync.d.ts.map +1 -0
- package/cjs/sync/model-sync.js +178 -0
- package/cjs/sync/model-sync.js.map +1 -0
- package/cjs/sync/sync-context.d.ts +70 -0
- package/cjs/sync/sync-context.d.ts.map +1 -0
- package/cjs/sync/sync-context.js +101 -0
- package/cjs/sync/sync-context.js.map +1 -0
- package/cjs/sync/sync-manager.d.ts +213 -0
- package/cjs/sync/sync-manager.d.ts.map +1 -0
- package/cjs/sync/sync-manager.js +689 -0
- package/cjs/sync/sync-manager.js.map +1 -0
- package/cjs/sync/types.d.ts +289 -0
- package/cjs/sync/types.d.ts.map +1 -0
- package/cjs/types.d.ts +45 -0
- package/cjs/types.d.ts.map +1 -0
- package/cjs/utils/connect-to-database.d.ts +246 -0
- package/cjs/utils/connect-to-database.d.ts.map +1 -0
- package/cjs/utils/connect-to-database.js +92 -0
- package/cjs/utils/connect-to-database.js.map +1 -0
- package/cjs/utils/database-writer.utils.d.ts +15 -0
- package/cjs/utils/database-writer.utils.d.ts.map +1 -0
- package/cjs/utils/database-writer.utils.js +14 -0
- package/cjs/utils/database-writer.utils.js.map +1 -0
- package/cjs/utils/define-model.js +100 -0
- package/cjs/utils/define-model.js.map +1 -0
- package/cjs/utils/once-connected.d.ts +146 -0
- package/cjs/utils/once-connected.d.ts.map +1 -0
- package/cjs/utils/once-connected.js +252 -0
- package/cjs/utils/once-connected.js.map +1 -0
- package/cjs/validation/database-seal-plugins.d.ts +2 -0
- package/cjs/validation/database-seal-plugins.d.ts.map +1 -0
- package/cjs/validation/database-seal-plugins.js +4 -0
- package/cjs/validation/database-seal-plugins.js.map +1 -0
- package/cjs/validation/database-writer-validation-error.d.ts +97 -0
- package/cjs/validation/database-writer-validation-error.d.ts.map +1 -0
- package/cjs/validation/database-writer-validation-error.js +160 -0
- package/cjs/validation/database-writer-validation-error.js.map +1 -0
- package/cjs/validation/index.d.ts +3 -0
- package/cjs/validation/index.d.ts.map +1 -0
- package/cjs/validation/mutators/embed-mutator.d.ts +9 -0
- package/cjs/validation/mutators/embed-mutator.d.ts.map +1 -0
- package/cjs/validation/mutators/embed-mutator.js +33 -0
- package/cjs/validation/mutators/embed-mutator.js.map +1 -0
- package/cjs/validation/plugins/embed-validator-plugin.d.ts +24 -0
- package/cjs/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
- package/cjs/validation/plugins/embed-validator-plugin.js +18 -0
- package/cjs/validation/plugins/embed-validator-plugin.js.map +1 -0
- package/cjs/validation/rules/database-model-rule.d.ts +7 -0
- package/cjs/validation/rules/database-model-rule.d.ts.map +1 -0
- package/cjs/validation/rules/database-model-rule.js +27 -0
- package/cjs/validation/rules/database-model-rule.js.map +1 -0
- package/cjs/validation/transformers/embed-model-transformer.d.ts +3 -0
- package/cjs/validation/transformers/embed-model-transformer.d.ts.map +1 -0
- package/cjs/validation/transformers/embed-model-transformer.js +18 -0
- package/cjs/validation/transformers/embed-model-transformer.js.map +1 -0
- package/cjs/validation/validators/embed-validator.d.ts +21 -0
- package/cjs/validation/validators/embed-validator.d.ts.map +1 -0
- package/cjs/validation/validators/embed-validator.js +42 -0
- package/cjs/validation/validators/embed-validator.js.map +1 -0
- package/cjs/writer/database-writer.d.ts +181 -0
- package/cjs/writer/database-writer.d.ts.map +1 -0
- package/cjs/writer/database-writer.js +402 -0
- package/cjs/writer/database-writer.js.map +1 -0
- package/esm/context/database-data-source-context.d.ts +29 -0
- package/esm/context/database-data-source-context.d.ts.map +1 -0
- package/esm/context/database-data-source-context.js +28 -0
- package/esm/context/database-data-source-context.js.map +1 -0
- package/esm/context/database-transaction-context.d.ts +31 -0
- package/esm/context/database-transaction-context.d.ts.map +1 -0
- package/esm/context/database-transaction-context.js +34 -0
- package/esm/context/database-transaction-context.js.map +1 -0
- package/esm/contracts/database-driver.contract.d.ts +143 -0
- package/esm/contracts/database-driver.contract.d.ts.map +1 -0
- package/esm/contracts/database-id-generator.contract.d.ts +109 -0
- package/esm/contracts/database-id-generator.contract.d.ts.map +1 -0
- package/esm/contracts/database-remover.contract.d.ts +104 -0
- package/esm/contracts/database-remover.contract.d.ts.map +1 -0
- package/esm/contracts/database-restorer.contract.d.ts +143 -0
- package/esm/contracts/database-restorer.contract.d.ts.map +1 -0
- package/esm/contracts/database-writer.contract.d.ts +119 -0
- package/esm/contracts/database-writer.contract.d.ts.map +1 -0
- package/esm/contracts/driver-blueprint.contract.d.ts +45 -0
- package/esm/contracts/driver-blueprint.contract.d.ts.map +1 -0
- package/esm/contracts/index.d.ts +10 -0
- package/esm/contracts/index.d.ts.map +1 -0
- package/esm/contracts/migration-driver.contract.d.ts +365 -0
- package/esm/contracts/migration-driver.contract.d.ts.map +1 -0
- package/esm/contracts/query-builder.contract.d.ts +1128 -0
- package/esm/contracts/query-builder.contract.d.ts.map +1 -0
- package/esm/contracts/sync-adapter.contract.d.ts +58 -0
- package/esm/contracts/sync-adapter.contract.d.ts.map +1 -0
- package/esm/data-source/data-source-registry.d.ts +104 -0
- package/esm/data-source/data-source-registry.d.ts.map +1 -0
- package/esm/data-source/data-source-registry.js +138 -0
- package/esm/data-source/data-source-registry.js.map +1 -0
- package/esm/data-source/data-source.d.ts +106 -0
- package/esm/data-source/data-source.d.ts.map +1 -0
- package/esm/data-source/data-source.js +77 -0
- package/esm/data-source/data-source.js.map +1 -0
- package/esm/database-dirty-tracker.d.ts +253 -0
- package/esm/database-dirty-tracker.d.ts.map +1 -0
- package/esm/database-dirty-tracker.js +389 -0
- package/esm/database-dirty-tracker.js.map +1 -0
- package/esm/drivers/mongo/mongo-id-generator.d.ts +116 -0
- package/esm/drivers/mongo/mongo-id-generator.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-id-generator.js +149 -0
- package/esm/drivers/mongo/mongo-id-generator.js.map +1 -0
- package/esm/drivers/mongo/mongo-migration-driver.d.ts +228 -0
- package/esm/drivers/mongo/mongo-migration-driver.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-migration-driver.js +524 -0
- package/esm/drivers/mongo/mongo-migration-driver.js.map +1 -0
- package/esm/drivers/mongo/mongo-query-builder.d.ts +922 -0
- package/esm/drivers/mongo/mongo-query-builder.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-query-builder.js +1740 -0
- package/esm/drivers/mongo/mongo-query-builder.js.map +1 -0
- package/esm/drivers/mongo/mongo-query-operations.d.ts +226 -0
- package/esm/drivers/mongo/mongo-query-operations.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-query-operations.js +270 -0
- package/esm/drivers/mongo/mongo-query-operations.js.map +1 -0
- package/esm/drivers/mongo/mongo-query-parser.d.ts +262 -0
- package/esm/drivers/mongo/mongo-query-parser.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-query-parser.js +1351 -0
- package/esm/drivers/mongo/mongo-query-parser.js.map +1 -0
- package/esm/drivers/mongo/mongo-sync-adapter.d.ts +79 -0
- package/esm/drivers/mongo/mongo-sync-adapter.d.ts.map +1 -0
- package/esm/drivers/mongo/mongo-sync-adapter.js +146 -0
- package/esm/drivers/mongo/mongo-sync-adapter.js.map +1 -0
- package/esm/drivers/mongo/mongodb-blueprint.d.ts +30 -0
- package/esm/drivers/mongo/mongodb-blueprint.d.ts.map +1 -0
- package/esm/drivers/mongo/mongodb-blueprint.js +51 -0
- package/esm/drivers/mongo/mongodb-blueprint.js.map +1 -0
- package/esm/drivers/mongo/mongodb-driver.d.ts +188 -0
- package/esm/drivers/mongo/mongodb-driver.d.ts.map +1 -0
- package/esm/drivers/mongo/mongodb-driver.js +411 -0
- package/esm/drivers/mongo/mongodb-driver.js.map +1 -0
- package/esm/drivers/mongo/types.d.ts +43 -0
- package/esm/drivers/mongo/types.d.ts.map +1 -0
- package/esm/errors/missing-data-source.error.d.ts +22 -0
- package/esm/errors/missing-data-source.error.d.ts.map +1 -0
- package/esm/errors/missing-data-source.error.js +29 -0
- package/esm/errors/missing-data-source.error.js.map +1 -0
- package/esm/events/model-events.d.ts +231 -0
- package/esm/events/model-events.d.ts.map +1 -0
- package/esm/events/model-events.js +259 -0
- package/esm/events/model-events.js.map +1 -0
- package/esm/expressions/aggregate-expressions.d.ts +215 -0
- package/esm/expressions/aggregate-expressions.d.ts.map +1 -0
- package/esm/expressions/aggregate-expressions.js +221 -0
- package/esm/expressions/aggregate-expressions.js.map +1 -0
- package/esm/expressions/index.d.ts +2 -0
- package/esm/expressions/index.d.ts.map +1 -0
- package/esm/index.d.ts +41 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +1 -40
- package/esm/index.js.map +1 -1
- package/esm/migration/column-builder.d.ts +167 -0
- package/esm/migration/column-builder.d.ts.map +1 -0
- package/esm/migration/column-builder.js +217 -0
- package/esm/migration/column-builder.js.map +1 -0
- package/esm/migration/foreign-key-builder.d.ts +110 -0
- package/esm/migration/foreign-key-builder.d.ts.map +1 -0
- package/esm/migration/foreign-key-builder.js +129 -0
- package/esm/migration/foreign-key-builder.js.map +1 -0
- package/esm/migration/index.d.ts +6 -0
- package/esm/migration/index.d.ts.map +1 -0
- package/esm/migration/migration-runner.d.ts +231 -0
- package/esm/migration/migration-runner.d.ts.map +1 -0
- package/esm/migration/migration-runner.js +443 -0
- package/esm/migration/migration-runner.js.map +1 -0
- package/esm/migration/migration.js +1346 -0
- package/esm/migration/migration.js.map +1 -0
- package/esm/migration/types.d.ts +132 -0
- package/esm/migration/types.d.ts.map +1 -0
- package/esm/model/model.d.ts +1267 -0
- package/esm/model/model.d.ts.map +1 -0
- package/esm/model/model.js +1463 -0
- package/esm/model/model.js.map +1 -0
- package/esm/model/register-model.d.ts +80 -0
- package/esm/model/register-model.d.ts.map +1 -0
- package/esm/model/register-model.js +91 -0
- package/esm/model/register-model.js.map +1 -0
- package/esm/remover/database-remover.d.ts +100 -0
- package/esm/remover/database-remover.d.ts.map +1 -0
- package/esm/remover/database-remover.js +209 -0
- package/esm/remover/database-remover.js.map +1 -0
- package/esm/restorer/database-restorer.d.ts +131 -0
- package/esm/restorer/database-restorer.d.ts.map +1 -0
- package/esm/restorer/database-restorer.js +425 -0
- package/esm/restorer/database-restorer.js.map +1 -0
- package/esm/sync/index.d.ts +12 -0
- package/esm/sync/index.d.ts.map +1 -0
- package/esm/sync/model-events.d.ts +62 -0
- package/esm/sync/model-events.d.ts.map +1 -0
- package/esm/sync/model-events.js +49 -0
- package/esm/sync/model-events.js.map +1 -0
- package/esm/sync/model-sync-operation.d.ts +163 -0
- package/esm/sync/model-sync-operation.d.ts.map +1 -0
- package/esm/sync/model-sync-operation.js +292 -0
- package/esm/sync/model-sync-operation.js.map +1 -0
- package/esm/sync/model-sync.d.ts +130 -0
- package/esm/sync/model-sync.d.ts.map +1 -0
- package/esm/sync/model-sync.js +178 -0
- package/esm/sync/model-sync.js.map +1 -0
- package/esm/sync/sync-context.d.ts +70 -0
- package/esm/sync/sync-context.d.ts.map +1 -0
- package/esm/sync/sync-context.js +101 -0
- package/esm/sync/sync-context.js.map +1 -0
- package/esm/sync/sync-manager.d.ts +213 -0
- package/esm/sync/sync-manager.d.ts.map +1 -0
- package/esm/sync/sync-manager.js +689 -0
- package/esm/sync/sync-manager.js.map +1 -0
- package/esm/sync/types.d.ts +289 -0
- package/esm/sync/types.d.ts.map +1 -0
- package/esm/types.d.ts +45 -0
- package/esm/types.d.ts.map +1 -0
- package/esm/utils/connect-to-database.d.ts +246 -0
- package/esm/utils/connect-to-database.d.ts.map +1 -0
- package/esm/utils/connect-to-database.js +92 -0
- package/esm/utils/connect-to-database.js.map +1 -0
- package/esm/utils/database-writer.utils.d.ts +15 -0
- package/esm/utils/database-writer.utils.d.ts.map +1 -0
- package/esm/utils/database-writer.utils.js +14 -0
- package/esm/utils/database-writer.utils.js.map +1 -0
- package/esm/utils/define-model.js +100 -0
- package/esm/utils/define-model.js.map +1 -0
- package/esm/utils/once-connected.d.ts +146 -0
- package/esm/utils/once-connected.d.ts.map +1 -0
- package/esm/utils/once-connected.js +252 -0
- package/esm/utils/once-connected.js.map +1 -0
- package/esm/validation/database-seal-plugins.d.ts +2 -0
- package/esm/validation/database-seal-plugins.d.ts.map +1 -0
- package/esm/validation/database-seal-plugins.js +4 -0
- package/esm/validation/database-seal-plugins.js.map +1 -0
- package/esm/validation/database-writer-validation-error.d.ts +97 -0
- package/esm/validation/database-writer-validation-error.d.ts.map +1 -0
- package/esm/validation/database-writer-validation-error.js +160 -0
- package/esm/validation/database-writer-validation-error.js.map +1 -0
- package/esm/validation/index.d.ts +3 -0
- package/esm/validation/index.d.ts.map +1 -0
- package/esm/validation/mutators/embed-mutator.d.ts +9 -0
- package/esm/validation/mutators/embed-mutator.d.ts.map +1 -0
- package/esm/validation/mutators/embed-mutator.js +33 -0
- package/esm/validation/mutators/embed-mutator.js.map +1 -0
- package/esm/validation/plugins/embed-validator-plugin.d.ts +24 -0
- package/esm/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
- package/esm/validation/plugins/embed-validator-plugin.js +18 -0
- package/esm/validation/plugins/embed-validator-plugin.js.map +1 -0
- package/esm/validation/rules/database-model-rule.d.ts +7 -0
- package/esm/validation/rules/database-model-rule.d.ts.map +1 -0
- package/esm/validation/rules/database-model-rule.js +27 -0
- package/esm/validation/rules/database-model-rule.js.map +1 -0
- package/esm/validation/transformers/embed-model-transformer.d.ts +3 -0
- package/esm/validation/transformers/embed-model-transformer.d.ts.map +1 -0
- package/esm/validation/transformers/embed-model-transformer.js +18 -0
- package/esm/validation/transformers/embed-model-transformer.js.map +1 -0
- package/esm/validation/validators/embed-validator.d.ts +21 -0
- package/esm/validation/validators/embed-validator.d.ts.map +1 -0
- package/esm/validation/validators/embed-validator.js +42 -0
- package/esm/validation/validators/embed-validator.js.map +1 -0
- package/esm/writer/database-writer.d.ts +181 -0
- package/esm/writer/database-writer.d.ts.map +1 -0
- package/esm/writer/database-writer.js +402 -0
- package/esm/writer/database-writer.js.map +1 -0
- package/package.json +61 -52
|
@@ -0,0 +1,1128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ordering direction supported by query builders.
|
|
3
|
+
*/
|
|
4
|
+
export type OrderDirection = "asc" | "desc";
|
|
5
|
+
/**
|
|
6
|
+
* Options describing a relationship join.
|
|
7
|
+
*/
|
|
8
|
+
export type JoinOptions = {
|
|
9
|
+
/** Target table or collection. */
|
|
10
|
+
table: string;
|
|
11
|
+
/** Local field used in the join condition. */
|
|
12
|
+
localField?: string;
|
|
13
|
+
/** Operator used in the join condition (defaults to equality). */
|
|
14
|
+
operator?: string;
|
|
15
|
+
/** Foreign field used in the join condition. */
|
|
16
|
+
foreignField?: string;
|
|
17
|
+
/** Join type. */
|
|
18
|
+
type?: "inner" | "left" | "right" | "full" | "cross";
|
|
19
|
+
/** Optional alias for the joined relation. */
|
|
20
|
+
alias?: string;
|
|
21
|
+
/** Driver-specific options (e.g. Mongo pipeline). */
|
|
22
|
+
options?: Record<string, unknown>;
|
|
23
|
+
/** Projection overrides for the joined relation. */
|
|
24
|
+
select?: string[];
|
|
25
|
+
/** Extra join conditions expressed as key/value pairs. */
|
|
26
|
+
conditions?: Record<string, unknown>;
|
|
27
|
+
/** Driver specific pipeline/clauses for advanced joins. */
|
|
28
|
+
pipeline?: unknown[];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Pagination result returned by paginate helpers.
|
|
32
|
+
*/
|
|
33
|
+
export type PaginationResult<T> = {
|
|
34
|
+
data: T[];
|
|
35
|
+
pagination: {
|
|
36
|
+
total: number;
|
|
37
|
+
page: number;
|
|
38
|
+
limit: number;
|
|
39
|
+
pages: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Cursor pagination result.
|
|
44
|
+
*/
|
|
45
|
+
export type CursorPaginationResult<T> = {
|
|
46
|
+
data: T[];
|
|
47
|
+
pagination: {
|
|
48
|
+
hasMore: boolean;
|
|
49
|
+
hasPrev?: boolean;
|
|
50
|
+
nextCursor?: unknown;
|
|
51
|
+
prevCursor?: unknown;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Chunk callback signature.
|
|
56
|
+
*/
|
|
57
|
+
export type ChunkCallback<T> = (rows: T[], chunkIndex: number) => Promise<boolean | void> | boolean | void;
|
|
58
|
+
/**
|
|
59
|
+
* Cursor pagination options.
|
|
60
|
+
*/
|
|
61
|
+
export type CursorPaginationOptions = {
|
|
62
|
+
cursor?: unknown;
|
|
63
|
+
direction?: "next" | "prev";
|
|
64
|
+
limit: number;
|
|
65
|
+
column?: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Standard pagination options.
|
|
69
|
+
*/
|
|
70
|
+
export type PaginationOptions = {
|
|
71
|
+
page?: number;
|
|
72
|
+
limit?: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Supported comparison operators.
|
|
76
|
+
*/
|
|
77
|
+
export type WhereOperator = "=" | "!=" | ">" | ">=" | "<" | "<=" | "in" | "notIn" | "between" | "notBetween" | "like" | "notLike" | "startsWith" | "notStartsWith" | "endsWith" | "notEndsWith" | "exists" | string;
|
|
78
|
+
/**
|
|
79
|
+
* Object-based predicate definition.
|
|
80
|
+
*/
|
|
81
|
+
import type { GlobalScopeDefinition, LocalScopeCallback } from "../model/model";
|
|
82
|
+
export type WhereObject = Record<string, unknown>;
|
|
83
|
+
/**
|
|
84
|
+
* Callback-based predicate definition.
|
|
85
|
+
*/
|
|
86
|
+
export type WhereCallback<T> = (builder: QueryBuilderContract<T>) => unknown;
|
|
87
|
+
/**
|
|
88
|
+
* Group-by payload supporting strings, arrays, or driver specific objects.
|
|
89
|
+
*/
|
|
90
|
+
export type GroupByInput = string | string[] | Record<string, unknown> | Array<Record<string, unknown>>;
|
|
91
|
+
/**
|
|
92
|
+
* Having clause payload.
|
|
93
|
+
*/
|
|
94
|
+
export type HavingInput = Record<string, unknown> | [field: string, value: unknown] | [field: string, operator: WhereOperator, value: unknown];
|
|
95
|
+
/**
|
|
96
|
+
* Raw expression payload for projection/order/group extensions.
|
|
97
|
+
*/
|
|
98
|
+
export type RawExpression = string | Record<string, unknown> | unknown;
|
|
99
|
+
/**
|
|
100
|
+
* Contract that all query builders must implement for building queries in a
|
|
101
|
+
* database-agnostic way. This interface provides a fluent, chainable API
|
|
102
|
+
* for constructing complex database queries.
|
|
103
|
+
*
|
|
104
|
+
* @template T - The type of records returned by the query
|
|
105
|
+
*/
|
|
106
|
+
export interface QueryBuilderContract<T = unknown> {
|
|
107
|
+
/**
|
|
108
|
+
* Table name
|
|
109
|
+
*/
|
|
110
|
+
table: string;
|
|
111
|
+
/**
|
|
112
|
+
* Hydrate records after fetching is done successfully
|
|
113
|
+
* Add hydrate callback function
|
|
114
|
+
*/
|
|
115
|
+
hydrate(callback: (data: any, index: number) => any): this;
|
|
116
|
+
/**
|
|
117
|
+
* Register a callback to be invoked before query execution.
|
|
118
|
+
* Allows modification of the query before it runs.
|
|
119
|
+
* @returns Unsubscribe function to remove the callback
|
|
120
|
+
*/
|
|
121
|
+
onFetching(callback: (query: this) => void | Promise<void>): () => void;
|
|
122
|
+
/**
|
|
123
|
+
* Register a callback to be invoked after records are fetched but before hydration.
|
|
124
|
+
* Receives raw records from the database.
|
|
125
|
+
* @returns Unsubscribe function to remove the callback
|
|
126
|
+
*/
|
|
127
|
+
onHydrating(callback: (records: any[], context: any) => void | Promise<void>): () => void;
|
|
128
|
+
/**
|
|
129
|
+
* Register a callback to be invoked after records are fetched and hydrated.
|
|
130
|
+
* Receives hydrated model instances.
|
|
131
|
+
* @returns Unsubscribe function to remove the callback
|
|
132
|
+
*/
|
|
133
|
+
onFetched(callback: (records: any[], context: any) => void | Promise<void>): () => void;
|
|
134
|
+
/**
|
|
135
|
+
* Pending global scopes to be applied before query execution.
|
|
136
|
+
* Passed from Model.query() and applied in execute().
|
|
137
|
+
*/
|
|
138
|
+
pendingGlobalScopes?: Map<string, GlobalScopeDefinition>;
|
|
139
|
+
/**
|
|
140
|
+
* Available local scopes that can be manually applied.
|
|
141
|
+
* Passed from Model.query() for opt-in usage.
|
|
142
|
+
*/
|
|
143
|
+
availableLocalScopes?: Map<string, LocalScopeCallback>;
|
|
144
|
+
/**
|
|
145
|
+
* Set of global scope names that have been disabled.
|
|
146
|
+
*/
|
|
147
|
+
disabledGlobalScopes?: Set<string>;
|
|
148
|
+
/**
|
|
149
|
+
* Flag indicating whether scopes have been applied.
|
|
150
|
+
*/
|
|
151
|
+
scopesApplied?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Disable one or more global scopes for this query.
|
|
154
|
+
*
|
|
155
|
+
* @param scopeNames - Names of scopes to disable
|
|
156
|
+
* @returns Query builder for chaining
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* // Disable tenant scope for admin queries
|
|
161
|
+
* await User.query().withoutGlobalScope('tenant').get();
|
|
162
|
+
*
|
|
163
|
+
* // Disable multiple scopes
|
|
164
|
+
* await User.query().withoutGlobalScope('tenant', 'softDelete').get();
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
withoutGlobalScope(...scopeNames: string[]): this;
|
|
168
|
+
/**
|
|
169
|
+
* Disable all global scopes for this query.
|
|
170
|
+
*
|
|
171
|
+
* @returns Query builder for chaining
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* // Get all users including soft-deleted and from all tenants
|
|
176
|
+
* await User.query().withoutGlobalScopes().get();
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
withoutGlobalScopes(): this;
|
|
180
|
+
/**
|
|
181
|
+
* Apply a local scope to this query.
|
|
182
|
+
*
|
|
183
|
+
* @param scopeName - Name of the scope to apply
|
|
184
|
+
* @returns Query builder for chaining
|
|
185
|
+
* @throws Error if scope not found
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* // Apply 'active' scope
|
|
190
|
+
* await User.query().scope('active').get();
|
|
191
|
+
*
|
|
192
|
+
* // Chain multiple scopes
|
|
193
|
+
* await User.query().scope('active').scope('admins').get();
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
scope(scopeName: string): this;
|
|
197
|
+
/**
|
|
198
|
+
* Add a where clause to the query.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* // Simple equality
|
|
202
|
+
* query.where('age', 18)
|
|
203
|
+
*
|
|
204
|
+
* // With operator
|
|
205
|
+
* query.where('age', '>', 18)
|
|
206
|
+
*
|
|
207
|
+
* // Object-based
|
|
208
|
+
* query.where({ age: 18, isActive: true })
|
|
209
|
+
*
|
|
210
|
+
* // Callback-based
|
|
211
|
+
* query.where(q => q.where('age', '>', 18).orWhere('role', 'admin'))
|
|
212
|
+
*/
|
|
213
|
+
where(field: string, value: unknown): this;
|
|
214
|
+
where(field: string, operator: WhereOperator, value: unknown): this;
|
|
215
|
+
where(conditions: WhereObject): this;
|
|
216
|
+
where(callback: WhereCallback<T>): this;
|
|
217
|
+
/**
|
|
218
|
+
* Add a raw where clause expressed in the native query language.
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* query.whereRaw({ $expr: { $gt: ["$stock", "$reserved"] } })
|
|
222
|
+
* query.whereRaw("this.age > ?", [30])
|
|
223
|
+
*/
|
|
224
|
+
whereRaw(expression: RawExpression, bindings?: unknown[]): this;
|
|
225
|
+
/**
|
|
226
|
+
* Add a raw OR where clause expressed in the native query language.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* query.orWhereRaw({ $where: "this.isAdmin === true" })
|
|
230
|
+
*/
|
|
231
|
+
orWhereRaw(expression: RawExpression, bindings?: unknown[]): this;
|
|
232
|
+
/**
|
|
233
|
+
* Compare two columns/fields directly.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* query.whereColumn('stock', '>', 'reserved')
|
|
237
|
+
*/
|
|
238
|
+
whereColumn(first: string, operator: WhereOperator, second: string): this;
|
|
239
|
+
/**
|
|
240
|
+
* Compare two columns/fields directly using OR logic.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* query.orWhereColumn('startDate', '<', 'endDate')
|
|
244
|
+
*/
|
|
245
|
+
orWhereColumn(first: string, operator: WhereOperator, second: string): this;
|
|
246
|
+
/**
|
|
247
|
+
* Compare multiple column pairs at once.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* query.whereColumns([
|
|
251
|
+
* ['price', '>', 'discountPrice'],
|
|
252
|
+
* ['stock', '>=', 'reserved'],
|
|
253
|
+
* ])
|
|
254
|
+
*/
|
|
255
|
+
whereColumns(comparisons: Array<[left: string, operator: WhereOperator, right: string]>): this;
|
|
256
|
+
/**
|
|
257
|
+
* Ensure a value falls between two other column values.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* query.whereBetweenColumns('age', 'minAge', 'maxAge')
|
|
261
|
+
*/
|
|
262
|
+
whereBetweenColumns(field: string, lowerColumn: string, upperColumn: string): this;
|
|
263
|
+
/**
|
|
264
|
+
* Constrain a field to a specific date (time portion ignored).
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* query.whereDate('createdAt', '2024-05-01')
|
|
268
|
+
*/
|
|
269
|
+
whereDate(field: string, value: Date | string): this;
|
|
270
|
+
/**
|
|
271
|
+
* Require a field to match a given date exactly.
|
|
272
|
+
*/
|
|
273
|
+
whereDateEquals(field: string, value: Date | string): this;
|
|
274
|
+
/**
|
|
275
|
+
* Require a field to be before the given date.
|
|
276
|
+
*/
|
|
277
|
+
whereDateBefore(field: string, value: Date | string): this;
|
|
278
|
+
/**
|
|
279
|
+
* Require a field to be after the given date.
|
|
280
|
+
*/
|
|
281
|
+
whereDateAfter(field: string, value: Date | string): this;
|
|
282
|
+
/**
|
|
283
|
+
* Constrain a field to match a specific time.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* query.whereTime('opensAt', '08:00')
|
|
287
|
+
*/
|
|
288
|
+
whereTime(field: string, value: string): this;
|
|
289
|
+
/**
|
|
290
|
+
* Constrain the day-of-month extracted from a date field.
|
|
291
|
+
*/
|
|
292
|
+
whereDay(field: string, value: number): this;
|
|
293
|
+
/**
|
|
294
|
+
* Constrain the month extracted from a date field.
|
|
295
|
+
*/
|
|
296
|
+
whereMonth(field: string, value: number): this;
|
|
297
|
+
/**
|
|
298
|
+
* Constrain the year extracted from a date field.
|
|
299
|
+
*/
|
|
300
|
+
whereYear(field: string, value: number): this;
|
|
301
|
+
/**
|
|
302
|
+
* Ensure a JSON/array path contains the given value.
|
|
303
|
+
*/
|
|
304
|
+
whereJsonContains(path: string, value: unknown): this;
|
|
305
|
+
/**
|
|
306
|
+
* Ensure a JSON/array path does not contain the given value.
|
|
307
|
+
*/
|
|
308
|
+
whereJsonDoesntContain(path: string, value: unknown): this;
|
|
309
|
+
/**
|
|
310
|
+
* Ensure a JSON/array path exists.
|
|
311
|
+
*/
|
|
312
|
+
whereJsonContainsKey(path: string): this;
|
|
313
|
+
/**
|
|
314
|
+
* Constrain the length of a JSON/array path.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* query.whereJsonLength('tags', '>', 3)
|
|
318
|
+
*/
|
|
319
|
+
whereJsonLength(path: string, operator: WhereOperator, value: number): this;
|
|
320
|
+
/**
|
|
321
|
+
* Ensure a JSON path resolves to an array.
|
|
322
|
+
*/
|
|
323
|
+
whereJsonIsArray(path: string): this;
|
|
324
|
+
/**
|
|
325
|
+
* Ensure a JSON path resolves to an object.
|
|
326
|
+
*/
|
|
327
|
+
whereJsonIsObject(path: string): this;
|
|
328
|
+
/**
|
|
329
|
+
* Constrain the length of an array field.
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* query.whereArrayLength('roles', '>=', 2)
|
|
333
|
+
*/
|
|
334
|
+
whereArrayLength(field: string, operator: WhereOperator, value: number): this;
|
|
335
|
+
/**
|
|
336
|
+
* Shortcut for filtering by the primary key.
|
|
337
|
+
*/
|
|
338
|
+
whereId(value: string | number): this;
|
|
339
|
+
/**
|
|
340
|
+
* Shortcut for filtering by multiple primary keys.
|
|
341
|
+
*/
|
|
342
|
+
whereIds(values: Array<string | number>): this;
|
|
343
|
+
/**
|
|
344
|
+
* Shortcut for UUID-based identifiers.
|
|
345
|
+
*/
|
|
346
|
+
whereUuid(value: string): this;
|
|
347
|
+
/**
|
|
348
|
+
* Shortcut for ULID-based identifiers.
|
|
349
|
+
*/
|
|
350
|
+
whereUlid(value: string): this;
|
|
351
|
+
/**
|
|
352
|
+
* Perform a full-text search across the specified fields.
|
|
353
|
+
*/
|
|
354
|
+
whereFullText(fields: string | string[], query: string): this;
|
|
355
|
+
/**
|
|
356
|
+
* Apply a full-text OR clause.
|
|
357
|
+
*/
|
|
358
|
+
orWhereFullText(fields: string | string[], query: string): this;
|
|
359
|
+
/**
|
|
360
|
+
* Convenience alias for simple text searches.
|
|
361
|
+
*/
|
|
362
|
+
whereSearch(field: string, query: string): this;
|
|
363
|
+
/**
|
|
364
|
+
* Negate a nested callback block.
|
|
365
|
+
*/
|
|
366
|
+
whereNot(callback: WhereCallback<T>): this;
|
|
367
|
+
/**
|
|
368
|
+
* Negate a nested callback block with OR logic.
|
|
369
|
+
*/
|
|
370
|
+
orWhereNot(callback: WhereCallback<T>): this;
|
|
371
|
+
/**
|
|
372
|
+
* Apply a nested existence check.
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* query.whereExists(q => q.where('status', 'active'))
|
|
376
|
+
* query.whereExists('optionalField')
|
|
377
|
+
*/
|
|
378
|
+
whereExists(callback: WhereCallback<T>): this;
|
|
379
|
+
/**
|
|
380
|
+
* Apply a nested non-existence check.
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* query.whereNotExists(q => q.where('status', 'inactive'))
|
|
384
|
+
* query.whereNotExists('deletedAt')
|
|
385
|
+
*/
|
|
386
|
+
whereNotExists(callback: WhereCallback<T>): this;
|
|
387
|
+
/**
|
|
388
|
+
* Add an OR where clause to the query.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* query.where('role', 'admin').orWhere('role', 'moderator')
|
|
392
|
+
*/
|
|
393
|
+
orWhere(field: string, value: unknown): this;
|
|
394
|
+
orWhere(field: string, operator: WhereOperator, value: unknown): this;
|
|
395
|
+
orWhere(conditions: WhereObject): this;
|
|
396
|
+
orWhere(callback: WhereCallback<T>): this;
|
|
397
|
+
/**
|
|
398
|
+
* Add a where IN clause to the query.
|
|
399
|
+
*
|
|
400
|
+
* @example
|
|
401
|
+
* query.whereIn('status', ['active', 'pending'])
|
|
402
|
+
*/
|
|
403
|
+
whereIn(field: string, values: unknown[]): this;
|
|
404
|
+
/**
|
|
405
|
+
* Add a where NOT IN clause to the query.
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* query.whereNotIn('status', ['deleted', 'archived'])
|
|
409
|
+
*/
|
|
410
|
+
whereNotIn(field: string, values: unknown[]): this;
|
|
411
|
+
/**
|
|
412
|
+
* Constrain the field to be NULL.
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* query.whereNull('deletedAt')
|
|
416
|
+
*/
|
|
417
|
+
whereNull(field: string): this;
|
|
418
|
+
/**
|
|
419
|
+
* Constrain the field to be NOT NULL.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* query.whereNotNull('email')
|
|
423
|
+
*/
|
|
424
|
+
whereNotNull(field: string): this;
|
|
425
|
+
/**
|
|
426
|
+
* Constrain the field to be between the given range (inclusive).
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* query.whereBetween('age', [18, 65])
|
|
430
|
+
*/
|
|
431
|
+
whereBetween(field: string, range: [unknown, unknown]): this;
|
|
432
|
+
/**
|
|
433
|
+
* Constrain the field to be outside the given range.
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* query.whereNotBetween('age', [18, 65])
|
|
437
|
+
*/
|
|
438
|
+
whereNotBetween(field: string, range: [unknown, unknown]): this;
|
|
439
|
+
/**
|
|
440
|
+
* Apply pattern matching (case-insensitive) for the given field.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* query.whereLike('name', '%john%')
|
|
444
|
+
*/
|
|
445
|
+
whereLike(field: string, pattern: RegExp | string): this;
|
|
446
|
+
/**
|
|
447
|
+
* Apply pattern exclusion (case-insensitive) for the given field.
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* query.whereNotLike('email', '%@spam.com')
|
|
451
|
+
*/
|
|
452
|
+
whereNotLike(field: string, pattern: string): this;
|
|
453
|
+
/**
|
|
454
|
+
* Constrain the field to start with the given value.
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* query.whereStartsWith('name', 'John')
|
|
458
|
+
*/
|
|
459
|
+
whereStartsWith(field: string, value: string | number): this;
|
|
460
|
+
/**
|
|
461
|
+
* Constrain the field to not start with the given value.
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* query.whereNotStartsWith('name', 'Admin')
|
|
465
|
+
*/
|
|
466
|
+
whereNotStartsWith(field: string, value: string | number): this;
|
|
467
|
+
/**
|
|
468
|
+
* Constrain the field to end with the given value.
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* query.whereEndsWith('email', '@example.com')
|
|
472
|
+
*/
|
|
473
|
+
whereEndsWith(field: string, value: string | number): this;
|
|
474
|
+
/**
|
|
475
|
+
* Constrain the field to not end with the given value.
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* query.whereNotEndsWith('email', '@spam.com')
|
|
479
|
+
*/
|
|
480
|
+
whereNotEndsWith(field: string, value: string | number): this;
|
|
481
|
+
/**
|
|
482
|
+
* Constrain the date field to be between the given range.
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* query.whereDateBetween('createdAt', [startDate, endDate])
|
|
486
|
+
*/
|
|
487
|
+
whereDateBetween(field: string, range: [Date, Date]): this;
|
|
488
|
+
/**
|
|
489
|
+
* Constrain the date field to not be between the given range.
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* query.whereDateNotBetween('createdAt', [startDate, endDate])
|
|
493
|
+
*/
|
|
494
|
+
whereDateNotBetween(field: string, range: [Date, Date]): this;
|
|
495
|
+
/**
|
|
496
|
+
* Check that a field exists (MongoDB-specific).
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* query.whereExists('optionalField')
|
|
500
|
+
*/
|
|
501
|
+
whereExists(field: string): this;
|
|
502
|
+
/**
|
|
503
|
+
* Check that a field does not exist (MongoDB-specific).
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* query.whereNotExists('optionalField')
|
|
507
|
+
*/
|
|
508
|
+
whereNotExists(field: string): this;
|
|
509
|
+
/**
|
|
510
|
+
* Constrain an array/collection field by size.
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* // Exact size
|
|
514
|
+
* query.whereSize('tags', 3)
|
|
515
|
+
*
|
|
516
|
+
* // With operator
|
|
517
|
+
* query.whereSize('tags', '>', 0)
|
|
518
|
+
*/
|
|
519
|
+
whereSize(field: string, size: number): this;
|
|
520
|
+
whereSize(field: string, operator: ">" | ">=" | "=" | "<" | "<=", size: number): this;
|
|
521
|
+
/**
|
|
522
|
+
* Perform a full-text search (driver-specific implementation).
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* query.textSearch('javascript tutorial', { language: 'en' })
|
|
526
|
+
*/
|
|
527
|
+
textSearch(query: string, filters?: WhereObject): this;
|
|
528
|
+
/**
|
|
529
|
+
* Constrain an array field to contain the given value.
|
|
530
|
+
* Optionally match by a specific key within array of objects.
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* // Simple array
|
|
534
|
+
* query.whereArrayContains('tags', 'javascript')
|
|
535
|
+
*
|
|
536
|
+
* // Array of objects
|
|
537
|
+
* query.whereArrayContains('items', 'laptop', 'name')
|
|
538
|
+
*/
|
|
539
|
+
whereArrayContains(field: string, value: unknown, key?: string): this;
|
|
540
|
+
/**
|
|
541
|
+
* Constrain an array field to not contain the given value.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* query.whereArrayNotContains('tags', 'deprecated')
|
|
545
|
+
*/
|
|
546
|
+
whereArrayNotContains(field: string, value: unknown, key?: string): this;
|
|
547
|
+
/**
|
|
548
|
+
* Constrain an array field to contain the value OR be empty.
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* query.whereArrayHasOrEmpty('permissions', 'admin')
|
|
552
|
+
*/
|
|
553
|
+
whereArrayHasOrEmpty(field: string, value: unknown, key?: string): this;
|
|
554
|
+
/**
|
|
555
|
+
* Constrain an array field to not contain the value OR be empty.
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* query.whereArrayNotHaveOrEmpty('blockedUsers', userId)
|
|
559
|
+
*/
|
|
560
|
+
whereArrayNotHaveOrEmpty(field: string, value: unknown, key?: string): this;
|
|
561
|
+
/**
|
|
562
|
+
* Specify the columns/fields to be selected.
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* query.select(['name', 'email', 'age'])
|
|
566
|
+
*/
|
|
567
|
+
select(fields: string[]): this;
|
|
568
|
+
select(fields: Record<string, 0 | 1 | boolean>): this;
|
|
569
|
+
select(...fields: Array<string | string[]>): this;
|
|
570
|
+
select(...args: Array<string | string[]>): this;
|
|
571
|
+
/**
|
|
572
|
+
* Select a field with an alias.
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* query.selectAs('name', 'fullName')
|
|
576
|
+
*/
|
|
577
|
+
selectAs(field: string, alias: string): this;
|
|
578
|
+
/**
|
|
579
|
+
* Add a raw selection/projection expression.
|
|
580
|
+
*
|
|
581
|
+
* @example
|
|
582
|
+
* query.selectRaw({ total: { $sum: "$items.price" } })
|
|
583
|
+
*/
|
|
584
|
+
selectRaw(expression: RawExpression, bindings?: unknown[]): this;
|
|
585
|
+
/**
|
|
586
|
+
* Add multiple raw selections at once.
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* query.selectRawMany([
|
|
590
|
+
* { alias: "firstName", expression: "$profile.name.first" },
|
|
591
|
+
* { alias: "isAdult", expression: { $gte: ["$age", 18] } },
|
|
592
|
+
* ])
|
|
593
|
+
*/
|
|
594
|
+
selectRawMany(definitions: Array<{
|
|
595
|
+
alias: string;
|
|
596
|
+
expression: RawExpression;
|
|
597
|
+
bindings?: unknown[];
|
|
598
|
+
}>): this;
|
|
599
|
+
/**
|
|
600
|
+
* Inject a sub-select expression under the given alias.
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* query.selectSub({ $sum: "$items.price" }, "itemsTotal")
|
|
604
|
+
*/
|
|
605
|
+
selectSub(expression: RawExpression, alias: string): this;
|
|
606
|
+
/**
|
|
607
|
+
* Add a sub-select expression without clearing previous selects.
|
|
608
|
+
*/
|
|
609
|
+
addSelectSub(expression: RawExpression, alias: string): this;
|
|
610
|
+
/**
|
|
611
|
+
* Add a simple aggregate expression to the projection.
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* query.selectAggregate("items.price", "sum", "itemsTotal")
|
|
615
|
+
*/
|
|
616
|
+
selectAggregate(field: string, aggregate: "sum" | "avg" | "min" | "max" | "count" | "first" | "last", alias: string): this;
|
|
617
|
+
/**
|
|
618
|
+
* Project whether the given field exists.
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* query.selectExists("deletedAt", "isDeleted")
|
|
622
|
+
*/
|
|
623
|
+
selectExists(field: string, alias: string): this;
|
|
624
|
+
/**
|
|
625
|
+
* Project the number of items in an array field.
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* query.selectCount("permissions", "permissionsCount")
|
|
629
|
+
*/
|
|
630
|
+
selectCount(field: string, alias: string): this;
|
|
631
|
+
/**
|
|
632
|
+
* Build CASE / switch like conditions in the projection.
|
|
633
|
+
*
|
|
634
|
+
* @example
|
|
635
|
+
* query.selectCase(
|
|
636
|
+
* [
|
|
637
|
+
* { when: { $eq: ["$status", "active"] }, then: "Active" },
|
|
638
|
+
* { when: { $eq: ["$status", "pending"] }, then: "Pending" },
|
|
639
|
+
* ],
|
|
640
|
+
* "Unknown",
|
|
641
|
+
* "statusLabel",
|
|
642
|
+
* )
|
|
643
|
+
*/
|
|
644
|
+
selectCase(cases: Array<{
|
|
645
|
+
when: RawExpression;
|
|
646
|
+
then: RawExpression | unknown;
|
|
647
|
+
}>, otherwise: RawExpression | unknown, alias: string): this;
|
|
648
|
+
/**
|
|
649
|
+
* Convenience helper for single condition CASE statements.
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* query.selectWhen({ $gt: ["$age", 18] }, "Adult", "Minor", "ageLabel")
|
|
653
|
+
*/
|
|
654
|
+
selectWhen(condition: RawExpression, thenValue: RawExpression | unknown, elseValue: RawExpression | unknown, alias: string): this;
|
|
655
|
+
/**
|
|
656
|
+
* Allow direct access to the driver projection object for advanced cases.
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* query.selectDriverProjection(projection => {
|
|
660
|
+
* projection.score = { $meta: "textScore" };
|
|
661
|
+
* })
|
|
662
|
+
*/
|
|
663
|
+
selectDriverProjection(callback: (projection: Record<string, unknown>) => void): this;
|
|
664
|
+
/**
|
|
665
|
+
* Project a nested JSON path under a new alias.
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
* query.selectJson("settings->theme", "theme")
|
|
669
|
+
*/
|
|
670
|
+
selectJson(path: string, alias?: string): this;
|
|
671
|
+
/**
|
|
672
|
+
* Apply a raw expression to a JSON path.
|
|
673
|
+
*
|
|
674
|
+
* @example
|
|
675
|
+
* query.selectJsonRaw("stats->views", { $ifNull: ["$stats.views", 0] }, "views")
|
|
676
|
+
*/
|
|
677
|
+
selectJsonRaw(path: string, expression: RawExpression, alias: string): this;
|
|
678
|
+
/**
|
|
679
|
+
* Exclude a nested JSON path from the projection.
|
|
680
|
+
*/
|
|
681
|
+
deselectJson(path: string): this;
|
|
682
|
+
/**
|
|
683
|
+
* Compute concatenated string fields.
|
|
684
|
+
*
|
|
685
|
+
* @example
|
|
686
|
+
* query.selectConcat(["$firstName", " ", "$lastName"], "fullName")
|
|
687
|
+
*/
|
|
688
|
+
selectConcat(fields: Array<string | RawExpression>, alias: string): this;
|
|
689
|
+
/**
|
|
690
|
+
* Coalesce a list of values, returning the first non-null entry.
|
|
691
|
+
*
|
|
692
|
+
* @example
|
|
693
|
+
* query.selectCoalesce(["$nickname", "$name"], "displayName")
|
|
694
|
+
*/
|
|
695
|
+
selectCoalesce(fields: Array<string | RawExpression>, alias: string): this;
|
|
696
|
+
/**
|
|
697
|
+
* Attach window function output to the projection.
|
|
698
|
+
*
|
|
699
|
+
* @example
|
|
700
|
+
* query.selectWindow({
|
|
701
|
+
* partitionBy: "$category",
|
|
702
|
+
* sortBy: { createdAt: 1 },
|
|
703
|
+
* output: { rank: { $denseRank: {} } },
|
|
704
|
+
* })
|
|
705
|
+
*/
|
|
706
|
+
selectWindow(spec: RawExpression): this;
|
|
707
|
+
/**
|
|
708
|
+
* Exclude the given fields from the projection.
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* query.deselect(['password', 'token'])
|
|
712
|
+
*/
|
|
713
|
+
deselect(fields: string[]): this;
|
|
714
|
+
/**
|
|
715
|
+
* Reset the projection to its default state.
|
|
716
|
+
*/
|
|
717
|
+
clearSelect(): this;
|
|
718
|
+
/**
|
|
719
|
+
* Alias for clearSelect() - keeps all fields.
|
|
720
|
+
*/
|
|
721
|
+
selectAll(): this;
|
|
722
|
+
/**
|
|
723
|
+
* Restore the default projection (all columns).
|
|
724
|
+
*/
|
|
725
|
+
selectDefault(): this;
|
|
726
|
+
/**
|
|
727
|
+
* Mark the query as distinct values for the given fields.
|
|
728
|
+
*
|
|
729
|
+
* @example
|
|
730
|
+
* query.distinctValues('category')
|
|
731
|
+
* query.distinctValues(['category', 'status'])
|
|
732
|
+
*/
|
|
733
|
+
distinctValues(fields?: string | string[]): this;
|
|
734
|
+
/**
|
|
735
|
+
* Add additional select fields to the existing projection.
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* query.select(['name', 'email']).addSelect(['age'])
|
|
739
|
+
*/
|
|
740
|
+
addSelect(fields: string[]): this;
|
|
741
|
+
/**
|
|
742
|
+
* Order results by the specified field and direction.
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* query.orderBy('createdAt', 'desc')
|
|
746
|
+
* query.orderBy({ id: 'asc', age: 'desc' })
|
|
747
|
+
*/
|
|
748
|
+
orderBy(field: string, direction?: OrderDirection): this;
|
|
749
|
+
orderBy(fields: Record<string, OrderDirection>): this;
|
|
750
|
+
/**
|
|
751
|
+
* Order results descending by the specified field (shortcut).
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
754
|
+
* query.orderByDesc('createdAt')
|
|
755
|
+
*/
|
|
756
|
+
orderByDesc(field: string): this;
|
|
757
|
+
/**
|
|
758
|
+
* Order results using a raw expression.
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* query.orderByRaw('RANDOM()')
|
|
762
|
+
*/
|
|
763
|
+
orderByRaw(expression: RawExpression, bindings?: unknown[]): this;
|
|
764
|
+
/**
|
|
765
|
+
* Order results randomly.
|
|
766
|
+
*
|
|
767
|
+
* @example
|
|
768
|
+
* query.orderByRandom(100)
|
|
769
|
+
*/
|
|
770
|
+
orderByRandom(limit: number): this;
|
|
771
|
+
/**
|
|
772
|
+
* Order by the latest records using a timestamp column (descending).
|
|
773
|
+
* Defaults to 'createdAt'.
|
|
774
|
+
*
|
|
775
|
+
* @example
|
|
776
|
+
* query.latest() // orderBy('createdAt', 'desc')
|
|
777
|
+
* query.latest('updatedAt') // orderBy('updatedAt', 'desc')
|
|
778
|
+
*/
|
|
779
|
+
latest(column?: string): Promise<T[]>;
|
|
780
|
+
/**
|
|
781
|
+
* Order by the oldest records using a timestamp column (ascending).
|
|
782
|
+
* Defaults to 'createdAt'.
|
|
783
|
+
*
|
|
784
|
+
* @example
|
|
785
|
+
* query.oldest() // orderBy('createdAt', 'asc')
|
|
786
|
+
*/
|
|
787
|
+
oldest(column?: string): this;
|
|
788
|
+
/**
|
|
789
|
+
* Limit the number of results.
|
|
790
|
+
*
|
|
791
|
+
* @example
|
|
792
|
+
* query.limit(10)
|
|
793
|
+
*/
|
|
794
|
+
limit(value: number): this;
|
|
795
|
+
/**
|
|
796
|
+
* Skip the specified number of results (alias for offset).
|
|
797
|
+
*
|
|
798
|
+
* @example
|
|
799
|
+
* query.skip(20)
|
|
800
|
+
*/
|
|
801
|
+
skip(value: number): this;
|
|
802
|
+
/**
|
|
803
|
+
* Skip the specified number of results.
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* query.offset(20)
|
|
807
|
+
*/
|
|
808
|
+
offset(value: number): this;
|
|
809
|
+
/**
|
|
810
|
+
* Alias for limit() - take the first N results.
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* query.take(5)
|
|
814
|
+
*/
|
|
815
|
+
take(value: number): this;
|
|
816
|
+
/**
|
|
817
|
+
* Apply cursor pagination hints.
|
|
818
|
+
*
|
|
819
|
+
* @example
|
|
820
|
+
* query.cursor({ after: lastId })
|
|
821
|
+
*/
|
|
822
|
+
cursor(after?: unknown, before?: unknown): this;
|
|
823
|
+
/**
|
|
824
|
+
* Group results by the given fields.
|
|
825
|
+
*
|
|
826
|
+
* @example
|
|
827
|
+
* query.groupBy('category')
|
|
828
|
+
* query.groupBy(['category', 'status'])
|
|
829
|
+
*/
|
|
830
|
+
groupBy(fields: GroupByInput): this;
|
|
831
|
+
/**
|
|
832
|
+
* Group results by the given fields with aggregate operations.
|
|
833
|
+
*
|
|
834
|
+
* This method allows you to group documents and compute aggregates in a single
|
|
835
|
+
* operation. It accepts abstract aggregate expressions (from $agg helpers) or
|
|
836
|
+
* raw database-specific expressions.
|
|
837
|
+
*
|
|
838
|
+
* @param fields - Field(s) to group by
|
|
839
|
+
* @param aggregates - Aggregate operations to perform
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* ```typescript
|
|
843
|
+
* import { $agg } from '@warlock.js/cascade';
|
|
844
|
+
*
|
|
845
|
+
* // Using abstract expressions (works for all databases)
|
|
846
|
+
* query.groupBy("type", {
|
|
847
|
+
* count: $agg.count(),
|
|
848
|
+
* total: $agg.sum("duration"),
|
|
849
|
+
* avg: $agg.avg("rating")
|
|
850
|
+
* });
|
|
851
|
+
*
|
|
852
|
+
* // Using raw expressions (database-specific)
|
|
853
|
+
* // MongoDB:
|
|
854
|
+
* query.groupBy("type", {
|
|
855
|
+
* count: { $sum: 1 },
|
|
856
|
+
* total: { $sum: "$duration" }
|
|
857
|
+
* });
|
|
858
|
+
*
|
|
859
|
+
* // SQL (future):
|
|
860
|
+
* query.groupBy("type", {
|
|
861
|
+
* count: "COUNT(*)",
|
|
862
|
+
* total: "SUM(duration)"
|
|
863
|
+
* });
|
|
864
|
+
* ```
|
|
865
|
+
*/
|
|
866
|
+
groupBy(fields: GroupByInput, aggregates: Record<string, RawExpression>): this;
|
|
867
|
+
/**
|
|
868
|
+
* Apply raw grouping expressions.
|
|
869
|
+
*
|
|
870
|
+
* @example
|
|
871
|
+
* query.groupByRaw('DATE(createdAt)')
|
|
872
|
+
*/
|
|
873
|
+
groupByRaw(expression: RawExpression, bindings?: unknown[]): this;
|
|
874
|
+
/**
|
|
875
|
+
* Apply having clause to aggregated results.
|
|
876
|
+
*
|
|
877
|
+
* @example
|
|
878
|
+
* query.groupBy('category').having('count', '>', 10)
|
|
879
|
+
*/
|
|
880
|
+
having(field: string, value: unknown): this;
|
|
881
|
+
having(field: string, operator: WhereOperator, value: unknown): this;
|
|
882
|
+
having(condition: HavingInput): this;
|
|
883
|
+
/**
|
|
884
|
+
* Apply raw having clause to aggregated results.
|
|
885
|
+
*
|
|
886
|
+
* @example
|
|
887
|
+
* query.havingRaw('COUNT(*) > ?', [10])
|
|
888
|
+
*/
|
|
889
|
+
havingRaw(expression: RawExpression, bindings?: unknown[]): this;
|
|
890
|
+
/**
|
|
891
|
+
* Join another table/collection using a structured payload.
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* query.join({
|
|
895
|
+
* table: 'posts',
|
|
896
|
+
* localField: 'userId',
|
|
897
|
+
* foreignField: 'authorId',
|
|
898
|
+
* type: 'left'
|
|
899
|
+
* })
|
|
900
|
+
*/
|
|
901
|
+
join(options: JoinOptions): this;
|
|
902
|
+
/**
|
|
903
|
+
* Add driver-specific raw modifications to the query.
|
|
904
|
+
*
|
|
905
|
+
* @example
|
|
906
|
+
* query.raw(nativeQuery => {
|
|
907
|
+
* // Modify native query object
|
|
908
|
+
* return nativeQuery;
|
|
909
|
+
* })
|
|
910
|
+
*/
|
|
911
|
+
raw(builder: (native: unknown) => unknown): this;
|
|
912
|
+
/**
|
|
913
|
+
* Extend the query builder with driver-specific extensions.
|
|
914
|
+
*
|
|
915
|
+
* @example
|
|
916
|
+
* query.extend('mongoAggregation', { $match: { ... } })
|
|
917
|
+
*/
|
|
918
|
+
extend<R>(extension: string, ...args: unknown[]): R;
|
|
919
|
+
/**
|
|
920
|
+
* Clone the current query builder instance.
|
|
921
|
+
*
|
|
922
|
+
* @example
|
|
923
|
+
* const baseQuery = User.query().where('isActive', true);
|
|
924
|
+
* const adminQuery = baseQuery.clone().where('role', 'admin');
|
|
925
|
+
*/
|
|
926
|
+
clone(): this;
|
|
927
|
+
/**
|
|
928
|
+
* Tap into the query builder for debugging or side effects without
|
|
929
|
+
* breaking the fluent chain.
|
|
930
|
+
*
|
|
931
|
+
* @example
|
|
932
|
+
* query.where('age', '>', 18).tap(q => console.log(q.parse())).get()
|
|
933
|
+
*/
|
|
934
|
+
tap(callback: (builder: this) => void): this;
|
|
935
|
+
/**
|
|
936
|
+
* Conditionally apply a callback to the query.
|
|
937
|
+
*
|
|
938
|
+
* @example
|
|
939
|
+
* query.when(searchTerm, (q, term) => q.whereLike('name', term))
|
|
940
|
+
*/
|
|
941
|
+
when<V>(condition: V | boolean, callback: (builder: this, value: V) => void, otherwise?: (builder: this) => void): this;
|
|
942
|
+
/**
|
|
943
|
+
* Execute the query and return all matching records.
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* const users = await User.query().where('isActive', true).get();
|
|
947
|
+
*/
|
|
948
|
+
get<Output = T>(): Promise<Output[]>;
|
|
949
|
+
/**
|
|
950
|
+
* Execute the query and return the first matching record.
|
|
951
|
+
*
|
|
952
|
+
* @example
|
|
953
|
+
* const user = await User.query().where('email', 'john@example.com').first();
|
|
954
|
+
*/
|
|
955
|
+
first<Output = T>(): Promise<Output | null>;
|
|
956
|
+
/**
|
|
957
|
+
* Execute the query and return the first matching record or throw an error.
|
|
958
|
+
*
|
|
959
|
+
* @throws {Error} If no record is found
|
|
960
|
+
* @example
|
|
961
|
+
* const user = await User.query().where('id', 123).firstOrFail();
|
|
962
|
+
*/
|
|
963
|
+
firstOrFail<Output = T>(): Promise<Output>;
|
|
964
|
+
/**
|
|
965
|
+
* Configure query to retrieve the last record.
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* const lastUser = await User.query().last().first();
|
|
969
|
+
*/
|
|
970
|
+
last<Output = T>(field?: string): Promise<Output | null>;
|
|
971
|
+
/**
|
|
972
|
+
* Count the records matching the query.
|
|
973
|
+
*
|
|
974
|
+
* @example
|
|
975
|
+
* const total = await User.query().where('isActive', true).count();
|
|
976
|
+
*/
|
|
977
|
+
count(): Promise<number>;
|
|
978
|
+
/**
|
|
979
|
+
* Aggregate sum for the given field.
|
|
980
|
+
*
|
|
981
|
+
* @example
|
|
982
|
+
* const total = await Order.query().sum('amount');
|
|
983
|
+
*/
|
|
984
|
+
sum(field: string): Promise<number>;
|
|
985
|
+
/**
|
|
986
|
+
* Aggregate average for the given field.
|
|
987
|
+
*
|
|
988
|
+
* @example
|
|
989
|
+
* const avgAge = await User.query().avg('age');
|
|
990
|
+
*/
|
|
991
|
+
avg(field: string): Promise<number>;
|
|
992
|
+
/**
|
|
993
|
+
* Aggregate minimum for the given field.
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* const minPrice = await Product.query().min('price');
|
|
997
|
+
*/
|
|
998
|
+
min(field: string): Promise<number>;
|
|
999
|
+
/**
|
|
1000
|
+
* Aggregate maximum for the given field.
|
|
1001
|
+
*
|
|
1002
|
+
* @example
|
|
1003
|
+
* const maxPrice = await Product.query().max('price');
|
|
1004
|
+
*/
|
|
1005
|
+
max(field: string): Promise<number>;
|
|
1006
|
+
/**
|
|
1007
|
+
* Retrieve distinct values for a field.
|
|
1008
|
+
* @param field - The field to get distinct values from
|
|
1009
|
+
* @returns an array of distinct values
|
|
1010
|
+
*
|
|
1011
|
+
* @example
|
|
1012
|
+
* const categories = await Product.query().distinct('category');
|
|
1013
|
+
*/
|
|
1014
|
+
distinct<T = unknown>(field: string): Promise<T[]>;
|
|
1015
|
+
/**
|
|
1016
|
+
* Retrieve a list of values for the given field.
|
|
1017
|
+
*
|
|
1018
|
+
* @example
|
|
1019
|
+
* const names = await User.query().pluck('name');
|
|
1020
|
+
*/
|
|
1021
|
+
pluck(field: string): Promise<unknown[]>;
|
|
1022
|
+
/**
|
|
1023
|
+
* Retrieve a single scalar value for the given field from the first record.
|
|
1024
|
+
*
|
|
1025
|
+
* @example
|
|
1026
|
+
* const email = await User.query().where('id', 123).value('email');
|
|
1027
|
+
*/
|
|
1028
|
+
value<T = unknown>(field: string): Promise<T | null>;
|
|
1029
|
+
/**
|
|
1030
|
+
* Determine if any record matches the current query.
|
|
1031
|
+
*
|
|
1032
|
+
* @example
|
|
1033
|
+
* const hasActiveUsers = await User.query().where('isActive', true).exists();
|
|
1034
|
+
*/
|
|
1035
|
+
exists(): Promise<boolean>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Determine if no records match the current query.
|
|
1038
|
+
*
|
|
1039
|
+
* @example
|
|
1040
|
+
* const noAdmins = await User.query().where('role', 'admin').doesntExist();
|
|
1041
|
+
*/
|
|
1042
|
+
notExists(): Promise<boolean>;
|
|
1043
|
+
/**
|
|
1044
|
+
* Count distinct values for the given field.
|
|
1045
|
+
*
|
|
1046
|
+
* @example
|
|
1047
|
+
* const uniqueCategories = await Product.query().countDistinct('category');
|
|
1048
|
+
*/
|
|
1049
|
+
countDistinct(field: string): Promise<number>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Increment a field's value by the given amount.
|
|
1052
|
+
*
|
|
1053
|
+
* @returns the new value
|
|
1054
|
+
* @example
|
|
1055
|
+
* await User.query().where('id', 123).increment('loginCount', 1);
|
|
1056
|
+
*/
|
|
1057
|
+
increment(field: string, amount?: number): Promise<number>;
|
|
1058
|
+
/**
|
|
1059
|
+
* Decrement a field's value by the given amount.
|
|
1060
|
+
*
|
|
1061
|
+
* @returns the new value
|
|
1062
|
+
* @example
|
|
1063
|
+
* await Product.query().where('id', 456).decrement('stock', 5);
|
|
1064
|
+
*/
|
|
1065
|
+
decrement(field: string, amount?: number): Promise<number>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Increment a field's value by the given amount for all matching documents.
|
|
1068
|
+
* @param field - The field to increment
|
|
1069
|
+
* @param amount - The amount to increment by (default: 1)
|
|
1070
|
+
* @returns the number of documents modified
|
|
1071
|
+
*/
|
|
1072
|
+
incrementMany(field: string, amount?: number): Promise<number>;
|
|
1073
|
+
/**
|
|
1074
|
+
* Decrement a field's value by the given amount for all matching documents.
|
|
1075
|
+
* @param field - The field to decrement
|
|
1076
|
+
* @param amount - The amount to decrement by (default: 1)
|
|
1077
|
+
* @returns the number of documents modified
|
|
1078
|
+
*/
|
|
1079
|
+
decrementMany(field: string, amount?: number): Promise<number>;
|
|
1080
|
+
/**
|
|
1081
|
+
* Iterate through results in chunks, executing the callback for each chunk.
|
|
1082
|
+
* Return false from the callback to stop iteration.
|
|
1083
|
+
*
|
|
1084
|
+
* @example
|
|
1085
|
+
* await User.query().chunk(100, async (users, index) => {
|
|
1086
|
+
* await processUsers(users);
|
|
1087
|
+
* // Return false to stop
|
|
1088
|
+
* });
|
|
1089
|
+
*/
|
|
1090
|
+
chunk(size: number, callback: ChunkCallback<T>): Promise<void>;
|
|
1091
|
+
/**
|
|
1092
|
+
* Paginate the results with standard page/limit pagination.
|
|
1093
|
+
*
|
|
1094
|
+
* @example
|
|
1095
|
+
* const result = await User.query().paginate({ page: 1, limit: 10 });
|
|
1096
|
+
* // { data: [...], total: 100, page: 1, limit: 10, pages: 10 }
|
|
1097
|
+
*/
|
|
1098
|
+
paginate(options: PaginationOptions): Promise<PaginationResult<T>>;
|
|
1099
|
+
/**
|
|
1100
|
+
* Paginate using cursor-based strategy for better performance.
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* const result = await User.query().cursorPaginate({ limit: 10, cursor: lastId });
|
|
1104
|
+
* // { data: [...], hasMore: true, nextCursor: '...' }
|
|
1105
|
+
*/
|
|
1106
|
+
cursorPaginate(options: CursorPaginationOptions): Promise<CursorPaginationResult<T>>;
|
|
1107
|
+
/**
|
|
1108
|
+
* Return the native query representation (SQL string, Mongo Pipeline, etc.).
|
|
1109
|
+
*
|
|
1110
|
+
* @example
|
|
1111
|
+
* const mongoFilter = query.parse();
|
|
1112
|
+
* console.log(mongoFilter); // { age: { $gt: 18 }, isActive: true }
|
|
1113
|
+
*/
|
|
1114
|
+
parse(): Promise<unknown> | unknown;
|
|
1115
|
+
/**
|
|
1116
|
+
* Returns a formatted string representation of the query pipeline | SQL string.
|
|
1117
|
+
* @returns A formatted string representation of the pipeline|SQL string
|
|
1118
|
+
*/
|
|
1119
|
+
pretty(): string;
|
|
1120
|
+
/**
|
|
1121
|
+
* Ask the underlying driver to explain the query execution plan.
|
|
1122
|
+
*
|
|
1123
|
+
* @example
|
|
1124
|
+
* const plan = await query.explain();
|
|
1125
|
+
*/
|
|
1126
|
+
explain(): Promise<unknown>;
|
|
1127
|
+
}
|
|
1128
|
+
//# sourceMappingURL=query-builder.contract.d.ts.map
|