How to use the @loopback/repository.createBelongsToAccessor 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 / address.repository.ts View on Github external
constructor(
      db: juggler.DataSource,
      customerRepositoryGetter: Getter,
    ) {
      super(Address, db);
      // create a belongsto relation from this public method
      const customerMeta = this.entityClass.definition.relations['customer'];
      this.customer = createBelongsToAccessor(
        customerMeta as BelongsToDefinition,
        customerRepositoryGetter,
        this,
      );
    }
  };
github strongloop / loopback-next / packages / repository-tests / src / crud / relations / fixtures / repositories / order.repository.ts View on Github external
constructor(
      db: juggler.DataSource,
      customerRepositoryGetter: Getter,
      shipmentRepositoryGetter: Getter,
    ) {
      super(Order, db);

      const customerMeta = this.entityClass.definition.relations['customer'];
      this.customer = createBelongsToAccessor(
        customerMeta as BelongsToDefinition,
        customerRepositoryGetter,
        this,
      );

      const shipmentrMeta = this.entityClass.definition.relations['shipment'];
      this.shipment = createBelongsToAccessor(
        shipmentrMeta as BelongsToDefinition,
        shipmentRepositoryGetter,
        this,
      );
    }
  };
github strongloop / loopback-next / packages / repository-tests / src / crud / relations / acceptance / belongs-to.relation.acceptance.ts View on Github external
function givenAccessor() {
      findCustomerOfOrder = createBelongsToAccessor(
        Order.definition.relations.customer as BelongsToDefinition,
        Getter.fromValue(customerRepo),
        orderRepo,
      );
    }
  });
github strongloop / loopback-next / packages / repository-tests / src / crud / relations / fixtures / repositories / customer.repository.ts View on Github external
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 / order.repository.ts View on Github external
constructor(
      db: juggler.DataSource,
      customerRepositoryGetter: Getter,
      shipmentRepositoryGetter: Getter,
    ) {
      super(Order, db);

      const customerMeta = this.entityClass.definition.relations['customer'];
      this.customer = createBelongsToAccessor(
        customerMeta as BelongsToDefinition,
        customerRepositoryGetter,
        this,
      );

      const shipmentrMeta = this.entityClass.definition.relations['shipment'];
      this.shipment = createBelongsToAccessor(
        shipmentrMeta as BelongsToDefinition,
        shipmentRepositoryGetter,
        this,
      );
    }
  };