MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / createEntities

Function createEntities

tests/features/partial-loading/GH5889.test.ts:46–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44}
45
46async function createEntities() {
47 const em = orm.em.fork();
48
49 for (let i = 0; i < 10; i++) {
50 const className = new ClassName();
51 className.foo = `CLSS${i}`;
52
53 em.persist(className);
54 }
55
56 await em.flush();
57
58 for (let i = 0; i < 50; i++) {
59 const product = new Product();
60
61 em.assign(product, {
62 className: getRandomBetween1And10(),
63 });
64
65 const subProduct = new SubProduct();
66
67 em.assign(subProduct, {
68 product,
69 });
70
71 em.persist(product);
72 em.persist(subProduct);
73 }
74
75 await em.flush();
76}
77
78let orm: MikroORM;
79

Callers 1

GH5889.test.tsFile · 0.70

Calls 5

getRandomBetween1And10Function · 0.85
forkMethod · 0.80
persistMethod · 0.65
assignMethod · 0.65
flushMethod · 0.45

Tested by

no test coverage detected