I'm trying to connect to multiple databases from single connection using typeORM in javascript. There's a way doing it using typescript
import {Entity, PrimaryGeneratedColumn, Column} from "typeorm";
@Entity({ database: "secondDB" })
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
firstName: string;
@Column()
lastName: string;
}
I tried to replicate this in javascript like this:
const { EntitySchema } = require("typeorm");
const userSchema = {
name: "User",
database: "secondDB",
columns: {
id: {
primary: true,
type: "int",
generated: true
},
firstName: {
type: "text"
},
lastName: {
type: "text"
},
}
module.exports = new EntitySchema(userSchema);
This doesn't seem to switch databases, Is there an equivalent way of doing this in javascript. I'm connecting to a postgresDB