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

Method capture

packages/cli/src/commands/CompileCommand.ts:90–126  ·  view source on GitHub ↗
(metadata: MetadataStorage, config: Configuration)

Source from the content-addressed store, hash-verified

88 }
89
90 static capture(metadata: MetadataStorage, config: Configuration) {
91 const captured: { key: string; contextKeys: string[]; code: string }[] = [];
92 const original = Utils.createFunction;
93 Utils.createFunction = (context, code, _compiledFunctions, key) => {
94 captured.push({ key: key!, contextKeys: [...context.keys()], code });
95 return original.call(Utils, context, code);
96 };
97
98 try {
99 const platform = config.getDriver().getPlatform();
100 const hydrator = new ObjectHydrator(metadata, platform, config);
101 const comparator = new EntityComparator(metadata, platform, config);
102
103 for (const meta of metadata) {
104 hydrator.getEntityHydrator(meta, 'full', false);
105 hydrator.getEntityHydrator(meta, 'full', true);
106 comparator.getEntityComparator(meta.class);
107 comparator.getSnapshotGenerator(meta.class);
108 comparator.getResultMapper(meta);
109
110 if (!meta.embeddable && !meta.virtual) {
111 hydrator.getEntityHydrator(meta, 'reference', false);
112 hydrator.getEntityHydrator(meta, 'reference', true);
113 }
114
115 if (meta.primaryKeys.length > 0) {
116 comparator.getPkGetter(meta);
117 comparator.getPkGetterConverted(meta);
118 comparator.getPkSerializer(meta);
119 }
120 }
121 } finally {
122 Utils.createFunction = original;
123 }
124
125 return captured;
126 }
127}

Callers 2

handlerMethod · 0.80

Calls 11

getEntityHydratorMethod · 0.95
getEntityComparatorMethod · 0.95
getSnapshotGeneratorMethod · 0.95
getResultMapperMethod · 0.95
getPkGetterMethod · 0.95
getPkGetterConvertedMethod · 0.95
getPkSerializerMethod · 0.95
pushMethod · 0.80
getPlatformMethod · 0.65
keysMethod · 0.45
getDriverMethod · 0.45

Tested by 1