postgrelize 0.0.0-stage → 1.1.0
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/CHANGELOG.md +289 -0
- package/LICENSE +21 -0
- package/README.md +131 -2
- package/dist/associations/alias-minifier.d.ts +43 -0
- package/dist/associations/association-accessors.d.ts +21 -0
- package/dist/associations/association-key-types.d.ts +44 -0
- package/dist/associations/association-keys.d.ts +98 -0
- package/dist/associations/association-lookup.d.ts +26 -0
- package/dist/associations/association-shape.d.ts +25 -0
- package/dist/associations/association.d.ts +95 -0
- package/dist/associations/belongs-to-many.d.ts +86 -0
- package/dist/associations/belongs-to.d.ts +45 -0
- package/dist/associations/has-many.d.ts +79 -0
- package/dist/associations/has-one.d.ts +44 -0
- package/dist/associations/include-assembler.d.ts +21 -0
- package/dist/associations/include-columns.d.ts +24 -0
- package/dist/associations/include-joins.d.ts +17 -0
- package/dist/associations/include-loader.d.ts +48 -0
- package/dist/associations/include-order.d.ts +22 -0
- package/dist/associations/include-query-builder.d.ts +54 -0
- package/dist/associations/include-resolver.d.ts +29 -0
- package/dist/associations/include-rows.d.ts +47 -0
- package/dist/associations/include-sub-query.d.ts +35 -0
- package/dist/associations/include.d.ts +112 -0
- package/dist/associations/junction-keys.d.ts +23 -0
- package/dist/associations/nested-creator.d.ts +44 -0
- package/dist/associations/nested-saver.d.ts +30 -0
- package/dist/associations/owner-keys.d.ts +34 -0
- package/dist/associations/separate-include-loader.d.ts +24 -0
- package/dist/associations/types.d.ts +139 -0
- package/dist/connection/after-connect-hook.d.ts +24 -0
- package/dist/connection/connect-hooks.d.ts +26 -0
- package/dist/connection/connection-config.d.ts +33 -0
- package/dist/connection/connection-manager.d.ts +65 -0
- package/dist/connection/connection-types.d.ts +21 -0
- package/dist/connection/copy-from-stdin.d.ts +52 -0
- package/dist/connection/copy-runner.d.ts +30 -0
- package/dist/connection/copy-to-stdout.d.ts +49 -0
- package/dist/connection/copy.d.ts +22 -0
- package/dist/connection/notifications.d.ts +28 -0
- package/dist/connection/options.d.ts +165 -0
- package/dist/connection/query-logger.d.ts +41 -0
- package/dist/connection/replica-router.d.ts +20 -0
- package/dist/connection/statement-cache.d.ts +36 -0
- package/dist/connection/statement-timeout.d.ts +22 -0
- package/dist/data-types/abstract-data-type.d.ts +58 -0
- package/dist/data-types/array-literal-parser.d.ts +17 -0
- package/dist/data-types/array-type.d.ts +18 -0
- package/dist/data-types/bit-type.d.ts +14 -0
- package/dist/data-types/blob-type.d.ts +12 -0
- package/dist/data-types/char-type.d.ts +12 -0
- package/dist/data-types/composite-fields.d.ts +26 -0
- package/dist/data-types/composite-type.d.ts +32 -0
- package/dist/data-types/data-types.d.ts +176 -0
- package/dist/data-types/date-type.d.ts +14 -0
- package/dist/data-types/decimal-type.d.ts +13 -0
- package/dist/data-types/default-value-generator.d.ts +15 -0
- package/dist/data-types/enum-type.d.ts +19 -0
- package/dist/data-types/ewkb-reader.d.ts +18 -0
- package/dist/data-types/ewkb-writer.d.ts +17 -0
- package/dist/data-types/float-type.d.ts +12 -0
- package/dist/data-types/geometric-text.d.ts +65 -0
- package/dist/data-types/geometric-type.d.ts +46 -0
- package/dist/data-types/hstore-type.d.ts +16 -0
- package/dist/data-types/integer-type.d.ts +24 -0
- package/dist/data-types/json-type.d.ts +16 -0
- package/dist/data-types/multirange-type.d.ts +19 -0
- package/dist/data-types/range-type.d.ts +28 -0
- package/dist/data-types/record-text.d.ts +29 -0
- package/dist/data-types/scalar-type.d.ts +13 -0
- package/dist/data-types/spatial-type.d.ts +20 -0
- package/dist/data-types/string-type.d.ts +12 -0
- package/dist/data-types/text-type.d.ts +12 -0
- package/dist/data-types/timestamp-type.d.ts +15 -0
- package/dist/data-types/virtual-type.d.ts +15 -0
- package/dist/data-types/wall-clock.d.ts +14 -0
- package/dist/ddl/column-ddl.d.ts +73 -0
- package/dist/ddl/constraint-ddl.d.ts +30 -0
- package/dist/ddl/ddl-generator.d.ts +181 -0
- package/dist/ddl/ddl-guards.d.ts +60 -0
- package/dist/ddl/ddl-types.d.ts +204 -0
- package/dist/ddl/enum-ddl.d.ts +42 -0
- package/dist/ddl/extension-ddl.d.ts +57 -0
- package/dist/ddl/function-ddl.d.ts +98 -0
- package/dist/ddl/index-ddl.d.ts +29 -0
- package/dist/ddl/index-element-ddl.d.ts +19 -0
- package/dist/ddl/partition-ddl.d.ts +88 -0
- package/dist/ddl/partition-types.d.ts +94 -0
- package/dist/ddl/policy-ddl.d.ts +137 -0
- package/dist/ddl/routine-guards.d.ts +63 -0
- package/dist/ddl/sequence-ddl.d.ts +103 -0
- package/dist/ddl/sql-literal.d.ts +61 -0
- package/dist/ddl/table-ddl.d.ts +35 -0
- package/dist/ddl/trigger-ddl.d.ts +81 -0
- package/dist/ddl/view-ddl.d.ts +122 -0
- package/dist/decorators/association-applier.d.ts +18 -0
- package/dist/decorators/association-decorators.d.ts +72 -0
- package/dist/decorators/column-decorators.d.ts +147 -0
- package/dist/decorators/decorator-factory.d.ts +45 -0
- package/dist/decorators/decorator-signature.d.ts +26 -0
- package/dist/decorators/decorator-types.d.ts +24 -0
- package/dist/decorators/foreign-key-decorator.d.ts +21 -0
- package/dist/decorators/hook-decorators.d.ts +393 -0
- package/dist/decorators/init-arguments.d.ts +29 -0
- package/dist/decorators/model-decorators.d.ts +18 -0
- package/dist/decorators/model-metadata.d.ts +70 -0
- package/dist/decorators/table-decorators.d.ts +43 -0
- package/dist/decorators/timestamp-decorators.d.ts +38 -0
- package/dist/errors/base-error.d.ts +40 -0
- package/dist/errors/connection-errors.d.ts +152 -0
- package/dist/errors/database-errors.d.ts +186 -0
- package/dist/errors/errors.d.ts +5 -0
- package/dist/errors/map-pg-error.d.ts +27 -0
- package/dist/errors/misc-errors.d.ts +232 -0
- package/dist/errors/validation-errors.d.ts +141 -0
- package/dist/exports-associations.d.ts +6 -0
- package/dist/exports-core.d.ts +95 -0
- package/dist/exports-decorators.d.ts +8 -0
- package/dist/exports-errors.d.ts +2 -0
- package/dist/exports-model.d.ts +21 -0
- package/dist/exports-schema.d.ts +19 -0
- package/dist/expressions/call-expressions.d.ts +54 -0
- package/dist/expressions/condition-expressions.d.ts +51 -0
- package/dist/expressions/expression.d.ts +52 -0
- package/dist/expressions/jsonpath-helpers.d.ts +37 -0
- package/dist/expressions/logic.d.ts +25 -0
- package/dist/expressions/methods.d.ts +188 -0
- package/dist/expressions/op.d.ts +182 -0
- package/dist/expressions/query-expressions.d.ts +110 -0
- package/dist/expressions/row-expressions.d.ts +35 -0
- package/dist/expressions/search-helpers.d.ts +138 -0
- package/dist/expressions/trigram-helpers.d.ts +40 -0
- package/dist/hooks/hooks.d.ts +125 -0
- package/dist/index.cjs +21864 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +21688 -0
- package/dist/index.js.map +1 -0
- package/dist/model/attribute-columns.d.ts +85 -0
- package/dist/model/attribute-normalizer.d.ts +42 -0
- package/dist/model/attribute-options.d.ts +121 -0
- package/dist/model/bulk-insert-builder.d.ts +24 -0
- package/dist/model/bulk-options.d.ts +173 -0
- package/dist/model/copy-options.d.ts +51 -0
- package/dist/model/cte-builder.d.ts +134 -0
- package/dist/model/definition-normalizer.d.ts +26 -0
- package/dist/model/delete-query-builder.d.ts +42 -0
- package/dist/model/find-options.d.ts +144 -0
- package/dist/model/find-query-builder.d.ts +38 -0
- package/dist/model/inflector.d.ts +28 -0
- package/dist/model/insert-query-builder.d.ts +41 -0
- package/dist/model/instance-destroyer.d.ts +44 -0
- package/dist/model/instance-lifecycle-services.d.ts +61 -0
- package/dist/model/instance-lifecycle.d.ts +128 -0
- package/dist/model/instance-saver.d.ts +25 -0
- package/dist/model/instance-state.d.ts +48 -0
- package/dist/model/instance-validation.d.ts +35 -0
- package/dist/model/instance-values.d.ts +88 -0
- package/dist/model/instance-writer.d.ts +59 -0
- package/dist/model/join-source-builder.d.ts +25 -0
- package/dist/model/lateral-keys-builder.d.ts +25 -0
- package/dist/model/merge-action-builder.d.ts +31 -0
- package/dist/model/merge-options.d.ts +72 -0
- package/dist/model/merge-query-builder.d.ts +29 -0
- package/dist/model/merge-source-builder.d.ts +22 -0
- package/dist/model/mixins/model-aggregates.d.ts +69 -0
- package/dist/model/mixins/model-associations.d.ts +113 -0
- package/dist/model/mixins/model-constructor.d.ts +7 -0
- package/dist/model/mixins/model-finders.d.ts +140 -0
- package/dist/model/mixins/model-hooks.d.ts +142 -0
- package/dist/model/mixins/model-postgres.d.ts +198 -0
- package/dist/model/mixins/model-schema-binding.d.ts +36 -0
- package/dist/model/mixins/model-schema.d.ts +100 -0
- package/dist/model/mixins/model-scopes.d.ts +57 -0
- package/dist/model/mixins/model-writers.d.ts +175 -0
- package/dist/model/mixins/named-hooks.d.ts +28 -0
- package/dist/model/model-accessors.d.ts +22 -0
- package/dist/model/model-base.d.ts +83 -0
- package/dist/model/model-definition.d.ts +130 -0
- package/dist/model/model-instance-persistence.d.ts +132 -0
- package/dist/model/model-instance-values.d.ts +197 -0
- package/dist/model/model-operations.d.ts +22 -0
- package/dist/model/model-registry.d.ts +152 -0
- package/dist/model/model-services.d.ts +46 -0
- package/dist/model/model-state.d.ts +68 -0
- package/dist/model/model-values.d.ts +86 -0
- package/dist/model/model.d.ts +629 -0
- package/dist/model/on-conflict-builder.d.ts +111 -0
- package/dist/model/operations/bulk-create-operation.d.ts +40 -0
- package/dist/model/operations/copy-from-source.d.ts +51 -0
- package/dist/model/operations/copy-operation.d.ts +54 -0
- package/dist/model/operations/count-operation.d.ts +52 -0
- package/dist/model/operations/create-operation.d.ts +31 -0
- package/dist/model/operations/destroy-operation.d.ts +65 -0
- package/dist/model/operations/find-cursor.d.ts +23 -0
- package/dist/model/operations/find-lookups.d.ts +99 -0
- package/dist/model/operations/find-operation.d.ts +47 -0
- package/dist/model/operations/increment-operation.d.ts +40 -0
- package/dist/model/operations/insert-operation.d.ts +71 -0
- package/dist/model/operations/merge-operation.d.ts +56 -0
- package/dist/model/operations/model-operation.d.ts +33 -0
- package/dist/model/operations/update-operation.d.ts +45 -0
- package/dist/model/operations/upsert-operation.d.ts +39 -0
- package/dist/model/options.d.ts +103 -0
- package/dist/model/returning-old.d.ts +52 -0
- package/dist/model/row-mapper.d.ts +78 -0
- package/dist/model/row-plan.d.ts +31 -0
- package/dist/model/runtime.d.ts +56 -0
- package/dist/model/scope-registry.d.ts +81 -0
- package/dist/model/select-aggregates.d.ts +37 -0
- package/dist/model/select-lock.d.ts +13 -0
- package/dist/model/select-options.d.ts +92 -0
- package/dist/model/select-query-builder.d.ts +73 -0
- package/dist/model/select-targets.d.ts +77 -0
- package/dist/model/source-option-builder.d.ts +23 -0
- package/dist/model/source-options.d.ts +108 -0
- package/dist/model/statement-builder.d.ts +77 -0
- package/dist/model/statement-services.d.ts +2 -0
- package/dist/model/sync-hooks.d.ts +18 -0
- package/dist/model/table-sample-builder.d.ts +13 -0
- package/dist/model/types.d.ts +85 -0
- package/dist/model/unnest-insert-builder.d.ts +24 -0
- package/dist/model/update-query-builder.d.ts +39 -0
- package/dist/model/v6-conflict-builder.d.ts +37 -0
- package/dist/model/value-cloner.d.ts +17 -0
- package/dist/model/values-writer.d.ts +12 -0
- package/dist/model/where-options.d.ts +164 -0
- package/dist/model/write-options.d.ts +160 -0
- package/dist/model/written-rows.d.ts +56 -0
- package/dist/package-version.d.ts +8 -0
- package/dist/query/query-result-shaper.d.ts +93 -0
- package/dist/query/raw-query.d.ts +27 -0
- package/dist/query-interface/alter-planner.d.ts +40 -0
- package/dist/query-interface/bulk-data.d.ts +44 -0
- package/dist/query-interface/column-commands.d.ts +52 -0
- package/dist/query-interface/column-describer.d.ts +17 -0
- package/dist/query-interface/enum-commands.d.ts +36 -0
- package/dist/query-interface/index-commands.d.ts +57 -0
- package/dist/query-interface/model-tables.d.ts +58 -0
- package/dist/query-interface/object-commands.d.ts +71 -0
- package/dist/query-interface/partition-commands.d.ts +43 -0
- package/dist/query-interface/policy-commands.d.ts +54 -0
- package/dist/query-interface/query-interface-catalog.d.ts +180 -0
- package/dist/query-interface/query-interface-objects.d.ts +108 -0
- package/dist/query-interface/query-interface-partitions.d.ts +66 -0
- package/dist/query-interface/query-interface-policies.d.ts +86 -0
- package/dist/query-interface/query-interface-routines.d.ts +120 -0
- package/dist/query-interface/query-interface-tables.d.ts +179 -0
- package/dist/query-interface/query-interface-types.d.ts +62 -0
- package/dist/query-interface/query-interface-views.d.ts +84 -0
- package/dist/query-interface/query-interface.d.ts +256 -0
- package/dist/query-interface/routine-commands.d.ts +71 -0
- package/dist/query-interface/schema-synchronizer.d.ts +110 -0
- package/dist/query-interface/statement-runner.d.ts +40 -0
- package/dist/query-interface/sync-planner.d.ts +26 -0
- package/dist/query-interface/table-commands.d.ts +63 -0
- package/dist/query-interface/table-introspector.d.ts +58 -0
- package/dist/query-interface/view-commands.d.ts +47 -0
- package/dist/sequelize/instance-hook-adders.d.ts +72 -0
- package/dist/sequelize/sequelize-base.d.ts +196 -0
- package/dist/sequelize/sequelize-constructor.d.ts +7 -0
- package/dist/sequelize/sequelize-helpers.d.ts +133 -0
- package/dist/sequelize/sequelize-hooks.d.ts +99 -0
- package/dist/sequelize/sequelize-internals.d.ts +87 -0
- package/dist/sequelize/sequelize-notifications.d.ts +66 -0
- package/dist/sequelize/sequelize-schema.d.ts +125 -0
- package/dist/sequelize/sequelize-transactions.d.ts +96 -0
- package/dist/sequelize.d.ts +1175 -0
- package/dist/sql/ast-clauses.d.ts +137 -0
- package/dist/sql/ast-expressions.d.ts +88 -0
- package/dist/sql/ast-statements.d.ts +80 -0
- package/dist/sql/ast.d.ts +21 -0
- package/dist/sql/compile.d.ts +21 -0
- package/dist/sql/dml-compiler.d.ts +54 -0
- package/dist/sql/expression-compiler.d.ts +56 -0
- package/dist/sql/from-compiler.d.ts +39 -0
- package/dist/sql/identifier-quoter.d.ts +15 -0
- package/dist/sql/merge-compiler.d.ts +20 -0
- package/dist/sql/order.d.ts +15 -0
- package/dist/sql/query-compiler.d.ts +45 -0
- package/dist/sql/sql-chunks.d.ts +50 -0
- package/dist/sql/with-compiler.d.ts +19 -0
- package/dist/transaction/advisory-locks.d.ts +28 -0
- package/dist/transaction/cls-namespace.d.ts +44 -0
- package/dist/transaction/transaction-constants.d.ts +35 -0
- package/dist/transaction/transaction-runner.d.ts +78 -0
- package/dist/transaction/transaction-starter.d.ts +25 -0
- package/dist/transaction/transaction-statements.d.ts +29 -0
- package/dist/transaction/transaction.d.ts +201 -0
- package/dist/validation/attribute-validators.d.ts +23 -0
- package/dist/validation/builtin-attribute-validator.d.ts +19 -0
- package/dist/validation/builtin-validators.d.ts +16 -0
- package/dist/validation/core-validator.d.ts +16 -0
- package/dist/validation/custom-validators.d.ts +13 -0
- package/dist/validation/instance-validator.d.ts +25 -0
- package/dist/validation/schema-items.d.ts +22 -0
- package/dist/validation/standard-schema-validator.d.ts +30 -0
- package/dist/validation/standard-schema.d.ts +39 -0
- package/dist/validation/types.d.ts +36 -0
- package/dist/validation/validation-target.d.ts +13 -0
- package/dist/where/comparison-compiler.d.ts +27 -0
- package/dist/where/condition-compiler.d.ts +18 -0
- package/dist/where/operand-resolver.d.ts +10 -0
- package/dist/where/operator-allowlist.d.ts +14 -0
- package/dist/where/where-support.d.ts +52 -0
- package/dist/where/where.d.ts +46 -0
- package/dist/where/window-compiler.d.ts +14 -0
- package/llm/USAGE.md +423 -0
- package/package.json +103 -4
- package/skills/postgrelize/SKILL.md +57 -0
- package/skills/postgrelize/reference/associations.md +108 -0
- package/skills/postgrelize/reference/errors.md +37 -0
- package/skills/postgrelize/reference/migrating-from-sequelize.md +15 -0
- package/skills/postgrelize/reference/postgresql-features.md +157 -0
- package/skills/postgrelize/reference/querying.md +111 -0
- package/skills/postgrelize/reference/schema.md +135 -0
- package/skills/postgrelize/reference/security.md +34 -0
- package/skills/postgrelize/reference/transactions-and-sessions.md +122 -0
- package/skills/postgrelize/reference/writing.md +198 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
2
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
3
|
+
import { ColumnDescription, ForeignKeyReference } from './query-interface-types.ts';
|
|
4
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Catalog lookups of `QueryInterface`: schemas, tables, columns and foreign keys. Every lookup
|
|
7
|
+
* filters by schema (the given one or `current_schema()`); values are escaped literals.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class TableIntrospector {
|
|
12
|
+
#private;
|
|
13
|
+
/**
|
|
14
|
+
* @param runner - Statement runner.
|
|
15
|
+
*/
|
|
16
|
+
constructor(runner: StatementRunner);
|
|
17
|
+
/**
|
|
18
|
+
* Lists user schemas.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Query options.
|
|
21
|
+
* @returns Schema names.
|
|
22
|
+
*/
|
|
23
|
+
showAllSchemas(options?: QueryOptionsBase): Promise<string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Checks whether a table exists.
|
|
26
|
+
*
|
|
27
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
28
|
+
* @param options - Query options.
|
|
29
|
+
* @returns True when the table exists.
|
|
30
|
+
*/
|
|
31
|
+
tableExists(table: TableName, options?: QueryOptionsBase): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Lists tables of the current schema.
|
|
34
|
+
*
|
|
35
|
+
* @param options - Query options.
|
|
36
|
+
* @returns Table names.
|
|
37
|
+
*/
|
|
38
|
+
showAllTables(options?: QueryOptionsBase): Promise<string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Describes the columns of a table.
|
|
41
|
+
*
|
|
42
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
43
|
+
* @param options - `schema` and query options.
|
|
44
|
+
* @returns Column descriptions keyed by column name.
|
|
45
|
+
* @throws Error when the table does not exist.
|
|
46
|
+
*/
|
|
47
|
+
describeTable(table: TableName, options: QueryOptionsBase & Readonly<{
|
|
48
|
+
schema?: string;
|
|
49
|
+
}>): Promise<Record<string, ColumnDescription>>;
|
|
50
|
+
/**
|
|
51
|
+
* Foreign keys of a table.
|
|
52
|
+
*
|
|
53
|
+
* @param table - Table name or `{ tableName, schema }`.
|
|
54
|
+
* @param options - Query options.
|
|
55
|
+
* @returns Constraint name, column and referenced table/column per foreign key column.
|
|
56
|
+
*/
|
|
57
|
+
getForeignKeyReferencesForTable(table: TableName, options?: QueryOptionsBase): Promise<ForeignKeyReference[]>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CreateMaterializedViewOptions, CreateViewOptions, DropViewOptions, RefreshMaterializedViewOptions } from '../ddl/view-ddl.ts';
|
|
2
|
+
import { TableName } from '../ddl/sql-literal.ts';
|
|
3
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
4
|
+
import { StatementRunner } from './statement-runner.ts';
|
|
5
|
+
/**
|
|
6
|
+
* View and materialized view DDL of `QueryInterface`. Names are quoted; the query is trusted SQL.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class ViewCommands {
|
|
11
|
+
#private;
|
|
12
|
+
/**
|
|
13
|
+
* @param runner - Statement runner.
|
|
14
|
+
*/
|
|
15
|
+
constructor(runner: StatementRunner);
|
|
16
|
+
/**
|
|
17
|
+
* Runs `CREATE VIEW`.
|
|
18
|
+
*
|
|
19
|
+
* @param name - View name.
|
|
20
|
+
* @param query - Trusted `SELECT` text.
|
|
21
|
+
* @param options - View and query options.
|
|
22
|
+
*/
|
|
23
|
+
createView(name: TableName, query: string, options: CreateViewOptions & QueryOptionsBase): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Runs `CREATE MATERIALIZED VIEW`.
|
|
26
|
+
*
|
|
27
|
+
* @param name - View name.
|
|
28
|
+
* @param query - Trusted `SELECT` text.
|
|
29
|
+
* @param options - View and query options.
|
|
30
|
+
*/
|
|
31
|
+
createMaterializedView(name: TableName, query: string, options: CreateMaterializedViewOptions & QueryOptionsBase): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Runs `REFRESH MATERIALIZED VIEW`.
|
|
34
|
+
*
|
|
35
|
+
* @param name - View name.
|
|
36
|
+
* @param options - Refresh and query options.
|
|
37
|
+
*/
|
|
38
|
+
refreshMaterializedView(name: TableName, options: RefreshMaterializedViewOptions & QueryOptionsBase): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Runs `DROP VIEW` or `DROP MATERIALIZED VIEW`.
|
|
41
|
+
*
|
|
42
|
+
* @param name - View name.
|
|
43
|
+
* @param materialized - Drops a materialized view.
|
|
44
|
+
* @param options - Drop and query options.
|
|
45
|
+
*/
|
|
46
|
+
dropView(name: TableName, materialized: boolean, options: DropViewOptions & QueryOptionsBase): Promise<void>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { NamedHookAdder } from '../model/mixins/named-hooks.ts';
|
|
2
|
+
/** Named hook adders of a `Sequelize` instance: `sequelize.beforeCreate(fn)` or `sequelize.beforeCreate(name, fn)` register a global hook. */
|
|
3
|
+
export interface InstanceHookAdders {
|
|
4
|
+
/** Adds a global `beforeValidate` hook: `sequelize.beforeValidate(fn)` or `sequelize.beforeValidate(name, fn)`. */
|
|
5
|
+
readonly beforeValidate: NamedHookAdder;
|
|
6
|
+
/** Adds a global `afterValidate` hook: `sequelize.afterValidate(fn)` or `sequelize.afterValidate(name, fn)`. */
|
|
7
|
+
readonly afterValidate: NamedHookAdder;
|
|
8
|
+
/** Adds a global `validationFailed` hook: `sequelize.validationFailed(fn)` or `sequelize.validationFailed(name, fn)`. */
|
|
9
|
+
readonly validationFailed: NamedHookAdder;
|
|
10
|
+
/** Adds a global `beforeCreate` hook: `sequelize.beforeCreate(fn)` or `sequelize.beforeCreate(name, fn)`. */
|
|
11
|
+
readonly beforeCreate: NamedHookAdder;
|
|
12
|
+
/** Adds a global `afterCreate` hook: `sequelize.afterCreate(fn)` or `sequelize.afterCreate(name, fn)`. */
|
|
13
|
+
readonly afterCreate: NamedHookAdder;
|
|
14
|
+
/** Adds a global `beforeUpdate` hook: `sequelize.beforeUpdate(fn)` or `sequelize.beforeUpdate(name, fn)`. */
|
|
15
|
+
readonly beforeUpdate: NamedHookAdder;
|
|
16
|
+
/** Adds a global `afterUpdate` hook: `sequelize.afterUpdate(fn)` or `sequelize.afterUpdate(name, fn)`. */
|
|
17
|
+
readonly afterUpdate: NamedHookAdder;
|
|
18
|
+
/** Adds a global `beforeSave` hook: `sequelize.beforeSave(fn)` or `sequelize.beforeSave(name, fn)`. */
|
|
19
|
+
readonly beforeSave: NamedHookAdder;
|
|
20
|
+
/** Adds a global `afterSave` hook: `sequelize.afterSave(fn)` or `sequelize.afterSave(name, fn)`. */
|
|
21
|
+
readonly afterSave: NamedHookAdder;
|
|
22
|
+
/** Adds a global `beforeDestroy` hook: `sequelize.beforeDestroy(fn)` or `sequelize.beforeDestroy(name, fn)`. */
|
|
23
|
+
readonly beforeDestroy: NamedHookAdder;
|
|
24
|
+
/** Adds a global `afterDestroy` hook: `sequelize.afterDestroy(fn)` or `sequelize.afterDestroy(name, fn)`. */
|
|
25
|
+
readonly afterDestroy: NamedHookAdder;
|
|
26
|
+
/** Adds a global `beforeRestore` hook: `sequelize.beforeRestore(fn)` or `sequelize.beforeRestore(name, fn)`. */
|
|
27
|
+
readonly beforeRestore: NamedHookAdder;
|
|
28
|
+
/** Adds a global `afterRestore` hook: `sequelize.afterRestore(fn)` or `sequelize.afterRestore(name, fn)`. */
|
|
29
|
+
readonly afterRestore: NamedHookAdder;
|
|
30
|
+
/** Adds a global `beforeUpsert` hook: `sequelize.beforeUpsert(fn)` or `sequelize.beforeUpsert(name, fn)`. */
|
|
31
|
+
readonly beforeUpsert: NamedHookAdder;
|
|
32
|
+
/** Adds a global `afterUpsert` hook: `sequelize.afterUpsert(fn)` or `sequelize.afterUpsert(name, fn)`. */
|
|
33
|
+
readonly afterUpsert: NamedHookAdder;
|
|
34
|
+
/** Adds a global `beforeBulkCreate` hook: `sequelize.beforeBulkCreate(fn)` or `sequelize.beforeBulkCreate(name, fn)`. */
|
|
35
|
+
readonly beforeBulkCreate: NamedHookAdder;
|
|
36
|
+
/** Adds a global `afterBulkCreate` hook: `sequelize.afterBulkCreate(fn)` or `sequelize.afterBulkCreate(name, fn)`. */
|
|
37
|
+
readonly afterBulkCreate: NamedHookAdder;
|
|
38
|
+
/** Adds a global `beforeBulkUpdate` hook: `sequelize.beforeBulkUpdate(fn)` or `sequelize.beforeBulkUpdate(name, fn)`. */
|
|
39
|
+
readonly beforeBulkUpdate: NamedHookAdder;
|
|
40
|
+
/** Adds a global `afterBulkUpdate` hook: `sequelize.afterBulkUpdate(fn)` or `sequelize.afterBulkUpdate(name, fn)`. */
|
|
41
|
+
readonly afterBulkUpdate: NamedHookAdder;
|
|
42
|
+
/** Adds a global `beforeBulkDestroy` hook: `sequelize.beforeBulkDestroy(fn)` or `sequelize.beforeBulkDestroy(name, fn)`. */
|
|
43
|
+
readonly beforeBulkDestroy: NamedHookAdder;
|
|
44
|
+
/** Adds a global `afterBulkDestroy` hook: `sequelize.afterBulkDestroy(fn)` or `sequelize.afterBulkDestroy(name, fn)`. */
|
|
45
|
+
readonly afterBulkDestroy: NamedHookAdder;
|
|
46
|
+
/** Adds a global `beforeBulkRestore` hook: `sequelize.beforeBulkRestore(fn)` or `sequelize.beforeBulkRestore(name, fn)`. */
|
|
47
|
+
readonly beforeBulkRestore: NamedHookAdder;
|
|
48
|
+
/** Adds a global `afterBulkRestore` hook: `sequelize.afterBulkRestore(fn)` or `sequelize.afterBulkRestore(name, fn)`. */
|
|
49
|
+
readonly afterBulkRestore: NamedHookAdder;
|
|
50
|
+
/** Adds a global `beforeFind` hook: `sequelize.beforeFind(fn)` or `sequelize.beforeFind(name, fn)`. */
|
|
51
|
+
readonly beforeFind: NamedHookAdder;
|
|
52
|
+
/** Adds a global `beforeFindAfterExpandIncludeAll` hook: `sequelize.beforeFindAfterExpandIncludeAll(fn)` or `sequelize.beforeFindAfterExpandIncludeAll(name, fn)`. */
|
|
53
|
+
readonly beforeFindAfterExpandIncludeAll: NamedHookAdder;
|
|
54
|
+
/** Adds a global `beforeFindAfterOptions` hook: `sequelize.beforeFindAfterOptions(fn)` or `sequelize.beforeFindAfterOptions(name, fn)`. */
|
|
55
|
+
readonly beforeFindAfterOptions: NamedHookAdder;
|
|
56
|
+
/** Adds a global `afterFind` hook: `sequelize.afterFind(fn)` or `sequelize.afterFind(name, fn)`. */
|
|
57
|
+
readonly afterFind: NamedHookAdder;
|
|
58
|
+
/** Adds a global `beforeCount` hook: `sequelize.beforeCount(fn)` or `sequelize.beforeCount(name, fn)`. */
|
|
59
|
+
readonly beforeCount: NamedHookAdder;
|
|
60
|
+
/** Adds a global `beforeSync` hook: `sequelize.beforeSync(fn)` or `sequelize.beforeSync(name, fn)`. */
|
|
61
|
+
readonly beforeSync: NamedHookAdder;
|
|
62
|
+
/** Adds a global `afterSync` hook: `sequelize.afterSync(fn)` or `sequelize.afterSync(name, fn)`. */
|
|
63
|
+
readonly afterSync: NamedHookAdder;
|
|
64
|
+
/** Adds a global `beforeConnect` hook: `sequelize.beforeConnect(fn)` or `sequelize.beforeConnect(name, fn)`. */
|
|
65
|
+
readonly beforeConnect: NamedHookAdder;
|
|
66
|
+
/** Adds a global `afterConnect` hook: `sequelize.afterConnect(fn)` or `sequelize.afterConnect(name, fn)`. */
|
|
67
|
+
readonly afterConnect: NamedHookAdder;
|
|
68
|
+
/** Adds a global `beforeBulkSync` hook: `sequelize.beforeBulkSync(fn)` or `sequelize.beforeBulkSync(name, fn)`. */
|
|
69
|
+
readonly beforeBulkSync: NamedHookAdder;
|
|
70
|
+
/** Adds a global `afterBulkSync` hook: `sequelize.afterBulkSync(fn)` or `sequelize.afterBulkSync(name, fn)`. */
|
|
71
|
+
readonly afterBulkSync: NamedHookAdder;
|
|
72
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { ConnectionConfig as ConnectionSettings, SequelizeOptions } from '../connection/options.ts';
|
|
2
|
+
import { Literal } from '../expressions/methods.ts';
|
|
3
|
+
import { Model } from '../model/model.ts';
|
|
4
|
+
import { ModelAttributes } from '../model/model-definition.ts';
|
|
5
|
+
import { AnyModel, InitOptions, ModelStatic } from '../model/options.ts';
|
|
6
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
7
|
+
import { QueryOptions } from '../query/query-result-shaper.ts';
|
|
8
|
+
import { QueryInterface } from '../query-interface/query-interface.ts';
|
|
9
|
+
import { SequelizeInternals } from './sequelize-internals.ts';
|
|
10
|
+
/**
|
|
11
|
+
* Options of `sequelize.define`: the model options of `Model.init` without `sequelize`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const options: DefineOptions = { tableName: 'products', timestamps: false, paranoid: false };
|
|
16
|
+
* const Product = sequelize.define('Product', { sku: DataTypes.STRING }, options);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export type DefineOptions = Omit<InitOptions, 'sequelize'>;
|
|
20
|
+
/**
|
|
21
|
+
* Core of `Sequelize`: options, models, query execution and connection lifecycle. The remaining
|
|
22
|
+
* capabilities are added by the `Sequelize` mixins; `Sequelize` is the public class.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare class SequelizeBase {
|
|
27
|
+
/** Normalized constructor options. */
|
|
28
|
+
readonly options: SequelizeOptions;
|
|
29
|
+
/** Connection settings. */
|
|
30
|
+
readonly config: ConnectionSettings;
|
|
31
|
+
/** Models registered with `define` / `Model.init`, by model name. */
|
|
32
|
+
readonly models: Record<string, ModelStatic<AnyModel>>;
|
|
33
|
+
/** Raw SQL fragment builder. */
|
|
34
|
+
readonly literal: (val: string) => Literal;
|
|
35
|
+
/** SQL function call builder. */
|
|
36
|
+
readonly fn: (name: string, ...args: readonly unknown[]) => import('../exports-core.ts').Fn;
|
|
37
|
+
/** Column reference builder. */
|
|
38
|
+
readonly col: (name: string) => import('../exports-core.ts').Col;
|
|
39
|
+
/** Type cast builder. */
|
|
40
|
+
readonly cast: (val: unknown, type: string) => import('../exports-core.ts').Cast;
|
|
41
|
+
/** Comparison builder. */
|
|
42
|
+
readonly where: import('../exports-core.ts').WhereFactory;
|
|
43
|
+
/** JSON path builder. */
|
|
44
|
+
readonly json: (conditionsOrPath: string | object, value?: unknown) => import('../exports-core.ts').Json;
|
|
45
|
+
/** @internal */
|
|
46
|
+
readonly internals: SequelizeInternals;
|
|
47
|
+
/**
|
|
48
|
+
* @param args - Connection URI, or database / username / password, followed by options.
|
|
49
|
+
*/
|
|
50
|
+
constructor(...args: readonly unknown[]);
|
|
51
|
+
/**
|
|
52
|
+
* Reports the SQL dialect of this instance; postgrelize supports PostgreSQL only.
|
|
53
|
+
*
|
|
54
|
+
* @returns Always `'postgres'`.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* sequelize.getDialect(); // 'postgres'
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
getDialect(): 'postgres';
|
|
62
|
+
/**
|
|
63
|
+
* Defines a model without declaring a class, like `Model.init` on an anonymous subclass named `modelName`.
|
|
64
|
+
* The model is registered in `sequelize.models`.
|
|
65
|
+
*
|
|
66
|
+
* @param modelName - Model name.
|
|
67
|
+
* @param attributes - Attribute definitions keyed by attribute name.
|
|
68
|
+
* @param options - Model options (`sequelize` is set for you).
|
|
69
|
+
* @returns The model class.
|
|
70
|
+
* @see {@link Model.init}
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* const Product = sequelize.define('Product', {
|
|
75
|
+
* sku: { type: DataTypes.STRING, allowNull: false, unique: true },
|
|
76
|
+
* price: DataTypes.DECIMAL(10, 2),
|
|
77
|
+
* });
|
|
78
|
+
* await Product.sync();
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
define<M extends AnyModel = Model>(modelName: string, attributes: ModelAttributes, options?: DefineOptions): ModelStatic<M>;
|
|
82
|
+
/**
|
|
83
|
+
* Registers model classes defined with decorators (`@Table`, `@Column`, `@HasMany`, …): initializes
|
|
84
|
+
* each one like `Model.init` and then adds its associations, so classes may refer to each other
|
|
85
|
+
* in any order. Pass every class of an association before using it.
|
|
86
|
+
*
|
|
87
|
+
* @param models - Model classes.
|
|
88
|
+
* @returns This instance.
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* sequelize.addModels([User, Post]);
|
|
92
|
+
* ```
|
|
93
|
+
* @see {@link Table}
|
|
94
|
+
*/
|
|
95
|
+
addModels(models: readonly ModelStatic<AnyModel>[]): this;
|
|
96
|
+
/**
|
|
97
|
+
* Looks up a model registered with `define`, `Model.init` or `addModels`.
|
|
98
|
+
*
|
|
99
|
+
* @param modelName - Model name.
|
|
100
|
+
* @returns The model class.
|
|
101
|
+
* @throws Error when the model is not defined.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* const Product = sequelize.model('Product');
|
|
106
|
+
* const total = await Product.count();
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
model(modelName: string): ModelStatic<AnyModel>;
|
|
110
|
+
/**
|
|
111
|
+
* Tells whether a model with the given name is registered on this instance.
|
|
112
|
+
*
|
|
113
|
+
* @param modelName - Model name.
|
|
114
|
+
* @returns True when defined.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* if (!sequelize.isDefined('Product')) {
|
|
119
|
+
* sequelize.define('Product', { sku: DataTypes.STRING });
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
isDefined(modelName: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Runs a raw SQL statement and shapes the result by `options.type`. Replacements are bound as parameters (never inlined).
|
|
126
|
+
* The SQL text itself is sent as is: never build it from user input — pass user values through
|
|
127
|
+
* `replacements` or `bind`.
|
|
128
|
+
*
|
|
129
|
+
* @param sql - SQL text, or a literal.
|
|
130
|
+
* @param options - Query options.
|
|
131
|
+
* @returns Shaped according to `options.type`, like Sequelize v6.
|
|
132
|
+
* @throws DatabaseError subclasses mapped from the PostgreSQL error (unique violation, foreign key violation, ...).
|
|
133
|
+
* @see {@link QueryTypes}
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* const rows = await sequelize.query('SELECT id, name FROM users WHERE name = :name', {
|
|
138
|
+
* type: QueryTypes.SELECT,
|
|
139
|
+
* replacements: { name: 'Ada' },
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
query(sql: string | Literal, options?: QueryOptions): Promise<unknown>;
|
|
144
|
+
/**
|
|
145
|
+
* Returns the schema manipulation API of this instance (used by migrations). The instance is created on first use and then reused.
|
|
146
|
+
*
|
|
147
|
+
* @returns The QueryInterface of this instance.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* const queryInterface = sequelize.getQueryInterface();
|
|
152
|
+
* await queryInterface.dropTable('legacy_logs');
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
getQueryInterface(): QueryInterface;
|
|
156
|
+
/**
|
|
157
|
+
* Verifies that the database is reachable by running `SELECT 1+1 AS result`.
|
|
158
|
+
*
|
|
159
|
+
* @param options - Query options.
|
|
160
|
+
* @returns Resolves when the database is reachable.
|
|
161
|
+
* @throws ConnectionError and its subclasses when the connection cannot be established.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* try {
|
|
166
|
+
* await sequelize.authenticate();
|
|
167
|
+
* } catch (error) {
|
|
168
|
+
* console.error('Database unreachable', error);
|
|
169
|
+
* }
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
authenticate(options?: QueryOptionsBase): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Reads the PostgreSQL server version with `SHOW server_version`, e.g. `'16.4'`.
|
|
175
|
+
*
|
|
176
|
+
* @param options - Query options.
|
|
177
|
+
* @returns Version string.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* const version = await sequelize.databaseVersion(); // e.g. '17.2'
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
databaseVersion(options?: QueryOptionsBase): Promise<string>;
|
|
185
|
+
/**
|
|
186
|
+
* Closes all pooled connections and stops the notification listener. The instance cannot run queries afterwards.
|
|
187
|
+
*
|
|
188
|
+
* @returns Resolves when closed.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* await sequelize.close();
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
close(): Promise<void>;
|
|
196
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Association } from '../associations/association.ts';
|
|
2
|
+
import { Fn } from '../expressions/methods.ts';
|
|
3
|
+
import { QueryOptionsBase } from '../model/runtime.ts';
|
|
4
|
+
import { QueryInterface } from '../query-interface/query-interface.ts';
|
|
5
|
+
import { SequelizeConstructor } from './sequelize-constructor.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Small Sequelize v6 instance members: `queryInterface`, `random`, `escape`, `validate`, `log`,
|
|
8
|
+
* `getDatabaseName`, `refreshTypes` and the `and` / `or` / `QueryTypes` / `Association` / `Validator` aliases.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const SequelizeHelpers: <TBase extends SequelizeConstructor>(Base: TBase) => {
|
|
13
|
+
new (...args: any[]): {
|
|
14
|
+
/** Result shapes of `query`, alias of {@link QueryTypes}. */
|
|
15
|
+
readonly QueryTypes: {
|
|
16
|
+
readonly SELECT: "SELECT";
|
|
17
|
+
readonly INSERT: "INSERT";
|
|
18
|
+
readonly UPDATE: "UPDATE";
|
|
19
|
+
readonly UPSERT: "UPSERT";
|
|
20
|
+
readonly DELETE: "DELETE";
|
|
21
|
+
readonly BULKUPDATE: "BULKUPDATE";
|
|
22
|
+
readonly BULKDELETE: "BULKDELETE";
|
|
23
|
+
readonly RAW: "RAW";
|
|
24
|
+
readonly SHOWTABLES: "SHOWTABLES";
|
|
25
|
+
readonly DESCRIBE: "DESCRIBE";
|
|
26
|
+
readonly VERSION: "VERSION";
|
|
27
|
+
readonly FOREIGNKEYS: "FOREIGNKEYS";
|
|
28
|
+
readonly SHOWINDEXES: "SHOWINDEXES";
|
|
29
|
+
readonly SHOWCONSTRAINTS: "SHOWCONSTRAINTS";
|
|
30
|
+
};
|
|
31
|
+
/** Base class of the association classes. */
|
|
32
|
+
readonly Association: typeof Association;
|
|
33
|
+
/** The `validator` library used by the built-in validators. */
|
|
34
|
+
readonly Validator: typeof import('validator');
|
|
35
|
+
/** Combines conditions with `AND`. */
|
|
36
|
+
readonly and: (...conditions: readonly import('../exports-model.ts').WhereOptions[]) => import('../exports-model.ts').WhereOptions;
|
|
37
|
+
/** Combines conditions with `OR`. */
|
|
38
|
+
readonly or: (...conditions: readonly import('../exports-model.ts').WhereOptions[]) => import('../exports-model.ts').WhereOptions;
|
|
39
|
+
/**
|
|
40
|
+
* Schema API of this instance (Sequelize v6 property; same object as `getQueryInterface()`).
|
|
41
|
+
*
|
|
42
|
+
* @returns The QueryInterface.
|
|
43
|
+
*/
|
|
44
|
+
get queryInterface(): QueryInterface;
|
|
45
|
+
/**
|
|
46
|
+
* SQL `RANDOM()` call, e.g. for `order: [sequelize.random()]`.
|
|
47
|
+
*
|
|
48
|
+
* @returns A `fn('RANDOM')` expression.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const sample = await User.findAll({ order: sequelize.random(), limit: 5 });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
random(): Fn;
|
|
56
|
+
/**
|
|
57
|
+
* Renders a value as a PostgreSQL literal, e.g. `'O''Brien'`. Prefer bound parameters for queries.
|
|
58
|
+
*
|
|
59
|
+
* @param value - String, number, boolean, `null`, `Date`, array or JSON value.
|
|
60
|
+
* @returns SQL literal text.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const sql = `SELECT ${sequelize.escape("O'Brien")}`; // SELECT 'O''Brien'
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
escape(value: unknown): string;
|
|
68
|
+
/**
|
|
69
|
+
* Alias of `authenticate`: checks that the database is reachable.
|
|
70
|
+
*
|
|
71
|
+
* @param options - Query options.
|
|
72
|
+
* @returns Resolves when the database is reachable.
|
|
73
|
+
* @throws ConnectionError and its subclasses when the connection cannot be established.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* await sequelize.validate();
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
validate(options?: QueryOptionsBase): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Name of the connected database.
|
|
83
|
+
*
|
|
84
|
+
* @returns Database name from the connection settings.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const name = sequelize.getDatabaseName();
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
getDatabaseName(): string | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Accepted for compatibility; postgrelize reads type information from each result, so there is nothing to refresh.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* sequelize.refreshTypes();
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
refreshTypes(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Passes a message to the configured `logging` function (or to the `logging` option of the last argument, as in v6).
|
|
103
|
+
*
|
|
104
|
+
* @param args - Message parts; an options object with `logging` may come last.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* sequelize.log('Cache warmed up');
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
log(...args: unknown[]): void;
|
|
112
|
+
readonly options: import('../exports-core.ts').SequelizeOptions;
|
|
113
|
+
readonly config: import('../exports-core.ts').ConnectionConfig;
|
|
114
|
+
readonly models: Record<string, import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>>;
|
|
115
|
+
readonly literal: (val: string) => import('../exports-core.ts').Literal;
|
|
116
|
+
readonly fn: (name: string, ...args: readonly unknown[]) => Fn;
|
|
117
|
+
readonly col: (name: string) => import('../exports-core.ts').Col;
|
|
118
|
+
readonly cast: (val: unknown, type: string) => import('../exports-core.ts').Cast;
|
|
119
|
+
readonly where: import('../exports-core.ts').WhereFactory;
|
|
120
|
+
readonly json: (conditionsOrPath: string | object, value?: unknown) => import('../exports-core.ts').Json;
|
|
121
|
+
readonly internals: import('./sequelize-internals.ts').SequelizeInternals;
|
|
122
|
+
getDialect(): "postgres";
|
|
123
|
+
define<M extends import('../exports-model.ts').AnyModel = import('../exports-model.ts').Model<import('../exports-model.ts').Values, import('../exports-model.ts').Values>>(modelName: string, attributes: import('../exports-model.ts').ModelAttributes, options?: import('./sequelize-base.ts').DefineOptions): import('../exports-model.ts').ModelStatic<M>;
|
|
124
|
+
addModels(models: readonly import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>[]): /*elided*/ any;
|
|
125
|
+
model(modelName: string): import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>;
|
|
126
|
+
isDefined(modelName: string): boolean;
|
|
127
|
+
query(sql: string | import('../exports-core.ts').Literal, options?: import('../sequelize.ts').QueryOptions): Promise<unknown>;
|
|
128
|
+
getQueryInterface(): QueryInterface;
|
|
129
|
+
authenticate(options?: QueryOptionsBase): Promise<void>;
|
|
130
|
+
databaseVersion(options?: QueryOptionsBase): Promise<string>;
|
|
131
|
+
close(): Promise<void>;
|
|
132
|
+
};
|
|
133
|
+
} & TBase;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { HookFunction } from '../hooks/hooks.ts';
|
|
2
|
+
import { SequelizeConstructor } from './sequelize-constructor.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Hook methods of `Sequelize`: `addHook`, `removeHook`, `hasHook`, `hasHooks`, `runHooks` and the named adders.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const SequelizeHooks: <TBase extends SequelizeConstructor>(Base: TBase) => {
|
|
9
|
+
new (...args: any[]): {
|
|
10
|
+
/**
|
|
11
|
+
* Registers a global hook that runs for every model of this instance, or a connection hook such as `beforeConnect`. Global hooks are not fired for models that never use the hook type.
|
|
12
|
+
*
|
|
13
|
+
* @param type - Hook type, e.g. `'beforeCreate'`.
|
|
14
|
+
* @param nameOrFn - Hook name (to remove it later) or the hook function.
|
|
15
|
+
* @param hook - Hook function when a name is given.
|
|
16
|
+
* @returns This instance.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* sequelize.addHook('beforeCreate', 'stamp', (instance: any) => {
|
|
21
|
+
* instance.createdBy = 'system';
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
addHook(type: string, nameOrFn: string | HookFunction, hook?: HookFunction): /*elided*/ any;
|
|
26
|
+
/**
|
|
27
|
+
* Unregisters global hooks by name or by function reference.
|
|
28
|
+
*
|
|
29
|
+
* @param type - Hook type.
|
|
30
|
+
* @param nameOrFn - Hook name or function; all hooks of the type when omitted.
|
|
31
|
+
* @returns This instance.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* sequelize.removeHook('beforeCreate', 'stamp');
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
removeHook(type: string, nameOrFn?: string | HookFunction): /*elided*/ any;
|
|
39
|
+
/**
|
|
40
|
+
* Tells whether this instance has at least one global hook of the given type.
|
|
41
|
+
*
|
|
42
|
+
* @param type - Hook type.
|
|
43
|
+
* @returns True when at least one hook exists.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* if (!sequelize.hasHook('beforeCreate')) {
|
|
48
|
+
* sequelize.addHook('beforeCreate', () => {});
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
hasHook(type: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Alias of {@link Sequelize.hasHook}, kept for Sequelize v6 compatibility.
|
|
55
|
+
*
|
|
56
|
+
* @param type - Hook type.
|
|
57
|
+
* @returns True when at least one hook exists.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const registered = sequelize.hasHooks('afterUpdate');
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
hasHooks(type: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Runs the global hooks of a type with the given arguments.
|
|
67
|
+
*
|
|
68
|
+
* @param type - Hook type.
|
|
69
|
+
* @param args - Hook arguments.
|
|
70
|
+
* @returns Resolves when all hooks finished.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* await sequelize.runHooks('beforeConnect', { host: 'localhost' });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
runHooks(type: string, ...args: readonly unknown[]): Promise<void>;
|
|
78
|
+
readonly options: import('../exports-core.ts').SequelizeOptions;
|
|
79
|
+
readonly config: import('../exports-core.ts').ConnectionConfig;
|
|
80
|
+
readonly models: Record<string, import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>>;
|
|
81
|
+
readonly literal: (val: string) => import('../exports-core.ts').Literal;
|
|
82
|
+
readonly fn: (name: string, ...args: readonly unknown[]) => import('../exports-core.ts').Fn;
|
|
83
|
+
readonly col: (name: string) => import('../exports-core.ts').Col;
|
|
84
|
+
readonly cast: (val: unknown, type: string) => import('../exports-core.ts').Cast;
|
|
85
|
+
readonly where: import('../exports-core.ts').WhereFactory;
|
|
86
|
+
readonly json: (conditionsOrPath: string | object, value?: unknown) => import('../exports-core.ts').Json;
|
|
87
|
+
readonly internals: import('./sequelize-internals.ts').SequelizeInternals;
|
|
88
|
+
getDialect(): "postgres";
|
|
89
|
+
define<M extends import('../exports-model.ts').AnyModel = import('../exports-model.ts').Model<import('../exports-model.ts').Values, import('../exports-model.ts').Values>>(modelName: string, attributes: import('../exports-model.ts').ModelAttributes, options?: import('./sequelize-base.ts').DefineOptions): import('../exports-model.ts').ModelStatic<M>;
|
|
90
|
+
addModels(models: readonly import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>[]): /*elided*/ any;
|
|
91
|
+
model(modelName: string): import('../exports-model.ts').ModelStatic<import('../exports-model.ts').AnyModel>;
|
|
92
|
+
isDefined(modelName: string): boolean;
|
|
93
|
+
query(sql: string | import('../exports-core.ts').Literal, options?: import('../sequelize.ts').QueryOptions): Promise<unknown>;
|
|
94
|
+
getQueryInterface(): import('../exports-schema.ts').QueryInterface;
|
|
95
|
+
authenticate(options?: import('../exports-model.ts').QueryOptionsBase): Promise<void>;
|
|
96
|
+
databaseVersion(options?: import('../exports-model.ts').QueryOptionsBase): Promise<string>;
|
|
97
|
+
close(): Promise<void>;
|
|
98
|
+
};
|
|
99
|
+
} & TBase;
|