Socket
Socket
Sign inDemoInstall

@hyoga/egg-mysql

Package Overview
Dependencies
328
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @hyoga/egg-mysql

EGGJS框架MYSQL库


Version published
Weekly downloads
6
increased by500%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@hyoga/egg-mysql

NPM version npm download

一个EGGJS的MySQL操作库,使用链式操作,方便快捷实现数据库操作。

依赖说明

依赖的 egg 版本

@hyoga/egg-mysql 版本egg 1.x
1.x😁
0.x

使用场景

  • eggjs使用mysql操作时,链式操作: mysql.table('user').field('name, id').select()
  • 插件依赖于@hyoga/mysql,更多API请查看@hyoga/mysql

安装

$ npm i @hyoga/egg-mysql --save

使用

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

// {app_root}/app/service/user.js
export default class User extends Service {
  private table = 'user';

  public async list() {
    // sql = SELECT * FROM user WHERE status = 1
    return this.app.mysql.table(this.table).where({ status: 1 }).select();
  }
}

配置

// {app_root}/config/config.default.js
exports.mysql = {
  client: {
    host: '127.0.0.1',
    port: '3306',
    user: 'root',
    password: '',
    database: 'db',
  },
  // 是否加载到 app 上,默认开启
  app: true,
  // 是否加载到 agent 上,默认关闭
  agent: false,
};

API

该插件依赖于@hyoga/mysql,更多API,请移步查看。

提问交流

请到 hyoga-egg-mysql 移步交流。

License

MIT

Keywords

FAQs

Last updated on 29 May 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc