-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
38 lines (31 loc) · 791 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { MikroORM, defineConfig } from "@mikro-orm/postgresql";
import { EntityA, EntityC } from "src/entities/Entities";
// BigIntType.prototype.ensureComparable = function (...vars: any[]) {
// return false;
// };
const run = async () => {
const orm = await MikroORM.init(
defineConfig({
dbName: "postgres",
host: "localhost",
port: 7432,
user: "postgres",
password: "example",
entities: [EntityA, EntityC],
migrations: {
path: "./dist/migrations",
pathTs: "./src/migrations",
},
debug: true,
allowGlobalContext: true,
})
);
const em = orm.em;
const c = await em.findAll(EntityC, { populate: ["a"] });
console.log(
c,
c.map((cc) => cc.a)
);
await orm.close(true);
};
run();