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

Function getCollections

tests/features/dataloader/dataloader.test.ts:231–250  ·  view source on GitHub ↗
(em: MikroORM['em'])

Source from the content-addressed store, hash-verified

229}
230
231async function getCollections(em: MikroORM['em']): Promise<Collection<any>[]> {
232 const authors = await em.find(Author, {}, { first: 3, orderBy: { id: QueryOrder.ASC } });
233 for (const author of authors) {
234 expect(author.books.isInitialized()).toBe(false);
235 expect(author.friends.isInitialized()).toBe(false);
236 }
237 const publishers = await em.find(Publisher, {}, { first: 2, orderBy: { id: QueryOrder.ASC } });
238 for (const publisher of publishers) {
239 expect(publisher.books.isInitialized()).toBe(false);
240 }
241 const chats = await em.find(Chat, {}, { first: 2 });
242 return [
243 ...authors.map(author => author.books),
244 ...publishers.map(publisher => publisher.books),
245 ...authors.map(author => author.buddies),
246 // ...authors.map(author => author.friends),
247 ...authors.map(author => author.ownedChats),
248 ...chats.map(chat => chat.messages),
249 ];
250}
251
252describe('Dataloader', () => {
253 let orm: MikroORM;

Callers 2

dataloader.test.tsFile · 0.85
getColsFunction · 0.85

Calls 3

findMethod · 0.65
isInitializedMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected