ts-prorm-orm 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 +1111 -0
- package/LICENSE +21 -0
- package/README.md +573 -0
- package/dist/audit/history-query.js +180 -0
- package/dist/audit/index.js +23 -0
- package/dist/audit/logger.js +236 -0
- package/dist/cache/cache-manager.js +84 -0
- package/dist/cache/index.js +16 -0
- package/dist/cache/redis-cluster-cache.js +557 -0
- package/dist/cli.js +2200 -0
- package/dist/compliance/audit-trail.js +68 -0
- package/dist/compliance/backup-verification.js +685 -0
- package/dist/compliance/breach-detector.js +505 -0
- package/dist/compliance/consent-record.js +227 -0
- package/dist/compliance/consent-versioning.js +331 -0
- package/dist/compliance/cross-border-log.js +530 -0
- package/dist/compliance/data-classifier.js +258 -0
- package/dist/compliance/data-lineage.js +565 -0
- package/dist/compliance/data-masker.js +303 -0
- package/dist/compliance/data-portability.js +265 -0
- package/dist/compliance/data-retention.js +195 -0
- package/dist/compliance/dsar-workflow.js +342 -0
- package/dist/compliance/field-encryption.js +223 -0
- package/dist/compliance/immutable-record.js +148 -0
- package/dist/compliance/index.js +260 -0
- package/dist/compliance/privacy-impact-assessment.js +364 -0
- package/dist/compliance/pseudonymization.js +269 -0
- package/dist/compliance/query-firewall.js +1182 -0
- package/dist/compliance/rate-limiter.js +580 -0
- package/dist/compliance/right-to-erasure.js +117 -0
- package/dist/compliance/row-level-security.js +246 -0
- package/dist/compliance/security-decorator.js +574 -0
- package/dist/compliance/security-monitor.js +525 -0
- package/dist/compliance/sensitive-data-discovery.js +476 -0
- package/dist/compliance/session-isolation.js +472 -0
- package/dist/compliance/tls-enforcer.js +108 -0
- package/dist/compliance/worm-storage.js +712 -0
- package/dist/connection-manager.js +198 -0
- package/dist/connection-pool.js +519 -0
- package/dist/decorators/audit.js +136 -0
- package/dist/decorators/belongs-to-many.js +115 -0
- package/dist/decorators/belongs-to.js +115 -0
- package/dist/decorators/check.js +435 -0
- package/dist/decorators/collate.js +329 -0
- package/dist/decorators/comment.js +205 -0
- package/dist/decorators/database-settings.js +236 -0
- package/dist/decorators/default.js +244 -0
- package/dist/decorators/encryption.js +235 -0
- package/dist/decorators/engine.js +97 -0
- package/dist/decorators/fk-constraints.js +594 -0
- package/dist/decorators/foreign-table.js +136 -0
- package/dist/decorators/generated.js +274 -0
- package/dist/decorators/has-many.js +127 -0
- package/dist/decorators/has-one.js +116 -0
- package/dist/decorators/hstore.js +129 -0
- package/dist/decorators/index.js +355 -0
- package/dist/decorators/json-column.js +83 -0
- package/dist/decorators/jsonb.js +101 -0
- package/dist/decorators/orm-decorators.js +425 -0
- package/dist/decorators/permissions.js +294 -0
- package/dist/decorators/procedure.js +210 -0
- package/dist/decorators/query-options.js +556 -0
- package/dist/decorators/range.js +167 -0
- package/dist/decorators/set-column.js +83 -0
- package/dist/decorators/spatial.js +114 -0
- package/dist/decorators/storage.js +580 -0
- package/dist/decorators/timezone.js +512 -0
- package/dist/decorators/trigger.js +90 -0
- package/dist/decorators/uuid.js +135 -0
- package/dist/decorators/view.js +258 -0
- package/dist/diagrams/chen-diagram.js +354 -0
- package/dist/diagrams/class-diagram.js +384 -0
- package/dist/diagrams/dependency-diagram.js +432 -0
- package/dist/diagrams/er-diagram.js +605 -0
- package/dist/diagrams/flow-diagram.js +394 -0
- package/dist/diagrams/gantt-diagram.js +411 -0
- package/dist/diagrams/index-diagram.js +353 -0
- package/dist/diagrams/index.js +184 -0
- package/dist/diagrams/migration-diagram.js +316 -0
- package/dist/diagrams/model-diagram.js +616 -0
- package/dist/diagrams/package-diagram.js +376 -0
- package/dist/diagrams/palette.js +85 -0
- package/dist/diagrams/relational-diagram.js +455 -0
- package/dist/diagrams/schemadoc-diagram.js +309 -0
- package/dist/diagrams/sequence-diagram.js +307 -0
- package/dist/diagrams/state-diagram.js +344 -0
- package/dist/diagrams/svg-dom.js +111 -0
- package/dist/diagrams/tree-diagram.js +250 -0
- package/dist/dialects/clickhouse/index.js +1742 -0
- package/dist/dialects/cockroachdb/index.js +4677 -0
- package/dist/dialects/cratedb/index.js +441 -0
- package/dist/dialects/databricks/index.js +517 -0
- package/dist/dialects/db2/index.js +2225 -0
- package/dist/dialects/dialect.js +720 -0
- package/dist/dialects/duckdb/index.js +2014 -0
- package/dist/dialects/exasol/index.js +357 -0
- package/dist/dialects/firebird/index.js +495 -0
- package/dist/dialects/greenplum/index.js +457 -0
- package/dist/dialects/hana/index.js +1741 -0
- package/dist/dialects/mariadb/index.js +3590 -0
- package/dist/dialects/mssql/index.js +2296 -0
- package/dist/dialects/mysql/index.js +4058 -0
- package/dist/dialects/oracle/index.js +2999 -0
- package/dist/dialects/postgres/index.js +5319 -0
- package/dist/dialects/query-stream-helper.js +152 -0
- package/dist/dialects/questdb/index.js +433 -0
- package/dist/dialects/redshift/index.js +2277 -0
- package/dist/dialects/singlestore/index.js +354 -0
- package/dist/dialects/snowflake/index.js +2082 -0
- package/dist/dialects/spanner/index.js +1768 -0
- package/dist/dialects/sqlite/index.js +3382 -0
- package/dist/dialects/tidb/index.js +377 -0
- package/dist/dialects/timescaledb/index.js +164 -0
- package/dist/dialects/trino/index.js +420 -0
- package/dist/dialects/turso/index.js +227 -0
- package/dist/dialects/vertica/index.js +317 -0
- package/dist/dialects/yugabytedb/index.js +424 -0
- package/dist/errors/index.js +472 -0
- package/dist/errors/utils.js +340 -0
- package/dist/errors.js +21 -0
- package/dist/extensions/catalog/cloud-warehouse-features.js +207 -0
- package/dist/extensions/catalog/mssql-features.js +147 -0
- package/dist/extensions/catalog/mysql-mariadb-plugins.js +229 -0
- package/dist/extensions/catalog/oracle-db2-features.js +196 -0
- package/dist/extensions/catalog/postgres-extensions.js +516 -0
- package/dist/extensions/index.js +71 -0
- package/dist/extensions/types.js +13 -0
- package/dist/foreign-data.js +173 -0
- package/dist/hooks/hooks-manager.js +350 -0
- package/dist/hooks/index.js +37 -0
- package/dist/index.js +463 -0
- package/dist/logging.js +335 -0
- package/dist/migrations/index.js +40 -0
- package/dist/migrations/migration.js +196 -0
- package/dist/migrations/migrator.js +411 -0
- package/dist/migrations/prormmigration.js +275 -0
- package/dist/migrations/query-interface.js +435 -0
- package/dist/migrations/seeder.js +353 -0
- package/dist/models/associations.js +852 -0
- package/dist/models/constraints.js +288 -0
- package/dist/models/data-types.js +2518 -0
- package/dist/models/decorators.js +445 -0
- package/dist/models/index.js +33 -0
- package/dist/models/indexes.js +531 -0
- package/dist/models/methods.js +382 -0
- package/dist/models/model-manager.js +103 -0
- package/dist/models/model.js +5349 -0
- package/dist/models/operators.js +67 -0
- package/dist/models/scopes.js +189 -0
- package/dist/models/typescript-types.js +26 -0
- package/dist/nosql/aerospike/index.js +205 -0
- package/dist/nosql/allegrograph/index.js +169 -0
- package/dist/nosql/arangodb/index.js +364 -0
- package/dist/nosql/azure-blob/index.js +206 -0
- package/dist/nosql/beanstalkd/index.js +231 -0
- package/dist/nosql/beequeue/index.js +210 -0
- package/dist/nosql/bigchaindb/index.js +195 -0
- package/dist/nosql/bigtable/index.js +224 -0
- package/dist/nosql/blazegraph/index.js +173 -0
- package/dist/nosql/bullmq/index.js +191 -0
- package/dist/nosql/cassandra/index.js +174 -0
- package/dist/nosql/chroma/index.js +190 -0
- package/dist/nosql/cloudflare-kv/index.js +220 -0
- package/dist/nosql/coherence/index.js +200 -0
- package/dist/nosql/cosmosdb/index.js +157 -0
- package/dist/nosql/couchbase/index.js +213 -0
- package/dist/nosql/dax/index.js +212 -0
- package/dist/nosql/deno-kv/index.js +206 -0
- package/dist/nosql/dgraph/index.js +171 -0
- package/dist/nosql/doris/index.js +169 -0
- package/dist/nosql/druid/index.js +162 -0
- package/dist/nosql/dynamodb/index.js +937 -0
- package/dist/nosql/elasticsearch/index.js +377 -0
- package/dist/nosql/etcd/index.js +502 -0
- package/dist/nosql/eventhubs/index.js +213 -0
- package/dist/nosql/eventstore/index.js +254 -0
- package/dist/nosql/faunadb/index.js +188 -0
- package/dist/nosql/firestore/index.js +177 -0
- package/dist/nosql/fluree/index.js +148 -0
- package/dist/nosql/fuseki/index.js +170 -0
- package/dist/nosql/gcs/index.js +172 -0
- package/dist/nosql/gearman/index.js +160 -0
- package/dist/nosql/geode/index.js +196 -0
- package/dist/nosql/graphdb/index.js +169 -0
- package/dist/nosql/graylog/index.js +188 -0
- package/dist/nosql/gridgain/index.js +171 -0
- package/dist/nosql/hazelcast/index.js +162 -0
- package/dist/nosql/hbase/index.js +230 -0
- package/dist/nosql/ignite/index.js +173 -0
- package/dist/nosql/immudb/index.js +184 -0
- package/dist/nosql/index.js +232 -0
- package/dist/nosql/infinispan/index.js +200 -0
- package/dist/nosql/influxdb/index.js +0 -0
- package/dist/nosql/kafka/index.js +234 -0
- package/dist/nosql/keyspaces/index.js +189 -0
- package/dist/nosql/kinesis/index.js +253 -0
- package/dist/nosql/leveldb/index.js +153 -0
- package/dist/nosql/lmdb/index.js +160 -0
- package/dist/nosql/loki/index.js +201 -0
- package/dist/nosql/marklogic/index.js +204 -0
- package/dist/nosql/materialize/index.js +145 -0
- package/dist/nosql/meilisearch/index.js +154 -0
- package/dist/nosql/memcached/index.js +223 -0
- package/dist/nosql/milvus/index.js +410 -0
- package/dist/nosql/minio/index.js +265 -0
- package/dist/nosql/momento/index.js +179 -0
- package/dist/nosql/mongodb/index.js +461 -0
- package/dist/nosql/nats/index.js +247 -0
- package/dist/nosql/nedb/index.js +164 -0
- package/dist/nosql/neo4j/index.js +450 -0
- package/dist/nosql/neptune/index.js +470 -0
- package/dist/nosql/nsq/index.js +200 -0
- package/dist/nosql/opensearch/index.js +186 -0
- package/dist/nosql/orientdb/index.js +175 -0
- package/dist/nosql/papertrail/index.js +200 -0
- package/dist/nosql/pinecone/index.js +0 -0
- package/dist/nosql/pinot/index.js +133 -0
- package/dist/nosql/pouchdb/index.js +172 -0
- package/dist/nosql/prometheus/index.js +174 -0
- package/dist/nosql/provendb/index.js +147 -0
- package/dist/nosql/pubsub/index.js +187 -0
- package/dist/nosql/pulsar/index.js +232 -0
- package/dist/nosql/qdrant/index.js +295 -0
- package/dist/nosql/qldb/index.js +192 -0
- package/dist/nosql/r2/index.js +281 -0
- package/dist/nosql/rabbitmq/index.js +237 -0
- package/dist/nosql/ravendb/index.js +175 -0
- package/dist/nosql/redis/index.js +607 -0
- package/dist/nosql/redpanda/index.js +237 -0
- package/dist/nosql/resque/index.js +203 -0
- package/dist/nosql/rethinkdb/index.js +232 -0
- package/dist/nosql/rocksdb/index.js +152 -0
- package/dist/nosql/rockset/index.js +126 -0
- package/dist/nosql/s3/index.js +298 -0
- package/dist/nosql/scylladb/index.js +178 -0
- package/dist/nosql/signoz/index.js +227 -0
- package/dist/nosql/sns/index.js +201 -0
- package/dist/nosql/solr/index.js +231 -0
- package/dist/nosql/splunk/index.js +227 -0
- package/dist/nosql/sqs/index.js +246 -0
- package/dist/nosql/stardog/index.js +169 -0
- package/dist/nosql/starrocks/index.js +170 -0
- package/dist/nosql/store.js +2 -0
- package/dist/nosql/sumologic/index.js +213 -0
- package/dist/nosql/surrealdb/index.js +179 -0
- package/dist/nosql/terminusdb/index.js +151 -0
- package/dist/nosql/tigergraph/index.js +469 -0
- package/dist/nosql/typesense/index.js +148 -0
- package/dist/nosql/unqlite/index.js +157 -0
- package/dist/nosql/upstash/index.js +167 -0
- package/dist/nosql/vercel-kv/index.js +166 -0
- package/dist/nosql/victoriametrics/index.js +213 -0
- package/dist/nosql/virtuoso/index.js +169 -0
- package/dist/nosql/weaviate/index.js +276 -0
- package/dist/operators/index.js +108 -0
- package/dist/operators.js +2690 -0
- package/dist/prisma-migrate/index.js +38 -0
- package/dist/prisma-migrate/migration-generator.js +125 -0
- package/dist/prisma-migrate/model-generator.js +172 -0
- package/dist/prisma-migrate/relations.js +100 -0
- package/dist/prisma-migrate/schema-parser.js +167 -0
- package/dist/prisma-migrate/type-mapper.js +40 -0
- package/dist/prorm.js +6832 -0
- package/dist/query-builders/cte-builder.js +80 -0
- package/dist/query-builders/functions/aggregate.js +390 -0
- package/dist/query-builders/functions/conditional.js +503 -0
- package/dist/query-builders/functions/datetime.js +695 -0
- package/dist/query-builders/functions/fulltext.js +439 -0
- package/dist/query-builders/functions/index.js +93 -0
- package/dist/query-builders/functions/json.js +427 -0
- package/dist/query-builders/functions/math.js +399 -0
- package/dist/query-builders/functions/string.js +518 -0
- package/dist/query-builders/functions/window.js +328 -0
- package/dist/query-builders/include-builder.js +323 -0
- package/dist/query-builders/index-expression-builder.js +242 -0
- package/dist/query-builders/index.js +161 -0
- package/dist/query-builders/insert-builder.js +164 -0
- package/dist/query-builders/model-helpers.js +38 -0
- package/dist/query-builders/order-limit-builder.js +239 -0
- package/dist/query-builders/sql-compiler.js +2040 -0
- package/dist/query-builders/subquery-builder.js +152 -0
- package/dist/query-builders/update-builder.js +182 -0
- package/dist/query-builders/view-builder.js +218 -0
- package/dist/query-builders/where-builder.js +1532 -0
- package/dist/query-interface.js +622 -0
- package/dist/query-optimizers/batch-optimizer.js +426 -0
- package/dist/query-optimizers/explain-plans.js +415 -0
- package/dist/query-optimizers/index.js +51 -0
- package/dist/query-optimizers/prepared-statement-cache.js +423 -0
- package/dist/query-optimizers/query-hints.js +438 -0
- package/dist/query-optimizers/query-optimizer.js +278 -0
- package/dist/query-optimizers/slow-query-logger.js +271 -0
- package/dist/replica-manager.js +507 -0
- package/dist/schema/index.js +15 -0
- package/dist/schema/migration-generator.js +374 -0
- package/dist/schema/schema-differ.js +549 -0
- package/dist/schema/types.js +6 -0
- package/dist/sql-constants.js +300 -0
- package/dist/sqlite-advanced.js +1047 -0
- package/dist/streams/index.js +12 -0
- package/dist/streams/transforms.js +178 -0
- package/dist/transaction.js +456 -0
- package/dist/types/index.js +180 -0
- package/dist/user-management.js +127 -0
- package/dist/utils/date.js +300 -0
- package/dist/utils/index.js +1079 -0
- package/dist/utils/string.js +161 -0
- package/dist/validators/index.js +19 -0
- package/dist/validators/validator.js +911 -0
- package/package.json +190 -0
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* QueryInterface - Provides methods for executing database operations during migrations
|
|
4
|
+
* Works with all supported dialects: SQLite, MySQL, PostgreSQL, MariaDB
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.CreateQueryInterface = void 0;
|
|
8
|
+
exports.createQueryInterface = createQueryInterface;
|
|
9
|
+
/**
|
|
10
|
+
* CreateQueryInterface - Provides migration operations for all database dialects
|
|
11
|
+
*/
|
|
12
|
+
class CreateQueryInterface {
|
|
13
|
+
/**
|
|
14
|
+
* Create a new QueryInterface instance
|
|
15
|
+
* @param dialect - The database dialect to use
|
|
16
|
+
*/
|
|
17
|
+
constructor(dialect) {
|
|
18
|
+
this.dialect = dialect;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get the dialect instance
|
|
22
|
+
*/
|
|
23
|
+
getDialect() {
|
|
24
|
+
return this.dialect;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a new table
|
|
28
|
+
* @param tableName - Name of the table to create
|
|
29
|
+
* @param columns - Column definitions
|
|
30
|
+
* @param options - Table options
|
|
31
|
+
*/
|
|
32
|
+
async createTable(tableName, columns, options) {
|
|
33
|
+
const columnDefinitions = {};
|
|
34
|
+
for (const [colName, colDef] of Object.entries(columns)) {
|
|
35
|
+
columnDefinitions[colName] = {
|
|
36
|
+
type: typeof colDef.type === 'string'
|
|
37
|
+
? colDef.type
|
|
38
|
+
: colDef.type,
|
|
39
|
+
allowNull: colDef.allowNull,
|
|
40
|
+
defaultValue: colDef.defaultValue,
|
|
41
|
+
primaryKey: colDef.primaryKey,
|
|
42
|
+
autoIncrement: colDef.autoIncrement,
|
|
43
|
+
unique: colDef.unique,
|
|
44
|
+
references: colDef.references
|
|
45
|
+
? {
|
|
46
|
+
table: colDef.references.model,
|
|
47
|
+
field: colDef.references.key || 'id',
|
|
48
|
+
onDelete: colDef.references.onDelete,
|
|
49
|
+
onUpdate: colDef.references.onUpdate,
|
|
50
|
+
}
|
|
51
|
+
: undefined,
|
|
52
|
+
comment: colDef.comment,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
await this.dialect.createTable(tableName, columnDefinitions, options);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create a partitioned table (PostgreSQL 10+)
|
|
59
|
+
* @param tableName - Name of the table to create
|
|
60
|
+
* @param columns - Column definitions
|
|
61
|
+
* @param options - Table options including partition configuration
|
|
62
|
+
*/
|
|
63
|
+
async createPartitionedTable(tableName, columns, options) {
|
|
64
|
+
const columnDefinitions = {};
|
|
65
|
+
for (const [colName, colDef] of Object.entries(columns)) {
|
|
66
|
+
columnDefinitions[colName] = {
|
|
67
|
+
type: typeof colDef.type === 'string'
|
|
68
|
+
? colDef.type
|
|
69
|
+
: colDef.type,
|
|
70
|
+
allowNull: colDef.allowNull,
|
|
71
|
+
defaultValue: colDef.defaultValue,
|
|
72
|
+
primaryKey: colDef.primaryKey,
|
|
73
|
+
autoIncrement: colDef.autoIncrement,
|
|
74
|
+
unique: colDef.unique,
|
|
75
|
+
references: colDef.references
|
|
76
|
+
? {
|
|
77
|
+
table: colDef.references.model,
|
|
78
|
+
field: colDef.references.key || 'id',
|
|
79
|
+
onDelete: colDef.references.onDelete,
|
|
80
|
+
onUpdate: colDef.references.onUpdate,
|
|
81
|
+
}
|
|
82
|
+
: undefined,
|
|
83
|
+
comment: colDef.comment,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
await this.dialect.createPartitionedTable(tableName, columnDefinitions, options);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a partition for an existing partitioned table (PostgreSQL 10+)
|
|
90
|
+
* @param options - Partition creation options
|
|
91
|
+
*/
|
|
92
|
+
async createPartition(options) {
|
|
93
|
+
await this.dialect.createPartition(options);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Attach a partition to a partitioned table (PostgreSQL 11+)
|
|
97
|
+
* @param options - Partition attachment options
|
|
98
|
+
*/
|
|
99
|
+
async attachPartition(options) {
|
|
100
|
+
await this.dialect.attachPartition(options);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Detach a partition from a partitioned table (PostgreSQL 11+)
|
|
104
|
+
* @param options - Partition detachment options
|
|
105
|
+
*/
|
|
106
|
+
async detachPartition(options) {
|
|
107
|
+
await this.dialect.detachPartition(options);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Drop a partition (PostgreSQL 10+)
|
|
111
|
+
* @param partitionName - Name of the partition to drop
|
|
112
|
+
* @param options - Drop options
|
|
113
|
+
*/
|
|
114
|
+
async dropPartition(partitionName, options) {
|
|
115
|
+
await this.dialect.dropPartition(partitionName, options);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Drop a table
|
|
119
|
+
* @param tableName - Name of the table to drop
|
|
120
|
+
* @param options - Drop options
|
|
121
|
+
*/
|
|
122
|
+
async dropTable(tableName, options) {
|
|
123
|
+
await this.dialect.dropTable(tableName, options);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Drop all tables (dialect-specific)
|
|
127
|
+
*/
|
|
128
|
+
async dropAllTables(_options) {
|
|
129
|
+
const tables = await this.dialect.showTables();
|
|
130
|
+
for (const table of tables) {
|
|
131
|
+
await this.dialect.dropTable(table);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Rename a table
|
|
136
|
+
* @param oldName - Current table name
|
|
137
|
+
* @param newName - New table name
|
|
138
|
+
*/
|
|
139
|
+
async renameTable(oldName, newName, _options) {
|
|
140
|
+
await this.dialect.renameTable(oldName, newName);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Add a column to a table
|
|
144
|
+
* @param tableName - Name of the table
|
|
145
|
+
* @param columnName - Name of the new column
|
|
146
|
+
* @param definition - Column definition
|
|
147
|
+
*/
|
|
148
|
+
async addColumn(tableName, columnName, definition, _options) {
|
|
149
|
+
const columnDef = {
|
|
150
|
+
type: typeof definition.type === 'string'
|
|
151
|
+
? definition.type
|
|
152
|
+
: definition.type,
|
|
153
|
+
allowNull: definition.allowNull,
|
|
154
|
+
defaultValue: definition.defaultValue,
|
|
155
|
+
primaryKey: definition.primaryKey,
|
|
156
|
+
autoIncrement: definition.autoIncrement,
|
|
157
|
+
unique: definition.unique,
|
|
158
|
+
references: definition.references
|
|
159
|
+
? {
|
|
160
|
+
table: definition.references.model,
|
|
161
|
+
field: definition.references.key || 'id',
|
|
162
|
+
onDelete: definition.references.onDelete,
|
|
163
|
+
onUpdate: definition.references.onUpdate,
|
|
164
|
+
}
|
|
165
|
+
: undefined,
|
|
166
|
+
comment: definition.comment,
|
|
167
|
+
};
|
|
168
|
+
await this.dialect.addColumn(tableName, columnName, columnDef);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Remove a column from a table
|
|
172
|
+
* @param tableName - Name of the table
|
|
173
|
+
* @param columnName - Name of the column to remove
|
|
174
|
+
*/
|
|
175
|
+
async removeColumn(tableName, columnName, _options) {
|
|
176
|
+
await this.dialect.removeColumn(tableName, columnName);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Change a column definition
|
|
180
|
+
* @param tableName - Name of the table
|
|
181
|
+
* @param columnName - Name of the column to change
|
|
182
|
+
* @param definition - New column definition
|
|
183
|
+
*/
|
|
184
|
+
async changeColumn(tableName, columnName, definition, _options) {
|
|
185
|
+
const columnDef = {
|
|
186
|
+
type: typeof definition.type === 'string'
|
|
187
|
+
? definition.type
|
|
188
|
+
: definition.type,
|
|
189
|
+
allowNull: definition.allowNull,
|
|
190
|
+
defaultValue: definition.defaultValue,
|
|
191
|
+
primaryKey: definition.primaryKey,
|
|
192
|
+
autoIncrement: definition.autoIncrement,
|
|
193
|
+
unique: definition.unique,
|
|
194
|
+
references: definition.references
|
|
195
|
+
? {
|
|
196
|
+
table: definition.references.model,
|
|
197
|
+
field: definition.references.key || 'id',
|
|
198
|
+
onDelete: definition.references.onDelete,
|
|
199
|
+
onUpdate: definition.references.onUpdate,
|
|
200
|
+
}
|
|
201
|
+
: undefined,
|
|
202
|
+
comment: definition.comment,
|
|
203
|
+
};
|
|
204
|
+
await this.dialect.changeColumn(tableName, columnName, columnDef);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Rename a column
|
|
208
|
+
* @param tableName - Name of the table
|
|
209
|
+
* @param oldColumnName - Current column name
|
|
210
|
+
* @param newColumnName - New column name
|
|
211
|
+
*/
|
|
212
|
+
async renameColumn(tableName, oldColumnName, newColumnName, _options) {
|
|
213
|
+
// Get current column definition
|
|
214
|
+
const tableDescription = await this.dialect.describeTable(tableName);
|
|
215
|
+
const columnDef = tableDescription[oldColumnName];
|
|
216
|
+
if (!columnDef) {
|
|
217
|
+
throw new Error(`Column ${oldColumnName} does not exist in table ${tableName}`);
|
|
218
|
+
}
|
|
219
|
+
// Add new column with new name
|
|
220
|
+
await this.dialect.addColumn(tableName, newColumnName, {
|
|
221
|
+
type: columnDef.type,
|
|
222
|
+
allowNull: columnDef.allowNull,
|
|
223
|
+
defaultValue: columnDef.defaultValue,
|
|
224
|
+
primaryKey: columnDef.primaryKey,
|
|
225
|
+
autoIncrement: columnDef.autoIncrement,
|
|
226
|
+
});
|
|
227
|
+
// Copy data from old column to new
|
|
228
|
+
const quotedTable = this.dialect.quoteTable(tableName);
|
|
229
|
+
const quotedOldColumn = this.dialect.quoteIdentifier(oldColumnName);
|
|
230
|
+
const quotedNewColumn = this.dialect.quoteIdentifier(newColumnName);
|
|
231
|
+
await this.dialect.query(`UPDATE ${quotedTable} SET ${quotedNewColumn} = ${quotedOldColumn}`, {
|
|
232
|
+
raw: true,
|
|
233
|
+
});
|
|
234
|
+
// Remove old column
|
|
235
|
+
await this.dialect.removeColumn(tableName, oldColumnName);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Add an index to a table
|
|
239
|
+
* @param tableName - Name of the table
|
|
240
|
+
* @param indexName - Name of the index
|
|
241
|
+
* @param fields - Fields to include in the index
|
|
242
|
+
* @param options - Index options
|
|
243
|
+
*/
|
|
244
|
+
async addIndex(tableName, indexNameOrFields, fieldsOrOptions, options) {
|
|
245
|
+
let indexName;
|
|
246
|
+
let fields;
|
|
247
|
+
let opts;
|
|
248
|
+
if (Array.isArray(indexNameOrFields)) {
|
|
249
|
+
// Called as (tableName, fields, options?)
|
|
250
|
+
fields = indexNameOrFields;
|
|
251
|
+
opts = fieldsOrOptions;
|
|
252
|
+
indexName = opts?.name || `${tableName}_${fields.join('_')}_idx`;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
// Called as (tableName, indexName, fields, options?)
|
|
256
|
+
indexName = indexNameOrFields;
|
|
257
|
+
fields = fieldsOrOptions || [];
|
|
258
|
+
opts = options;
|
|
259
|
+
}
|
|
260
|
+
const fieldNames = fields.map((f) => (typeof f === 'string' ? f : f.name));
|
|
261
|
+
const indexOptions = {
|
|
262
|
+
unique: opts?.unique,
|
|
263
|
+
type: opts?.type,
|
|
264
|
+
using: opts?.using,
|
|
265
|
+
where: opts?.where,
|
|
266
|
+
expression: opts?.expression,
|
|
267
|
+
include: opts?.include,
|
|
268
|
+
};
|
|
269
|
+
await this.dialect.addIndex(tableName, indexName, fieldNames, indexOptions);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Remove an index from a table
|
|
273
|
+
* @param tableName - Name of the table
|
|
274
|
+
* @param indexName - Name of the index to remove
|
|
275
|
+
*/
|
|
276
|
+
async removeIndex(tableName, indexName, _options) {
|
|
277
|
+
await this.dialect.removeIndex(tableName, indexName);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Show all indexes for a table
|
|
281
|
+
* @param tableName - Name of the table
|
|
282
|
+
*/
|
|
283
|
+
async showIndexes(tableName) {
|
|
284
|
+
const indexes = [];
|
|
285
|
+
if (this.dialect.name === 'sqlite') {
|
|
286
|
+
const sql = `SELECT name, sql FROM sqlite_master WHERE type='index' AND tbl_name='${tableName}'`;
|
|
287
|
+
const result = await this.dialect.query(sql, { raw: true });
|
|
288
|
+
for (const row of result.rows) {
|
|
289
|
+
if (!row.name)
|
|
290
|
+
continue;
|
|
291
|
+
const isUnique = row.sql ? /CREATE\s+UNIQUE\s+INDEX/i.test(row.sql) : false;
|
|
292
|
+
// Parse field names from the SQL if available
|
|
293
|
+
const fieldsMatch = row.sql ? row.sql.match(/\(([^)]+)\)/) : null;
|
|
294
|
+
const fields = fieldsMatch
|
|
295
|
+
? fieldsMatch[1].split(',').map((f) => f.trim().replace(/^["'`]|["'`]$/g, ''))
|
|
296
|
+
: [];
|
|
297
|
+
indexes.push({ name: row.name, fields, unique: isUnique });
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
const sql = `SHOW INDEX FROM ${this.dialect.quoteTable(tableName)}`;
|
|
302
|
+
const result = await this.dialect.query(sql, { raw: true });
|
|
303
|
+
for (const row of result.rows) {
|
|
304
|
+
const existingIdx = indexes.find((i) => i.name === row.Key_name);
|
|
305
|
+
if (existingIdx) {
|
|
306
|
+
existingIdx.fields.push(row.Column_name);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
indexes.push({
|
|
310
|
+
name: row.Key_name,
|
|
311
|
+
fields: [row.Column_name],
|
|
312
|
+
unique: row.Non_unique === 0,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return indexes;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Add a constraint to a table
|
|
321
|
+
* @param tableName - Name of the table
|
|
322
|
+
* @param constraintName - Name of the constraint
|
|
323
|
+
* @param constraint - Constraint definition
|
|
324
|
+
*/
|
|
325
|
+
async addConstraint(tableName, constraintNameOrOptions, constraintOrOptions, _options) {
|
|
326
|
+
let constraintName;
|
|
327
|
+
let constraint;
|
|
328
|
+
if (typeof constraintNameOrOptions === 'object') {
|
|
329
|
+
// Called as (tableName, { type, fields, name, ... })
|
|
330
|
+
constraint = constraintNameOrOptions;
|
|
331
|
+
constraintName = constraintNameOrOptions.name || `${tableName}_constraint`;
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
// Called as (tableName, constraintName, constraint, options?)
|
|
335
|
+
constraintName = constraintNameOrOptions;
|
|
336
|
+
constraint = constraintOrOptions;
|
|
337
|
+
}
|
|
338
|
+
const quotedTable = this.dialect.quoteTable(tableName);
|
|
339
|
+
const isSQLite = this.dialect.name === 'sqlite';
|
|
340
|
+
let sql = '';
|
|
341
|
+
switch (constraint.type) {
|
|
342
|
+
case 'PRIMARY KEY':
|
|
343
|
+
if (isSQLite)
|
|
344
|
+
return; // SQLite doesn't support ADD CONSTRAINT after table creation
|
|
345
|
+
const pkFields = constraint.fields?.map((f) => this.dialect.quoteIdentifier(f)).join(', ') || '';
|
|
346
|
+
sql = `ALTER TABLE ${quotedTable} ADD CONSTRAINT ${this.dialect.quoteIdentifier(constraintName)} PRIMARY KEY (${pkFields})`;
|
|
347
|
+
break;
|
|
348
|
+
case 'UNIQUE':
|
|
349
|
+
if (isSQLite) {
|
|
350
|
+
// SQLite: use CREATE UNIQUE INDEX as an equivalent
|
|
351
|
+
const uFields = constraint.fields?.map((f) => this.dialect.quoteIdentifier(f)).join(', ') || '';
|
|
352
|
+
sql = `CREATE UNIQUE INDEX IF NOT EXISTS ${this.dialect.quoteIdentifier(constraintName)} ON ${quotedTable} (${uFields})`;
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
const uniqueFields = constraint.fields?.map((f) => this.dialect.quoteIdentifier(f)).join(', ') || '';
|
|
356
|
+
sql = `ALTER TABLE ${quotedTable} ADD CONSTRAINT ${this.dialect.quoteIdentifier(constraintName)} UNIQUE (${uniqueFields})`;
|
|
357
|
+
}
|
|
358
|
+
break;
|
|
359
|
+
case 'FOREIGN KEY':
|
|
360
|
+
if (isSQLite)
|
|
361
|
+
return; // SQLite doesn't support ADD CONSTRAINT ... FOREIGN KEY after creation
|
|
362
|
+
const fkFields = constraint.fields?.map((f) => this.dialect.quoteIdentifier(f)).join(', ') || '';
|
|
363
|
+
const refTable = this.dialect.quoteTable(constraint.references?.table || '');
|
|
364
|
+
const refFieldList = constraint.references?.field
|
|
365
|
+
? [this.dialect.quoteIdentifier(constraint.references.field)]
|
|
366
|
+
: (constraint.references?.fields || []).map((f) => this.dialect.quoteIdentifier(f));
|
|
367
|
+
const refFields = refFieldList.join(', ');
|
|
368
|
+
sql = `ALTER TABLE ${quotedTable} ADD CONSTRAINT ${this.dialect.quoteIdentifier(constraintName)} FOREIGN KEY (${fkFields}) REFERENCES ${refTable}(${refFields})`;
|
|
369
|
+
if (constraint.onDelete) {
|
|
370
|
+
sql += ` ON DELETE ${constraint.onDelete}`;
|
|
371
|
+
}
|
|
372
|
+
if (constraint.onUpdate) {
|
|
373
|
+
sql += ` ON UPDATE ${constraint.onUpdate}`;
|
|
374
|
+
}
|
|
375
|
+
break;
|
|
376
|
+
case 'CHECK':
|
|
377
|
+
if (isSQLite)
|
|
378
|
+
return; // SQLite doesn't support ADD CONSTRAINT CHECK after creation
|
|
379
|
+
sql = `ALTER TABLE ${quotedTable} ADD CONSTRAINT ${this.dialect.quoteIdentifier(constraintName)} CHECK (${constraint.where || '1=1'})`;
|
|
380
|
+
break;
|
|
381
|
+
default:
|
|
382
|
+
throw new Error(`Unknown constraint type: ${constraint.type}`);
|
|
383
|
+
}
|
|
384
|
+
if (sql)
|
|
385
|
+
await this.dialect.query(sql, { raw: true });
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Remove a constraint from a table
|
|
389
|
+
* @param tableName - Name of the table
|
|
390
|
+
* @param constraintName - Name of the constraint to remove
|
|
391
|
+
*/
|
|
392
|
+
async removeConstraint(tableName, constraintName, _typeOrOptions) {
|
|
393
|
+
const isSQLite = this.dialect.name === 'sqlite';
|
|
394
|
+
if (isSQLite) {
|
|
395
|
+
// SQLite: constraint was likely added as an index, try to drop the index
|
|
396
|
+
try {
|
|
397
|
+
const sql = `DROP INDEX IF EXISTS ${this.dialect.quoteIdentifier(constraintName)}`;
|
|
398
|
+
await this.dialect.query(sql, { raw: true });
|
|
399
|
+
}
|
|
400
|
+
catch {
|
|
401
|
+
// Ignore - may not exist as an index
|
|
402
|
+
}
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
const quotedTable = this.dialect.quoteTable(tableName);
|
|
406
|
+
const sql = `ALTER TABLE ${quotedTable} DROP CONSTRAINT ${this.dialect.quoteIdentifier(constraintName)}`;
|
|
407
|
+
await this.dialect.query(sql, { raw: true });
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Check if an index exists on a table
|
|
411
|
+
*/
|
|
412
|
+
async indexExists(tableName, indexName) {
|
|
413
|
+
const indexes = await this.showIndexes(tableName);
|
|
414
|
+
return indexes.some((idx) => idx.name === indexName);
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Bulk insert records
|
|
418
|
+
* @param tableName - Name of the table
|
|
419
|
+
* @param records - Records to insert
|
|
420
|
+
* @param options - Insert options
|
|
421
|
+
*/
|
|
422
|
+
async bulkInsert(tableName, records, _options) {
|
|
423
|
+
if (records.length === 0) {
|
|
424
|
+
return 0;
|
|
425
|
+
}
|
|
426
|
+
const columns = Object.keys(records[0]);
|
|
427
|
+
const quotedTable = this.dialect.quoteTable(tableName);
|
|
428
|
+
const quotedColumns = columns.map((c) => this.dialect.quoteIdentifier(c)).join(', ');
|
|
429
|
+
let totalInserted = 0;
|
|
430
|
+
for (const record of records) {
|
|
431
|
+
const values = columns.map((col) => this.dialect.escape(record[col])).join(', ');
|
|
432
|
+
const sql = `INSERT INTO ${quotedTable} (${quotedColumns}) VALUES (${values})`;
|
|
433
|
+
const result = await this.dialect.query(sql, { raw: true });
|
|
434
|
+
totalInserted += result.rowCount;
|
|
435
|
+
}
|
|
436
|
+
return totalInserted;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Bulk update records
|
|
440
|
+
* @param tableName - Name of the table
|
|
441
|
+
* @param values - Values to update
|
|
442
|
+
* @param where - Where clause
|
|
443
|
+
* @param options - Update options
|
|
444
|
+
*/
|
|
445
|
+
async bulkUpdate(tableName, values, where, _options) {
|
|
446
|
+
const quotedTable = this.dialect.quoteTable(tableName);
|
|
447
|
+
const setClauses = Object.entries(values)
|
|
448
|
+
.map(([key, value]) => `${this.dialect.quoteIdentifier(key)} = ${this.dialect.escape(value)}`)
|
|
449
|
+
.join(', ');
|
|
450
|
+
const { sql, values: whereValues } = this.dialect.buildWhereClause(where);
|
|
451
|
+
const fullSql = this.dialect.replaceReplacements(`UPDATE ${quotedTable} SET ${setClauses} WHERE ${sql}`, whereValues);
|
|
452
|
+
const result = await this.dialect.query(fullSql, { raw: true });
|
|
453
|
+
return result.rowCount;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Bulk delete records
|
|
457
|
+
* @param tableName - Name of the table
|
|
458
|
+
* @param where - Where clause
|
|
459
|
+
* @param options - Delete options
|
|
460
|
+
*/
|
|
461
|
+
async bulkDelete(tableName, where, _options) {
|
|
462
|
+
const quotedTable = this.dialect.quoteTable(tableName);
|
|
463
|
+
const { sql, values: whereVals } = this.dialect.buildWhereClause(where);
|
|
464
|
+
const fullSql = this.dialect.replaceReplacements(`DELETE FROM ${quotedTable} WHERE ${sql}`, whereVals);
|
|
465
|
+
const result = await this.dialect.query(fullSql, { raw: true });
|
|
466
|
+
return result.rowCount;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Describe a table (get column information)
|
|
470
|
+
* @param tableName - Name of the table
|
|
471
|
+
*/
|
|
472
|
+
async describeTable(tableName) {
|
|
473
|
+
return this.dialect.describeTable(tableName);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Show all tables in the database
|
|
477
|
+
*/
|
|
478
|
+
async showTables() {
|
|
479
|
+
return this.dialect.showTables();
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Check if a table exists
|
|
483
|
+
* @param tableName - Name of the table
|
|
484
|
+
*/
|
|
485
|
+
async tableExists(tableName) {
|
|
486
|
+
const tables = await this.dialect.showTables();
|
|
487
|
+
return tables.includes(tableName);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Get all table names with schema (for PostgreSQL, MySQL, etc.)
|
|
491
|
+
* @param _schema - Optional schema name
|
|
492
|
+
*/
|
|
493
|
+
async getTableNames(_schema) {
|
|
494
|
+
return this.dialect.showTables();
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Get foreign keys for a table
|
|
498
|
+
* @param tableName - Name of the table
|
|
499
|
+
*/
|
|
500
|
+
async getForeignKeysForTable(_tableName) {
|
|
501
|
+
// Simplified implementation - dialects can override
|
|
502
|
+
return [];
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Get constraints for a table
|
|
506
|
+
* @param tableName - Name of the table
|
|
507
|
+
*/
|
|
508
|
+
async getConstraints(_tableName) {
|
|
509
|
+
// Simplified implementation - dialects can override
|
|
510
|
+
return [];
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Create a database (for databases that support it)
|
|
514
|
+
* @param databaseName - Name of the database
|
|
515
|
+
*/
|
|
516
|
+
async createDatabase(_databaseName, _options) {
|
|
517
|
+
throw new Error('Creating databases is not supported by this dialect');
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Drop a database (for databases that support it)
|
|
521
|
+
* @param databaseName - Name of the database
|
|
522
|
+
*/
|
|
523
|
+
async dropDatabase(_databaseName, _options) {
|
|
524
|
+
throw new Error('Dropping databases is not supported by this dialect');
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Create a database view
|
|
528
|
+
* @param viewName - Name of the view to create
|
|
529
|
+
* @param query - The SELECT query for the view
|
|
530
|
+
* @param options - View options
|
|
531
|
+
*/
|
|
532
|
+
async createView(viewName, query, options) {
|
|
533
|
+
await this.dialect.createView(viewName, query, options);
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Drop a database view
|
|
537
|
+
* @param viewName - Name of the view to drop
|
|
538
|
+
* @param options - Drop options
|
|
539
|
+
*/
|
|
540
|
+
async dropView(viewName, options) {
|
|
541
|
+
await this.dialect.dropView(viewName, options);
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Show all views in the database
|
|
545
|
+
*/
|
|
546
|
+
async showViews() {
|
|
547
|
+
return this.dialect.showViews();
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Check if a view exists
|
|
551
|
+
* @param viewName - Name of the view
|
|
552
|
+
*/
|
|
553
|
+
async viewExists(viewName) {
|
|
554
|
+
const views = await this.dialect.showViews();
|
|
555
|
+
return views.includes(viewName);
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Create a materialized view
|
|
559
|
+
* @param options - Materialized view options
|
|
560
|
+
*/
|
|
561
|
+
async createMaterializedView(options) {
|
|
562
|
+
await this.dialect.createMaterializedView(options);
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Refresh a materialized view
|
|
566
|
+
* @param viewName - Name of the materialized view to refresh
|
|
567
|
+
* @param options - Refresh options
|
|
568
|
+
*/
|
|
569
|
+
async refreshMaterializedView(viewName, options) {
|
|
570
|
+
await this.dialect.refreshMaterializedView(viewName, options);
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Drop a materialized view
|
|
574
|
+
* @param viewName - Name of the materialized view to drop
|
|
575
|
+
* @param options - Drop options
|
|
576
|
+
*/
|
|
577
|
+
async dropMaterializedView(viewName, options) {
|
|
578
|
+
await this.dialect.dropMaterializedView(viewName, options);
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Check if a materialized view exists
|
|
582
|
+
* @param viewName - Name of the materialized view
|
|
583
|
+
*/
|
|
584
|
+
async materializedViewExists(viewName) {
|
|
585
|
+
return this.dialect.hasMaterializedView(viewName);
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Show all materialized views in the database
|
|
589
|
+
*/
|
|
590
|
+
async showMaterializedViews() {
|
|
591
|
+
return this.dialect.showMaterializedViews();
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Execute a raw query
|
|
595
|
+
* @param sql - The SQL query
|
|
596
|
+
* @param options - Query options
|
|
597
|
+
*/
|
|
598
|
+
async query(sql, options) {
|
|
599
|
+
return this.dialect.query(sql, { raw: options?.logging === true });
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Quote an identifier
|
|
603
|
+
* @param identifier - The identifier to quote
|
|
604
|
+
*/
|
|
605
|
+
quoteIdentifier(identifier) {
|
|
606
|
+
return this.dialect.quoteIdentifier(identifier);
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Escape a value
|
|
610
|
+
* @param value - The value to escape
|
|
611
|
+
*/
|
|
612
|
+
escape(value) {
|
|
613
|
+
return this.dialect.escape(value);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
exports.CreateQueryInterface = CreateQueryInterface;
|
|
617
|
+
/**
|
|
618
|
+
* Factory function to create a QueryInterface from a Prorm instance
|
|
619
|
+
*/
|
|
620
|
+
function createQueryInterface(dialect) {
|
|
621
|
+
return new CreateQueryInterface(dialect);
|
|
622
|
+
}
|