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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Malcolm Stone
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
# prorm
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@mstone6969/prorm)
|
|
4
|
+
[](https://www.npmjs.com/package/@mstone6969/prorm)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://gitlab.com/Malcolmston/prod-orm/-/pipelines)
|
|
8
|
+
|
|
9
|
+
A TypeScript ORM supporting multiple database dialects with full TypeScript support.
|
|
10
|
+
|
|
11
|
+
> Published on npm as **[`@mstone6969/prorm`](https://www.npmjs.com/package/@mstone6969/prorm)** — `npm install @mstone6969/prorm`
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Multi-database support**: 14 dialects — SQLite, MySQL, PostgreSQL, MariaDB, Oracle, MSSQL, CockroachDB, Amazon Redshift, IBM Db2, Snowflake, ClickHouse, DuckDB, SAP HANA, Google Cloud Spanner
|
|
16
|
+
- **TypeScript-first**: Full TypeScript support with decorators
|
|
17
|
+
- **CRUD operations**: Full query builder with associations, scopes, transactions
|
|
18
|
+
- **Migrations**: Database versioning and seeding
|
|
19
|
+
- **Hooks**: Lifecycle events for models
|
|
20
|
+
- **Validation**: Built-in and custom validators
|
|
21
|
+
- **Stored Procedures**: Create and call stored procedures (across supported dialects)
|
|
22
|
+
- **Triggers**: Database triggers with FOR EACH ROW and WHEN clauses (across supported dialects)
|
|
23
|
+
- **Sequences**: Sequence support across all dialects
|
|
24
|
+
- **Table Partitions**: RANGE, LIST, HASH partitioning (across supported dialects)
|
|
25
|
+
- **Partial Indexes**: Conditional indexes for MySQL, MariaDB, PostgreSQL, Oracle, MSSQL
|
|
26
|
+
- **Row-Level Security (RLS)**: PostgreSQL, Oracle VPD, MSSQL Security Policies
|
|
27
|
+
- **Materialized Views**: With FAST/COMPLETE refresh (PostgreSQL, Oracle)
|
|
28
|
+
- **Views**: Database views support
|
|
29
|
+
- **Full-Text Search**: SQLite FTS5 and PostgreSQL full-text search
|
|
30
|
+
- **JSON/JSONB**: Native JSON data type support
|
|
31
|
+
- **Spatial Data**: PostGIS support for PostgreSQL
|
|
32
|
+
- **Foreign Data Wrappers**: PostgreSQL FDW support
|
|
33
|
+
- **User Management**: Database users and privileges (PostgreSQL, Oracle, MSSQL)
|
|
34
|
+
- **Connection Pooling**: Efficient connection pool management
|
|
35
|
+
- **Query Optimization**: Prepared statements, query hints, caching
|
|
36
|
+
- **Audit Logging**: Built-in audit trail functionality
|
|
37
|
+
- **Polymorphic Associations**: Built-in helpers for polymorphic relationships
|
|
38
|
+
- **Self-referential Associations**: Tree structure support
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install ts-prorm-orm
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { Prorm, DataTypes } from 'ts-prorm-orm';
|
|
50
|
+
|
|
51
|
+
const prorm = new Prorm({
|
|
52
|
+
dialect: 'sqlite',
|
|
53
|
+
storage: ':memory:',
|
|
54
|
+
logging: console.log,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const User = prorm.define('User', {
|
|
58
|
+
name: DataTypes.STRING,
|
|
59
|
+
email: {
|
|
60
|
+
type: DataTypes.STRING,
|
|
61
|
+
validate: { isEmail: true },
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
await prorm.sync();
|
|
66
|
+
const user = await User.create({ name: 'John', email: 'john@example.com' });
|
|
67
|
+
console.log(user.toJSON());
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Database type coverage
|
|
71
|
+
|
|
72
|
+
prorm spans **22 database types, each with at least 5 supported engines** — 27
|
|
73
|
+
SQL dialects and 102 NoSQL/data stores (129 engines). Full taxonomy:
|
|
74
|
+
[`docs/database-types.md`](./docs/database-types.md).
|
|
75
|
+
|
|
76
|
+
| Type | Engines |
|
|
77
|
+
|------|---------|
|
|
78
|
+
| Relational (OLTP) | SQLite, MySQL, PostgreSQL, MariaDB, Oracle, MSSQL, Db2, Firebird, Turso |
|
|
79
|
+
| Warehouse / OLAP | ClickHouse, DuckDB, Redshift, Snowflake, Vertica, Greenplum, Exasol, HANA, Databricks, Trino |
|
|
80
|
+
| NewSQL / distributed | CockroachDB, YugabyteDB, TiDB, SingleStore, Spanner |
|
|
81
|
+
| Document | MongoDB, Couchbase, RethinkDB, SurrealDB, ArangoDB |
|
|
82
|
+
| Key-value | Redis, Memcached, etcd, DynamoDB, Aerospike |
|
|
83
|
+
| Wide-column | Cassandra, ScyllaDB, Keyspaces, HBase, Bigtable |
|
|
84
|
+
| Graph | Neo4j, ArangoDB, TigerGraph, Neptune, Dgraph |
|
|
85
|
+
| Vector | Pinecone, Milvus, Qdrant, Weaviate, Chroma |
|
|
86
|
+
| Time-series | InfluxDB, TimescaleDB, QuestDB, Prometheus, VictoriaMetrics |
|
|
87
|
+
| Search | Elasticsearch, OpenSearch, Meilisearch, Typesense, Solr |
|
|
88
|
+
| Object storage | S3, GCS, Azure Blob, MinIO, Cloudflare R2 |
|
|
89
|
+
| Streaming / queue | Kafka, NATS, RabbitMQ, Pulsar, Redpanda |
|
|
90
|
+
| In-memory data grid | Hazelcast, Ignite, GridGain, Infinispan, Geode, Coherence |
|
|
91
|
+
| Embedded storage engine | RocksDB, LevelDB, LMDB, UnQLite, NeDB, PouchDB |
|
|
92
|
+
| Ledger / immutable | QLDB, immudb, BigchainDB, TerminusDB, Fluree, ProvenDB |
|
|
93
|
+
| Multi-model | Cosmos DB, FaunaDB, OrientDB, MarkLogic, Firestore, RavenDB |
|
|
94
|
+
| RDF / triplestore | Fuseki, GraphDB, Stardog, Blazegraph, Virtuoso, AllegroGraph |
|
|
95
|
+
| Real-time OLAP | Druid, Pinot, StarRocks, Doris, Rockset, Materialize |
|
|
96
|
+
| Cloud pub/sub | Kinesis, Event Hubs, Pub/Sub, SQS, SNS, EventStoreDB |
|
|
97
|
+
| Edge / serverless KV | Cloudflare KV, Vercel KV, Upstash, Deno KV, Momento, DAX |
|
|
98
|
+
| Job / task queue | Beanstalkd, Gearman, BullMQ, NSQ, Resque, Bee-Queue |
|
|
99
|
+
| Log / observability | Loki, Splunk, Graylog, Sumo Logic, SigNoz, Papertrail |
|
|
100
|
+
|
|
101
|
+
## Supported Dialects
|
|
102
|
+
|
|
103
|
+
| Dialect | Status | Features |
|
|
104
|
+
|---------|--------|-----------|
|
|
105
|
+
| SQLite | Stable | FTS5, CTEs, Window Functions, UPSERT |
|
|
106
|
+
| MySQL | Stable | Stored procedures, triggers, partitions |
|
|
107
|
+
| PostgreSQL | Stable | RLS, FDW, PostGIS, Sequences, Extensions |
|
|
108
|
+
| MariaDB | Stable | Stored procedures, triggers, virtual columns |
|
|
109
|
+
| Oracle | Stable | Sequences, stored procedures |
|
|
110
|
+
| MSSQL | Stable | Sequences, stored procedures, RLS |
|
|
111
|
+
| CockroachDB | Stable | Distributed SQL, Postgres wire protocol/driver (`pg`), horizontal scalability |
|
|
112
|
+
| Amazon Redshift | Stable | Postgres-derived cloud data warehouse (`pg` driver), DISTKEY/SORTKEY instead of indexes, no FK/unique enforcement |
|
|
113
|
+
| IBM Db2 | Stable | `ibm_db` driver, FETCH FIRST pagination, MERGE upsert |
|
|
114
|
+
| Snowflake | Stable | `snowflake-sdk` driver, VARIANT semi-structured type, warehouse-based compute, no traditional indexes |
|
|
115
|
+
| ClickHouse | Stable | `@clickhouse/client` driver, columnar OLAP, requires ENGINE clause on CREATE TABLE, no multi-statement transactions, no FK enforcement |
|
|
116
|
+
| DuckDB | Stable | `duckdb` driver, embedded/in-process OLAP (file or `:memory:`, no server), window functions, recursive CTEs, `LIST`/`STRUCT`/`MAP` types, direct Parquet/CSV/JSON table functions |
|
|
117
|
+
| SAP HANA | Stable | `hdb` driver, in-memory column-store tables, native `UPSERT ... WITH PRIMARY KEY`, `LIMIT n OFFSET m` pagination requiring a sentinel `LIMIT` |
|
|
118
|
+
| Google Cloud Spanner | Stable | `@google-cloud/spanner` driver (GoogleSQL), globally distributed with externally-consistent transactions, Mutation API for bulk/blind writes, `INSERT OR UPDATE` upsert syntax |
|
|
119
|
+
|
|
120
|
+
### Extended dialects
|
|
121
|
+
|
|
122
|
+
Twelve additional dialects subclass the nearest wire-compatible base dialect and
|
|
123
|
+
override the grammar / type-mapping that genuinely differs, reusing the base's
|
|
124
|
+
driver. Each has a dedicated page under [`docs/dialects/`](./docs/dialects/) and
|
|
125
|
+
a connection-free SQL-generation test suite (`tests/dialects/<name>*.test.ts`).
|
|
126
|
+
|
|
127
|
+
| Dialect | Base (driver) | Key differences |
|
|
128
|
+
|---------|---------------|-----------------|
|
|
129
|
+
| [TiDB](./docs/dialects/tidb.md) | MySQL (`mysql2`) | `AUTO_RANDOM`, `SHARD_ROW_ID_BITS`/`PRE_SPLIT_REGIONS`, `SPLIT TABLE` |
|
|
130
|
+
| [SingleStore](./docs/dialects/singlestore.md) | MySQL (`mysql2`) | `SHARD KEY`/`SORT KEY`, ROWSTORE/columnstore, REFERENCE tables, FK omitted |
|
|
131
|
+
| [Databricks](./docs/dialects/databricks.md) | MySQL (`mysql2`) | `USING DELTA`, `MERGE INTO` upsert, Spark types, `GENERATED ALWAYS AS IDENTITY` |
|
|
132
|
+
| [YugabyteDB](./docs/dialects/yugabytedb.md) | PostgreSQL (`pg`) | `SPLIT INTO TABLETS`, colocation, `HASH` primary keys, tablegroups |
|
|
133
|
+
| [TimescaleDB](./docs/dialects/timescaledb.md) | PostgreSQL (`pg`) | `create_hypertable`, compression/retention policies, continuous aggregates |
|
|
134
|
+
| [Greenplum](./docs/dialects/greenplum.md) | PostgreSQL (`pg`) | `DISTRIBUTED BY`, append-optimized storage, external tables, staging-table upsert |
|
|
135
|
+
| [Vertica](./docs/dialects/vertica.md) | PostgreSQL (`pg`) | `ORDER BY`/`SEGMENTED BY`, projections, `IDENTITY`, `LONG VARCHAR` |
|
|
136
|
+
| [Trino](./docs/dialects/trino.md) | PostgreSQL (`pg`) | `catalog.schema.table`, `WITH (format=…)`, CTAS, no PK/FK/index |
|
|
137
|
+
| [Exasol](./docs/dialects/exasol.md) | PostgreSQL (`pg`) | `DISTRIBUTE BY`, `IDENTITY`, `IMPORT`/`EXPORT`, MERGE upsert |
|
|
138
|
+
| [QuestDB](./docs/dialects/questdb.md) | PostgreSQL (`pg`) | designated `TIMESTAMP`, `PARTITION BY`, `SYMBOL`, `DEDUP` |
|
|
139
|
+
| [CrateDB](./docs/dialects/cratedb.md) | PostgreSQL (`pg`) | `CLUSTERED`/`PARTITIONED`, `OBJECT`/`ARRAY` types |
|
|
140
|
+
| [Firebird](./docs/dialects/firebird.md) | PostgreSQL (`pg`) | `FIRST`/`SKIP` paging, `GENERATED … IDENTITY`, generators |
|
|
141
|
+
|
|
142
|
+
> These dialect layers are verified at the SQL-generation level (connection-free
|
|
143
|
+
> tests); end-to-end execution against a live server of each engine is not part
|
|
144
|
+
> of the automated suite. See each page's "verification status" section.
|
|
145
|
+
|
|
146
|
+
## Diagrams
|
|
147
|
+
|
|
148
|
+
The [`src/diagrams`](./docs/diagrams/README.md) module renders standalone SVG
|
|
149
|
+
diagrams from schema data — 15 generators (model card, ER, migration, UML class,
|
|
150
|
+
crow's-foot relational, sequence, state, dependency graph, data-dictionary,
|
|
151
|
+
index map, flowchart, tree, Chen-ER, package, gantt) built on a shared
|
|
152
|
+
DOM-backed SVG builder with light/dark themes and configurable accent colours.
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { ModelDiagram } from '@mstone6969/prorm';
|
|
156
|
+
|
|
157
|
+
new ModelDiagram({
|
|
158
|
+
name: 'User',
|
|
159
|
+
fields: { id: { type: 'INTEGER', primaryKey: true }, email: { type: 'VARCHAR(255)', unique: true } },
|
|
160
|
+
theme: 'dark',
|
|
161
|
+
color: 'emerald',
|
|
162
|
+
}).save('./diagrams/User.svg');
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
See the [diagram module guide](./docs/diagrams/README.md) for every generator.
|
|
166
|
+
|
|
167
|
+
## NoSQL Stores
|
|
168
|
+
|
|
169
|
+
NoSQL engines don't share the SQL-shaped `Dialect` interface used above (no `query(sql)`, no identifier escaping, no DDL). Instead, each is its own store class under `src/nosql/<name>/`, exposing the operations that engine actually supports — see each store's README for full details.
|
|
170
|
+
|
|
171
|
+
| Store | Status | Features |
|
|
172
|
+
|-------|--------|-----------|
|
|
173
|
+
| MongoDB | Stable | `mongodb` driver, document CRUD, filters, aggregation pipeline, indexes, multi-document transactions (requires replica set) |
|
|
174
|
+
| Redis | Stable | `ioredis` driver, string/hash/list/set/sorted-set commands, pub/sub, pipelining/`MULTI`, no query language |
|
|
175
|
+
| Amazon DynamoDB | Stable | `@aws-sdk/client-dynamodb` + `@aws-sdk/lib-dynamodb`, partition/sort-key CRUD, Query/Scan, batch and transactional writes, no arbitrary queries |
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
import { MongoStore, RedisStore, DynamoDbStore } from '@mstone6969/prorm';
|
|
179
|
+
|
|
180
|
+
const mongo = new MongoStore({ uri: 'mongodb://localhost:27017', database: 'app' });
|
|
181
|
+
await mongo.connect();
|
|
182
|
+
await mongo.collection('users').insertOne({ name: 'Ada' });
|
|
183
|
+
|
|
184
|
+
const redis = new RedisStore({ host: 'localhost', port: 6379 });
|
|
185
|
+
await redis.connect();
|
|
186
|
+
await redis.set('session:1', 'active', { ex: 3600 });
|
|
187
|
+
|
|
188
|
+
const dynamo = new DynamoDbStore({ region: 'us-east-1' });
|
|
189
|
+
await dynamo.connect();
|
|
190
|
+
await dynamo.putItem('Users', { id: '1', name: 'Ada' });
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Object storage, streaming & additional stores
|
|
194
|
+
|
|
195
|
+
Twelve more adapters cover object storage, streaming/queues, wide-column,
|
|
196
|
+
document, cache, and search engines. Each **lazy-loads** its driver (none is a
|
|
197
|
+
hard dependency) and accepts an **injected client**, so it can be used and
|
|
198
|
+
unit-tested without the driver installed. Full pages under
|
|
199
|
+
[`docs/stores/`](./docs/stores/README.md).
|
|
200
|
+
|
|
201
|
+
| Store | Driver | Kind |
|
|
202
|
+
|-------|--------|------|
|
|
203
|
+
| [S3Store](./docs/stores/s3.md) | `@aws-sdk/client-s3` | Amazon S3 object storage |
|
|
204
|
+
| [GCSStore](./docs/stores/gcs.md) | `@google-cloud/storage` | Google Cloud Storage |
|
|
205
|
+
| [AzureBlobStore](./docs/stores/azure-blob.md) | `@azure/storage-blob` | Azure Blob Storage |
|
|
206
|
+
| [KafkaStore](./docs/stores/kafka.md) | `kafkajs` | Apache Kafka streaming |
|
|
207
|
+
| [NatsStore](./docs/stores/nats.md) | `nats` | NATS + JetStream KV |
|
|
208
|
+
| [RabbitMQStore](./docs/stores/rabbitmq.md) | `amqplib` | RabbitMQ / AMQP |
|
|
209
|
+
| [CassandraStore](./docs/stores/cassandra.md) | `cassandra-driver` | Apache Cassandra (CQL) |
|
|
210
|
+
| [CouchbaseStore](./docs/stores/couchbase.md) | `couchbase` | Couchbase (N1QL) |
|
|
211
|
+
| [MemcachedStore](./docs/stores/memcached.md) | `memjs` | Memcached cache |
|
|
212
|
+
| [SurrealStore](./docs/stores/surrealdb.md) | `surrealdb` | SurrealDB multi-model |
|
|
213
|
+
| [OpenSearchStore](./docs/stores/opensearch.md) | `@opensearch-project/opensearch` | OpenSearch |
|
|
214
|
+
| [RethinkDBStore](./docs/stores/rethinkdb.md) | `rethinkdb-ts` | RethinkDB |
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
import { S3Store, KafkaStore } from '@mstone6969/prorm';
|
|
218
|
+
|
|
219
|
+
const s3 = new S3Store({ region: 'us-east-1' });
|
|
220
|
+
await s3.connect();
|
|
221
|
+
await s3.putObject('bucket', 'hello.txt', 'hi');
|
|
222
|
+
|
|
223
|
+
const kafka = new KafkaStore({ clientId: 'app', brokers: ['localhost:9092'] });
|
|
224
|
+
await kafka.connect();
|
|
225
|
+
await kafka.produce('events', [{ value: JSON.stringify({ hello: 'world' }) }]);
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Usage Examples by Dialect
|
|
229
|
+
|
|
230
|
+
### SQLite
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
import { Prorm, DataTypes } from 'ts-prorm-orm';
|
|
234
|
+
|
|
235
|
+
const prorm = new Prorm({
|
|
236
|
+
dialect: 'sqlite',
|
|
237
|
+
storage: './database.db',
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Define model with SQLite-specific features
|
|
241
|
+
const User = prorm.define('User', {
|
|
242
|
+
id: {
|
|
243
|
+
type: DataTypes.INTEGER,
|
|
244
|
+
primaryKey: true,
|
|
245
|
+
autoIncrement: true,
|
|
246
|
+
},
|
|
247
|
+
name: DataTypes.STRING,
|
|
248
|
+
email: DataTypes.STRING(255),
|
|
249
|
+
// SQLite supports virtual columns
|
|
250
|
+
fullName: {
|
|
251
|
+
type: DataTypes.VIRTUAL,
|
|
252
|
+
get() {
|
|
253
|
+
return `${this.name}`;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// Use FTS5 for full-text search
|
|
259
|
+
await prorm.query(`
|
|
260
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS users_fts USING fts5(
|
|
261
|
+
name, email, content='users', content_rowid='id'
|
|
262
|
+
)
|
|
263
|
+
`);
|
|
264
|
+
|
|
265
|
+
// Upsert (INSERT OR REPLACE)
|
|
266
|
+
await User.upsert({
|
|
267
|
+
id: 1,
|
|
268
|
+
name: 'John',
|
|
269
|
+
email: 'john@example.com'
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### MySQL
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
import { Prorm, DataTypes } from 'ts-prorm-orm';
|
|
277
|
+
|
|
278
|
+
const prorm = new Prorm({
|
|
279
|
+
dialect: 'mysql',
|
|
280
|
+
host: 'localhost',
|
|
281
|
+
port: 3306,
|
|
282
|
+
database: 'mydb',
|
|
283
|
+
username: 'root',
|
|
284
|
+
password: 'password',
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const User = prorm.define('User', {
|
|
288
|
+
id: {
|
|
289
|
+
type: DataTypes.INTEGER,
|
|
290
|
+
primaryKey: true,
|
|
291
|
+
autoIncrement: true,
|
|
292
|
+
},
|
|
293
|
+
name: DataTypes.STRING(100),
|
|
294
|
+
email: {
|
|
295
|
+
type: DataTypes.STRING(255),
|
|
296
|
+
unique: true,
|
|
297
|
+
},
|
|
298
|
+
// MySQL JSON column
|
|
299
|
+
preferences: DataTypes.JSON,
|
|
300
|
+
// MySQL enum
|
|
301
|
+
status: {
|
|
302
|
+
type: DataTypes.ENUM('active', 'inactive', 'pending'),
|
|
303
|
+
defaultValue: 'active',
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
// Create stored procedure
|
|
308
|
+
await prorm.query(`
|
|
309
|
+
CREATE PROCEDURE get_user_by_email(IN user_email VARCHAR(255))
|
|
310
|
+
BEGIN
|
|
311
|
+
SELECT * FROM users WHERE email = user_email;
|
|
312
|
+
END
|
|
313
|
+
`);
|
|
314
|
+
|
|
315
|
+
// Call stored procedure
|
|
316
|
+
await prorm.query('CALL get_user_by_email(?)', {
|
|
317
|
+
replacements: ['john@example.com']
|
|
318
|
+
});
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### PostgreSQL
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
import { Prorm, DataTypes } from 'ts-prorm-orm';
|
|
325
|
+
|
|
326
|
+
const prorm = new Prorm({
|
|
327
|
+
dialect: 'postgres',
|
|
328
|
+
host: 'localhost',
|
|
329
|
+
port: 5432,
|
|
330
|
+
database: 'mydb',
|
|
331
|
+
username: 'postgres',
|
|
332
|
+
password: 'password',
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const User = prorm.define('User', {
|
|
336
|
+
id: {
|
|
337
|
+
type: DataTypes.INTEGER,
|
|
338
|
+
primaryKey: true,
|
|
339
|
+
autoIncrement: true,
|
|
340
|
+
},
|
|
341
|
+
name: DataTypes.STRING(100),
|
|
342
|
+
email: {
|
|
343
|
+
type: DataTypes.STRING(255),
|
|
344
|
+
unique: true,
|
|
345
|
+
},
|
|
346
|
+
// PostgreSQL UUID
|
|
347
|
+
uuid: {
|
|
348
|
+
type: DataTypes.UUID,
|
|
349
|
+
defaultValue: DataTypes.UUIDV4,
|
|
350
|
+
},
|
|
351
|
+
// PostgreSQL JSONB
|
|
352
|
+
metadata: DataTypes.JSONB,
|
|
353
|
+
// PostgreSQL array
|
|
354
|
+
tags: DataTypes.ARRAY(DataTypes.STRING),
|
|
355
|
+
// PostgreSQL hstore
|
|
356
|
+
properties: DataTypes.HSTORE,
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
// Row-Level Security (RLS)
|
|
360
|
+
await prorm.query(`
|
|
361
|
+
ALTER TABLE users ENABLE ROW LEVEL SECURITY
|
|
362
|
+
`);
|
|
363
|
+
|
|
364
|
+
await prorm.query(`
|
|
365
|
+
CREATE POLICY users_policy ON users
|
|
366
|
+
USING (user_id = current_user_id())
|
|
367
|
+
`);
|
|
368
|
+
|
|
369
|
+
// Full-text search
|
|
370
|
+
await prorm.query(`
|
|
371
|
+
CREATE INDEX users_fts_idx ON users
|
|
372
|
+
USING GIN (to_tsvector('english', name || ' ' || email))
|
|
373
|
+
`);
|
|
374
|
+
|
|
375
|
+
// Sequence example
|
|
376
|
+
await prorm.query(`
|
|
377
|
+
CREATE SEQUENCE user_id_seq START WITH 1000
|
|
378
|
+
`);
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### MariaDB
|
|
382
|
+
|
|
383
|
+
```typescript
|
|
384
|
+
import { Prorm, DataTypes } from 'ts-prorm-orm';
|
|
385
|
+
|
|
386
|
+
const prorm = new Prorm({
|
|
387
|
+
dialect: 'mariadb',
|
|
388
|
+
host: 'localhost',
|
|
389
|
+
port: 3306,
|
|
390
|
+
database: 'mydb',
|
|
391
|
+
username: 'root',
|
|
392
|
+
password: 'password',
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
const Product = prorm.define('Product', {
|
|
396
|
+
id: {
|
|
397
|
+
type: DataTypes.INTEGER,
|
|
398
|
+
primaryKey: true,
|
|
399
|
+
autoIncrement: true,
|
|
400
|
+
},
|
|
401
|
+
name: DataTypes.STRING(200),
|
|
402
|
+
price: DataTypes.DECIMAL(10, 2),
|
|
403
|
+
// MariaDB virtual column
|
|
404
|
+
price_with_tax: {
|
|
405
|
+
type: DataTypes.VIRTUAL,
|
|
406
|
+
get() {
|
|
407
|
+
return parseFloat(this.price) * 1.2;
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
// MariaDB JSON
|
|
411
|
+
attributes: DataTypes.JSON,
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
// Stored procedure
|
|
415
|
+
await prorm.query(`
|
|
416
|
+
CREATE PROCEDURE get_products_by_price(IN min_price DECIMAL(10,2))
|
|
417
|
+
BEGIN
|
|
418
|
+
SELECT * FROM products WHERE price >= min_price;
|
|
419
|
+
END
|
|
420
|
+
`);
|
|
421
|
+
|
|
422
|
+
await prorm.query('CALL get_products_by_price(?)', {
|
|
423
|
+
replacements: [10.00]
|
|
424
|
+
});
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Oracle
|
|
428
|
+
|
|
429
|
+
```typescript
|
|
430
|
+
import { Prorm, DataTypes } from 'ts-prorm-orm';
|
|
431
|
+
|
|
432
|
+
const prorm = new Prorm({
|
|
433
|
+
dialect: 'oracle',
|
|
434
|
+
host: 'localhost',
|
|
435
|
+
port: 1521,
|
|
436
|
+
database: 'ORCL',
|
|
437
|
+
username: 'system',
|
|
438
|
+
password: 'password',
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
const Employee = prorm.define('Employee', {
|
|
442
|
+
id: {
|
|
443
|
+
type: DataTypes.INTEGER,
|
|
444
|
+
primaryKey: true,
|
|
445
|
+
autoIncrement: true,
|
|
446
|
+
},
|
|
447
|
+
name: DataTypes.STRING(100),
|
|
448
|
+
email: DataTypes.STRING(255),
|
|
449
|
+
// Oracle BLOB for binary data
|
|
450
|
+
resume: DataTypes.BLOB,
|
|
451
|
+
// Oracle CLOB for large text
|
|
452
|
+
description: DataTypes.TEXT,
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
// Oracle sequence
|
|
456
|
+
await prorm.query(`
|
|
457
|
+
CREATE SEQUENCE employee_seq START WITH 1000 INCREMENT BY 1
|
|
458
|
+
`);
|
|
459
|
+
|
|
460
|
+
// Stored procedure with OUT parameter
|
|
461
|
+
await prorm.query(`
|
|
462
|
+
CREATE OR REPLACE PROCEDURE get_employee_count(
|
|
463
|
+
p_count OUT NUMBER
|
|
464
|
+
) AS
|
|
465
|
+
BEGIN
|
|
466
|
+
SELECT COUNT(*) INTO p_count FROM employees;
|
|
467
|
+
END;
|
|
468
|
+
`);
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### MSSQL
|
|
472
|
+
|
|
473
|
+
```typescript
|
|
474
|
+
import { Prorm, DataTypes } from 'ts-prorm-orm';
|
|
475
|
+
|
|
476
|
+
const prorm = new Prorm({
|
|
477
|
+
dialect: 'mssql',
|
|
478
|
+
host: 'localhost',
|
|
479
|
+
port: 1433,
|
|
480
|
+
database: 'mydb',
|
|
481
|
+
username: 'sa',
|
|
482
|
+
password: 'password',
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
const Order = prorm.define('Order', {
|
|
486
|
+
id: {
|
|
487
|
+
type: DataTypes.INTEGER,
|
|
488
|
+
primaryKey: true,
|
|
489
|
+
autoIncrement: true,
|
|
490
|
+
},
|
|
491
|
+
customer_id: DataTypes.INTEGER,
|
|
492
|
+
total: DataTypes.DECIMAL(10, 2),
|
|
493
|
+
// MSSQL datetime2
|
|
494
|
+
order_date: DataTypes.DATE,
|
|
495
|
+
// MSSQL-specific geometry
|
|
496
|
+
location: DataTypes.GEOMETRY('POINT'),
|
|
497
|
+
// MSSQL XML
|
|
498
|
+
details: DataTypes.XML,
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
// MSSQL sequence
|
|
502
|
+
await prorm.query(`
|
|
503
|
+
CREATE SEQUENCE order_id_seq START WITH 1000 INCREMENT BY 1
|
|
504
|
+
`);
|
|
505
|
+
|
|
506
|
+
// Row-Level Security
|
|
507
|
+
await prorm.query(`
|
|
508
|
+
CREATE SECURITY POLICY SalesFilter
|
|
509
|
+
ADD FILTER PREDICATE dbo.fn_tenantAccessPredicate(TenantId)
|
|
510
|
+
ON dbo.Sales
|
|
511
|
+
`);
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
## CLI Commands
|
|
515
|
+
|
|
516
|
+
```bash
|
|
517
|
+
# Generate a model
|
|
518
|
+
npm run model:generate -- --name User --attributes name:string,email:string
|
|
519
|
+
|
|
520
|
+
# Run migrations
|
|
521
|
+
npm run model:create
|
|
522
|
+
|
|
523
|
+
# Generate ER diagram
|
|
524
|
+
npm run diagram:model
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
## Documentation
|
|
528
|
+
|
|
529
|
+
Full documentation is available in the `docs/` directory:
|
|
530
|
+
|
|
531
|
+
- [Getting Started](./docs/) - Main documentation entry point
|
|
532
|
+
- [Dialects](./docs/dialects/) - Database-specific documentation
|
|
533
|
+
- [SQLite](./docs/dialects/sqlite.md)
|
|
534
|
+
- [MySQL](./docs/dialects/mysql.md)
|
|
535
|
+
- [PostgreSQL](./docs/dialects/postgres.md)
|
|
536
|
+
- [MariaDB](./docs/dialects/mariadb.md)
|
|
537
|
+
- [Oracle](./docs/dialects/oracle.md)
|
|
538
|
+
- [MSSQL](./docs/dialects/mssql.md)
|
|
539
|
+
- [API Reference](./docs/api/) - API documentation
|
|
540
|
+
- [Models](./docs/api/models.md)
|
|
541
|
+
- [Query Builder](./docs/api/queries.md)
|
|
542
|
+
- [Hooks](./docs/api/hooks.md)
|
|
543
|
+
- [Associations](./docs/api/associations.md)
|
|
544
|
+
|
|
545
|
+
Additional documentation:
|
|
546
|
+
- [Models](./docs/MODELS.md) - Model definition
|
|
547
|
+
- [Migrations](./docs/MIGRATIONS.md) - Database migrations
|
|
548
|
+
- [Associations](./docs/ASSOCIATIONS.md) - Relationship types
|
|
549
|
+
- [Hooks](./docs/HOOKS.md) - Lifecycle hooks
|
|
550
|
+
- [Stored Procedures](./docs/STORED_PROCEDURES.md) - Advanced database features
|
|
551
|
+
- [Triggers](./docs/TRIGGERS.md) - Database triggers
|
|
552
|
+
|
|
553
|
+
### Architecture / Component Guides
|
|
554
|
+
|
|
555
|
+
In-depth, code-level reference docs for each major subsystem, living alongside the source under `src/`:
|
|
556
|
+
|
|
557
|
+
- [Dialects](src/dialects/README.md) - The `Dialect` interface and per-database (SQLite/MySQL/PostgreSQL/MariaDB/Oracle/MSSQL/CockroachDB/Redshift/Db2/Snowflake/ClickHouse/DuckDB/HANA/Spanner) implementations of connections, DDL, views, partitioning, RLS, and query building.
|
|
558
|
+
- [Models](src/models/README.md) - The model layer: attribute/data types, `prorm.define()`, associations, scopes, indexes/constraints, and the model registry.
|
|
559
|
+
- [Query Builders](src/query-builders/README.md) - Translates `where`/`order`/`limit`/`include` options into dialect-specific SQL strings and bound parameter values. Includes a typed SQL function-builder library (`src/query-builders/functions/**` - window functions, date/time, JSON paths, string/math functions, CASE expressions, cross-dialect aggregates, full-text search) usable via `import { ... } from 'ts-prorm-orm'`; see [SQL Functions](docs/query-features/queries.md#sql-functions) for worked examples.
|
|
560
|
+
- [Extension Catalog](src/extensions/README.md) - A discoverability reference (not executable code) of ~124 verified real extensions/plugins/licensed features across dialects, queryable via `findExtension()`/`listExtensionsForDialect()`/`listExtensionsByCategory()`/`searchExtensions()`.
|
|
561
|
+
- [Query Optimizers](src/query-optimizers/README.md) - Opt-in performance tooling (query hints, explain plans, slow-query logging, batch optimization, prepared-statement/result caching).
|
|
562
|
+
- [Migrations](src/migrations/README.md) - Migration files, the `Migrator`, `PrormMeta` history tracking, seeders, `QueryInterface`, and schema diffing (`src/schema/`).
|
|
563
|
+
- [Compliance](src/compliance/README.md) - GDPR/privacy/security tooling layered on the ORM core: DSAR workflows, right to erasure, consent tracking, and the composite `@Security` decorator.
|
|
564
|
+
- [Decorators](src/decorators/README.md) - TypeScript decorator API for defining models (`@Table`, `@Column`, etc.) plus a larger set of feature decorators for constraints, associations, and dialect-specific column types.
|
|
565
|
+
- [Connections, Transactions & Hooks](src/CONNECTIONS.md) - Connection pooling, connection/replica management, transactions, and the lifecycle hooks manager.
|
|
566
|
+
- [CLI Tooling](src/cli/README.md) - Reference for the multiple (non-unified) CLI entry points for model generation, migrations, seeding, and diagrams.
|
|
567
|
+
- [Utilities](src/UTILITIES.md) - Supporting modules: error hierarchy, validators, logging, audit logging, caching, diagram generation, streams, foreign-data helpers, and user management.
|
|
568
|
+
|
|
569
|
+
Online documentation: [GitLab Pages](https://malcolmston.gitlab.io/prod-orm)
|
|
570
|
+
|
|
571
|
+
## License
|
|
572
|
+
|
|
573
|
+
MIT
|