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

Method toArray

packages/core/src/entity/Collection.ts:571–577  ·  view source on GitHub ↗

Converts all items in the collection to plain DTO objects.

()

Source from the content-addressed store, hash-verified

569
570 /** Converts all items in the collection to plain DTO objects. */
571 toArray<TT extends T>(): EntityDTO<TT>[] {
572 if (this.#items.size === 0) {
573 return [];
574 }
575
576 return this.map(item => wrap(item as TT).toJSON());
577 }
578
579 /** Returns the primary key values (or a specific field) of all items in the collection. */
580 getIdentifiers<U extends IPrimaryKey = Primary<T> & IPrimaryKey>(field?: string | string[]): U[] {

Callers 1

toJSONMethod · 0.95

Calls 3

mapMethod · 0.95
wrapFunction · 0.70
toJSONMethod · 0.65

Tested by

no test coverage detected