How to use the @loopback/repository.getModelRelations 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-json-schema / src / filter-json-schema.ts View on Github external
skip: {
        type: 'integer',
        minimum: 0,
      },

      order: {
        type: 'array',
        items: {
          type: 'string',
        },
      },
    },
    additionalProperties: false,
  };

  const modelRelations = getModelRelations(modelCtor);
  const hasRelations = Object.keys(modelRelations).length > 0;

  if (hasRelations) {
    schema.properties!.include = {
      type: 'array',
      items: {
        type: 'object',
        properties: {
          // TODO(bajtos) restrict values to relations defined by "model"
          relation: {type: 'string'},
          // TODO(bajtos) describe the filter for the relation target model
          scope: scopeFilter,
        },
      },
    };
  }