How to use the @loopback/repository.createHasManyRepositoryFactory function in @loopback/repository

To help you get started, we’ve selected a few @loopback/repository examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strongloop / loopback-next / packages / repository-tests / src / crud / relations / fixtures / repositories / customer.repository.ts View on Github external
constructor(
      db: juggler.DataSource,
      orderRepositoryGetter: Getter,
      addressRepositoryGetter: Getter,
    ) {
      super(Customer, db);
      const ordersMeta = this.entityClass.definition.relations['orders'];
      // create a has-many relation through this public method
      this.orders = createHasManyRepositoryFactory(
        ordersMeta as HasManyDefinition,
        orderRepositoryGetter,
      );

      const addressMeta = this.entityClass.definition.relations['address'];
      this.address = createHasOneRepositoryFactory(
        addressMeta as HasOneDefinition,
        addressRepositoryGetter,
      );
      const customersMeta = this.entityClass.definition.relations['customers'];
      this.customers = createHasManyRepositoryFactory(
        customersMeta as HasManyDefinition,
        Getter.fromValue(this),
      );
      const parentMeta = this.entityClass.definition.relations['parent'];
      this.parent = createBelongsToAccessor(
github strongloop / loopback-next / packages / repository-tests / src / crud / relations / fixtures / repositories / customer.repository.ts View on Github external
) {
      super(Customer, db);
      const ordersMeta = this.entityClass.definition.relations['orders'];
      // create a has-many relation through this public method
      this.orders = createHasManyRepositoryFactory(
        ordersMeta as HasManyDefinition,
        orderRepositoryGetter,
      );

      const addressMeta = this.entityClass.definition.relations['address'];
      this.address = createHasOneRepositoryFactory(
        addressMeta as HasOneDefinition,
        addressRepositoryGetter,
      );
      const customersMeta = this.entityClass.definition.relations['customers'];
      this.customers = createHasManyRepositoryFactory(
        customersMeta as HasManyDefinition,
        Getter.fromValue(this),
      );
      const parentMeta = this.entityClass.definition.relations['parent'];
      this.parent = createBelongsToAccessor(
        parentMeta as BelongsToDefinition,
        Getter.fromValue(this),
        this,
      );
    }
  };
github strongloop / loopback-next / packages / repository-tests / src / crud / relations / fixtures / repositories / shipment.repository.ts View on Github external
constructor(
      db: juggler.DataSource,
      orderRepositoryGetter: Getter,
    ) {
      super(Shipment, db);
      const ordersMeta = this.entityClass.definition.relations[
        'shipmentOrders'
      ];
      this.orders = createHasManyRepositoryFactory(
        ordersMeta as HasManyDefinition,
        orderRepositoryGetter,
      );
    }
  };