UNPKG

@thaumaturgy/zod

Version:

Thaumaturgy is a fixtures and seeding library for TypeScript.

27 lines (26 loc) 621 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Ref = void 0; const core_1 = require("@thaumaturgy/core"); const entity_name_1 = require("./entity-name"); /** * A reference to another entity. * * ### Examples * * ``` * Ref.to(User).through(user => user.id); * ``` */ class Ref { constructor(Entity) { this.Entity = Entity; } static to(Entity) { return new Ref(Entity); } through(mapping) { return new core_1.MappedRef({ C: this.Entity, name: (0, entity_name_1.extractEntityName)(this.Entity) }, mapping); } } exports.Ref = Ref;