Created
May 4, 2020 07:58
-
-
Save joras/03bf07a7eb0ab0f7bc755f15b510b432 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createConnection, Connection, PrimaryColumn } from "typeorm"; | |
import { Entity, Column } from "typeorm"; | |
@Entity() | |
export class Test { | |
@PrimaryColumn("integer") | |
id!: string; | |
} | |
async function longQuery(connection: Connection) { | |
try { | |
console.log(await connection.query("SELECT pg_sleep(5)")); | |
} catch (e) { | |
console.error("caught ", e); | |
} | |
} | |
async function main() { | |
const connection = await createConnection({ | |
type: "postgres", | |
host: "localhost", | |
port: 5432, | |
username: "postgres", | |
password: "postgres", | |
database: "test", | |
entities: [Test], | |
synchronize: true, | |
poolErrorHandler: (err) => console.error("pool error: ", err), | |
logging: true, | |
extra: { | |
min: 1, | |
max: 1, | |
}, | |
}); | |
while (true) { | |
longQuery(connection); | |
} | |
} | |
main().catch((err) => { | |
console.error("main error", err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment