Skip to content

Supported databases ​

The protocol of the connection string picks the database. Install its driver next to the module.

DatabaseProtocolsDriverTested on
PostgreSQLpostgres://, postgresql://pg17
MySQLmysql://mysql28.4
MariaDBmariadb://mysql211.4
SQL Servermssql://, sqlserver://mssql2022
MongoDBmongodb://, mongodb+srv://mongodb8.0

Feature matrix ​

PostgreSQLMySQLMariaDBSQL ServerMongoDB
Queries, filters, ordering, pagination✅✅✅✅✅
Create, update, delete, upsert, batches✅✅✅✅✅
Relationsfrom foreign keysfrom foreign keysfrom foreign keysfrom foreign keysinferred from names and DBRefs
Composite keys✅✅✅✅—
Views (read-only)✅✅✅✅—
Transactions for hooks✅✅✅✅with a replica set
Schemaread from the catalogread from the catalogread from the catalogread from the cataloginferred from 100 sampled documents per collection

Every database runs the same integration tests and the same end-to-end GraphQL test in CI on every change.

Connection strings ​

Driver parameters in the URL are passed to the driver, e.g. ?sslmode=require on PostgreSQL or ?trustServerCertificate=true on SQL Server. Passwords with special characters must be URL-encoded.

TLS ​

The ssl option turns TLS on for any database:

ts
InverseModelModule.forRoot({
  url: process.env.DATABASE_URL!,
  ssl: true, // the driver's defaults
});

InverseModelModule.forRoot({
  url: process.env.DATABASE_URL!,
  ssl: {
    rejectUnauthorized: true,
    ca: process.env.DB_CA_CERT, // PEM contents, not file paths
    cert: process.env.DB_CLIENT_CERT,
    key: process.env.DB_CLIENT_KEY,
  },
});

rejectUnauthorized: false accepts self-signed or otherwise unverified server certificates; use it only for development.

Run them locally ​

The repository's compose.yaml starts every database with the blog sample loaded:

sh
docker compose up -d --wait postgres mysql mariadb sqlserver mongodb redis

The SQL Server image is published for amd64 only; on Apple silicon it needs Docker with Rosetta and at least 2 GB of memory.

Released under the MIT License.