1.1.1 • Published 6 years ago

egg-loopback v1.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

egg-loopback

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-loopback --save

Usage

// {app_root}/config/plugin.js
exports.loopback = {
  enable: true,
  package: 'egg-loopback',
};

Configuration

// {app_root}/config/config.default.js
exports.eggLoopback = {
  app: true,
  client: {
    dir: path.join(appInfo.baseDir, 'app/loopback'),
  }
};

see config/config.default.js for more detail.

Example

loopback-test

// {app_root}/app/controller
module.exports = app => {

  class DemoController extends app.Controller {
    * index() {

      const { Test } = this.app.eggLoopback.models;

      this.ctx.body = yield Test.find();
    }

    * create() {

      const { name } = this.ctx.query;
      const { Test } = this.app.eggLoopback.models;

      yield Test.create({ name });
      this.ctx.body = yield Test.find();
    }

  }

  return DemoController;

};

Questions & Suggestions

Please open an issue here.

License

MIT