pg on 5432 and authenticates exactly like RDS forAuroraPostgresDialect extendsRdsPostgresDialect: IAM tokens, verified TLS against therds_superuser refusals and the extension allow-list are| Property | Value |
|---|---|
| Dialect name | aurorapostgres |
| Extends | RdsPostgresDialect |
| Driver | pg |
| Cloud SDK | @aws-sdk/rds-signer (IAM only, optional) |
| Default port | 5432 |
| Local runtime | none — hosted service only |
$ npm install ts-prorm-orm pg$ pnpm add ts-prorm-orm pg$ yarn add ts-prorm-orm pg$ bun add ts-prorm-orm pgpg is the same driver the rdspostgres dialect uses. Add @aws-sdk/rds-signer only for the token-based logins under Managed and cloud variants. pg-copy-streams is optional: only the features that need it load it.import { Prorm } from 'ts-prorm-orm';
export const db = new Prorm({
dialect: 'aurorapostgres',
host: 'app.cluster-abc123.us-east-1.rds.amazonaws.com',
database: 'app',
username: 'app_user',
password: process.env.DB_PASSWORD,
dialectOptions: {
caBundle: '/etc/ssl/rds/global-bundle.pem',
routeReads: true, // plain SELECTs go to the reader endpoint
},
});import { Prorm } from 'ts-prorm-orm';
export const db = new Prorm({
dialect: 'aurorapostgres',
url: 'aurorapostgres://app_user:secret@app.cluster-abc123.us-east-1.rds.amazonaws.com:5432/app',
dialectOptions: {
caBundle: '/etc/ssl/rds/global-bundle.pem',
routeReads: true, // plain SELECTs go to the reader endpoint
},
});host, port, database, username and password before the dialect is built; any of those passed alongside it wins.import { DataTypes } from 'ts-prorm-orm';
const User = db.define('User', {
id: { type: DataTypes.INTEGER(), primaryKey: true, autoIncrement: true },
email: { type: DataTypes.STRING(255), allowNull: false, unique: true },
name: { type: DataTypes.STRING(100) },
meta: { type: DataTypes.JSONB() },
});
await db.sync(); // CREATE TABLE — see Generated SQL belowmeta is JSONB, which the containment query below needs.import { Op } from 'ts-prorm-orm';
await User.create({ email: 'ada@example.com', name: 'Ada' });
const page = await User.findAll({
where: { name: { [Op.like]: 'A%' } },
order: [['id', 'ASC']],
limit: 20,
offset: 40,
});import { Prorm } from 'ts-prorm-orm';
export const db = new Prorm({
dialect: 'aurorapostgres',
host: 'app.cluster-abc123.us-east-1.rds.amazonaws.com',
database: 'app',
username: 'app_user',
password: process.env.DB_PASSWORD,
dialectOptions: {
caBundle: '/etc/ssl/rds/global-bundle.pem',
routeReads: true, // the reader pool signs its own token
},
});import { Prorm } from 'ts-prorm-orm';
export const db = new Prorm({
dialect: 'aurorapostgres',
host: 'app.cluster-abc123.us-east-1.rds.amazonaws.com',
database: 'app',
username: 'app_user', // granted rds_iam; no password
dialectOptions: {
iamAuth: { region: 'us-east-1' }, // or true: the default credential chain
caBundle: '/etc/ssl/rds/global-bundle.pem', // a token is only sent over verified TLS
routeReads: true, // the reader pool signs its own token
},
});@aws-sdk/rds-signer installed next to the driver.query(), captured with the driver stubbed out. The model layer inlines the values.db.sync() for the model in the Quick start:CREATE TABLEawait User.create({ email: 'ada@example.com', name: 'Ada' });
await User.update({ name: 'Grace' }, { where: { email: 'ada@example.com' } });
await User.destroy({ where: { id: 1 } });await User.upsert({ id: 1, email: 'ada@example.com', name: 'Ada Lovelace' });upsert() also reads the row by primary key before and after the write, to return the instance.await User.findAll({
where: { name: { [Op.like]: 'A%' } },
order: [['id', 'ASC']],
limit: 20,
offset: 40,
});meta column:import { Op } from 'ts-prorm-orm';
await User.findAll({ where: { meta: { [Op.contains]: { plan: 'pro' } } } });await db.transaction(async (t) => {
await User.create({ email: 'grace@example.com', name: 'Grace' }, { transaction: t });
// A nested transaction is a SAVEPOINT; its failure undoes only its own work.
await db
.transaction(async (sp) => {
await User.destroy({ where: { id: 1 }, transaction: sp });
throw new Error('keep the row');
}, { transaction: t })
.catch(() => {});
});SKIP LOCKED)lock with skipLocked inside a transaction:await db.transaction(async (t) => {
await User.findAll({ where: { name: 'Ada' }, lock: { level: 'UPDATE', skipLocked: true }, transaction: t });
});STRING → VARCHAR(255), auto-increment INTEGER → SERIAL, BOOLEAN → BOOLEAN, DATE → TIMESTAMP, UUID → UUID, JSON → JSON. The type comparison lines the major engines up side by side.| Endpoint | Name | Reaches |
|---|---|---|
| Cluster | <cluster>.cluster-<id>.<region>.rds.amazonaws.com | the writer, and the new writer after a failover |
| Reader | <cluster>.cluster-ro-<id>.<region>.rds.amazonaws.com | Aurora Replicas, load-balanced per connection |
| Instance / custom | anything else | one instance / a chosen set |
host to the cluster endpoint. The reader endpoint is derived from it.cluster- → .cluster-ro-), or pass readerEndpoint.dialectOptions: {
routeReads: true;
} // readerEndpoint derived from hostrouteReads, a second pool (a second AuroraPostgresDialect, with its ownquery() sends a statement there only when it is a single plain SELECT,FOR UPDATE/SHARE, no INTO, and no functionnextval, advisory locks, set_config, …).WITH is never routed. Everything else — writes, DDL, transactions, and any{ useWriter: true } — stays on the writer.useWriter: true. queryReader(sql) sends one query to therouteReads.readerReplicaConfig({ username, password, database }) returns aReplicaConnectionConfig for the ORM's ReplicaManager. It refuses IAMgetReplicaStatus().| Builder | SQL |
|---|---|
buildAuroraVersionQuery() / getAuroraVersion() | SELECT aurora_version() (e.g. 16.4.1) |
buildInstanceIdentifierQuery() | SELECT aurora_db_instance_identifier() |
buildReplicaStatusQuery() / getReplicaStatus() | aurora_replica_status() with role (MASTER_SESSION_ID = writer) and replica_lag_in_msec |
buildIsWriterQuery() | joins aurora_replica_status() to aurora_db_instance_identifier() |
buildGlobalDbStatusQuery() | SELECT * FROM aurora_global_db_status() |
buildGlobalDbInstanceStatusQuery() | SELECT * FROM aurora_global_db_instance_status() |
buildStatQuery(fn) | aurora_stat_system_waits, aurora_stat_wait_event, aurora_stat_wait_type, aurora_stat_memctx_usage |
buildSystemWaitsQuery() | system waits joined to wait type/event names |
buildBackendWaitsQuery(pid) | aurora_stat_backend_waits($1) with names |
buildWriteForwardConsistencySql(mode) | SET apg_write_forward.consistency_mode = 'SESSION' | 'EVENTUAL' | 'GLOBAL' | 'OFF' |
buildWriteForwardConsistencySql. DDL, COPY,LOCK, TRUNCATE, SAVEPOINT and SERIALIZABLE are not forwarded.aurora_stat_* functions not listed above.aurorapostgres → rdspostgres → postgres.aurorapostgres://, aurora-postgres://,aurorapostgresql://.AuroraPostgresDialect extends RdsPostgresDialect (rdspostgres) andObject.getOwnPropertyNames(AuroraPostgresDialect.prototype),| Area | Overridden |
|---|---|
| Connection and execution | connect, disconnect, query |
| DML builders | buildInstanceIdentifierQuery |
| Introspection | getAuroraVersion, getReplicaStatus, readerReplicaConfig |
| Other | buildAuroraVersionQuery, buildBackendWaitsQuery, buildGlobalDbInstanceStatusQuery, buildGlobalDbStatusQuery, buildIsWriterQuery, buildReplicaStatusQuery, buildStatQuery, buildSystemWaitsQuery, buildWriteForwardConsistencySql, queryReader |
capabilitiesOf() (src/transaction-support.ts),whereSupportOf() (src/query-builders/expression-render.ts),sqlObjectCapabilitiesOf() (src/sql-objects/capabilities.ts) and the| Capability | aurorapostgres |
|---|---|
| Transactions atomic | yes |
| Savepoints | yes |
| Isolation | up to SERIALIZABLE |
| Transaction modes | read-only yes; deferrable yes; constraint deferral yes |
| RETURNING | RETURNING on INSERT |
| Upsert | INSERT … ON CONFLICT (…) DO UPDATE |
| JSON column | JSON (JSONB → JSONB) |
| Vector column | VECTOR(3) |
| Array column | INTEGER[] |
| WHERE builder | 62 operator keys; $and/$or/$not; $exists: yes; $in subquery: yes; expression operands: yes |
| SQL objects | family postgres: triggers yes; procedures yes; functions multiStatement; materialized views native; sequences yes; enums named; RLS policy |
| Streaming | queryStream() present; LISTEN present; createExtension() present |