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

Function asSnapshot

tests/defineEntity.test.ts:2454–2469  ·  view source on GitHub ↗
(value: EntityMetadata)

Source from the content-addressed store, hash-verified

2452type UnwrapReference<T extends Reference<any>> = T extends Reference<infer Value> ? Value : T;
2453
2454function asSnapshot(value: EntityMetadata): EntityMetadata {
2455 const snap = new EntityMetadata({ ...value });
2456 Object.defineProperty(snap, '_id', { writable: false, value: expect.any(Number) });
2457 snap.root = expect.any(Object);
2458 snap.class = expect.any(Function);
2459 for (const prop of Object.values(snap.properties)) {
2460 for (const [key, value] of Object.entries(prop)) {
2461 if (typeof value === 'function') {
2462 Object.defineProperty(prop, key, { value: expect.any(Function) });
2463 } else if (value && typeof value === 'object' && value instanceof Type) {
2464 Object.defineProperty(prop, key, { value: expect.any(value.constructor) });
2465 }
2466 }
2467 }
2468 return snap;
2469}

Callers 1

Calls 2

entriesMethod · 0.80
valuesMethod · 0.45

Tested by

no test coverage detected