Skip to content

support lazy loading references for convenient recursive relationship definitions #18

@uladkasach

Description

@uladkasach

i.e., complete of branch https://github.com/uladkasach/schema-generator/tree/features/lazyRef

    it('should be possible to declare an entity with a recursive / hierarchial relationship', () => {
      const person: Entity = new Entity({
        name: 'person',
        properties: {
          birthday: prop.DATETIME(6),
          mother_id: prop.REFERENCES(() => person),
          father_id: prop.REFERENCES(() => person),
        },
        unique: ['birthday', 'mother_id', 'father_id'],
      });
    });

will need to defer evaluation of fn's until after entity is "initialized" - meaning we probably want an internal and external representation of "Entity":

  • internal must have properties defined completely
  • external expects properties to be defined w/ lazy load and completely

and then during the normalization step we simply cast each "external" entity into the internal entity, by "evaluating" all of its properties

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions