Multiple data sources, databases, schemas and replication setup
Using multiple data sources
import { DataSource } from "typeorm"
const db1DataSource = new DataSource({
type: "mysql",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
database: "db1",
entities: [__dirname + "/entities/*{.js,.ts}"],
synchronize: true,
})
const db2DataSource = new DataSource({
type: "mysql",
host: "localhost",
port: 3306,
username: "root",
password: "admin",
database: "db2",
entities: [__dirname + "/entities/*{.js,.ts}"],
synchronize: true,
})Using multiple databases within a single data source
Using multiple schemas within a single data source
Replication
Explicitly selecting query destinations
Adjusting the default destination for reads
Supported drivers
Last updated