How to use the @loopback/repository.ModelDefinition 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 / loopback4-example-microservices / services / account-without-juggler / repositories / account / models / Account.ts View on Github external
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: loopback4-example-microservices
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {Entity, model, ModelDefinition} from '@loopback/repository';

@model(require('./account/model-definition'))
export class Account extends Entity {
  static definition = new ModelDefinition(
    require('./account/model-definition').properties,
  );
  static modelName = 'Account';

  id: string;
  customerNumber: string;
  balance: number;
  branch: string;
  type: string;
  avgBalance: number;
  minimumBalance: number;

  constructor(body?: Partial) {
    super();
    if (body) {
      Object.assign(this, body);
github strongloop / loopback-next / examples / todo / src / controllers / model-admin.controller.ts View on Github external
length: 512,
            precision: null,
            scale: null,
            mysql: {
              columnName: 'city',
              dataType: 'varchar',
              dataLength: 512,
              dataPrecision: null,
              dataScale: null,
              nullable: 'Y',
            },
          },
       }}
     */

  return new ModelDefinition({
    name: jugglerDef.name,
    // TODO: convert from juggler/LB3 style to LB4
    // For example, we need to transform array-type definitions from
    // {type: ['string']} to {type: 'array', itemType: 'string'}
    properties: jugglerDef.properties,
    settings: jugglerDef.options,
  });
}