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

Function createEntities

tests/features/collection/partial-collections.test.ts:97–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95afterAll(() => orm.close(true));
96
97async function createEntities() {
98 const author1 = new Author('Author 1'); // no books
99 const author2 = new Author('Author 2'); // only 'Foo'
100 const author3 = new Author('Author 3'); // 'Foo' and 'Bar'
101 const author4 = new Author('Author 4'); // only 'Foo Bar'
102 const author5 = new Author('Author 5'); // only 'Foo'
103
104 const t1 = new BookTag('t1', true);
105 const t2 = new BookTag('t2', true);
106 const t3 = new BookTag('t3');
107 const t4 = new BookTag('t4');
108 const t5 = new BookTag('t5', true);
109
110 author2.books.add(new Book(author2, 'Foo 1', [t1, t5], true), new Book(author2, 'Foo 2', [t1, t3]));
111 author3.books.add(
112 new Book(author3, 'Foo 3', [t2]),
113 new Book(author3, 'Foo 4', [t4], true),
114 new Book(author3, 'Bar 1', [t2], true),
115 new Book(author3, 'Bar 2', [t2], true),
116 );
117 author4.books.add(new Book(author4, 'Foo Bar 1', [t1, t2], true), new Book(author4, 'Foo Bar 2', [t1, t2, t4]));
118 author5.books.add(new Book(author5, 'Foo', [t4, t5]));
119
120 await orm.em.fork().persist([author1, author2, author3, author4, author5]).flush();
121}
122
123const expected = [
124 {

Callers 1

Calls 4

addMethod · 0.80
forkMethod · 0.80
persistMethod · 0.65
flushMethod · 0.45

Tested by

no test coverage detected