TypeORM supports multiple databases, including:
- MySQL / MariaDB: The most commonly used relational database
- PostgreSQL: Powerful open-source database
- SQLite: Lightweight embedded database
- Microsoft SQL Server: Microsoft's database system
- Oracle: Enterprise-level database
- MongoDB: NoSQL document database (through TypeORM's MongoDB support)
- CockroachDB: Distributed SQL database
Examples of configuring different databases:
typescript// MySQL new DataSource({ type: 'mysql', host: 'localhost', port: 3306, username: 'root', password: 'password', database: 'test' }); // PostgreSQL new DataSource({ type: 'postgres', host: 'localhost', port: 5432, username: 'postgres', password: 'password', database: 'test' }); // SQLite new DataSource({ type: 'sqlite', database: './database.sqlite' });
The advantage of TypeORM is its unified API, making it very easy to switch between different databases.