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

Method toJSON

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

Serializes the collection items to plain JSON objects. Returns an empty array if not initialized.

()

Source from the content-addressed store, hash-verified

225
226 /** Serializes the collection items to plain JSON objects. Returns an empty array if not initialized. */
227 toJSON<TT extends T>(): EntityDTO<TT>[] {
228 if (!this.isInitialized()) {
229 return [];
230 }
231
232 return this.toArray();
233 }
234
235 /** Adds one or more items to the collection, propagating the change to the inverse side. Returns the number of items added. */
236 add<TT extends T>(

Callers

nothing calls this directly

Calls 2

isInitializedMethod · 0.95
toArrayMethod · 0.95

Tested by

no test coverage detected