Socket
Book a DemoInstallSign in
Socket

@blued-core/mysql-client

Package Overview
Dependencies
Maintainers
4
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blued-core/mysql-client

基于 mysql2 和 sequelize 的一层封装。

latest
npmnpm
Version
2.0.1
Version published
Maintainers
4
Created
Source

基于 mysql2 和 sequelize 的一层封装。

npm i @blued-core/mysql-client

API与 Sequelize 保持一致,内置定时更新 Client 之类的功能。

使用方式:

cache 与 mysql-conf 组件都为可选的,可以自己根据描述自定义

import Cache from '@blued-core/cache'
import { MysqlConf } from '@blued-core/mysql-conf'
import MysqlClient, { QueryTypes } from '@blued-core/mysql-client'

const mysqlConf = new MysqlConf({
  mysql1: {
    qconf: 'XXX',
    database: 'XX database'
  }
})

async function main () {
  // 如不想安装 Cache ,则可使用 new Map() 代替
  const mysqlClient = new MysqlClient(mysqlConf, new Cache())

  const mysql = mysqlClient.getClient('mysql1')

  const results = await mysql.query(
    `SELECT col1, col2 FROM table LIMIT 10;`,
    { type: QueryTypes.SELECT }
  )
}

main()

FAQs

Package last updated on 28 Oct 2020

Did you know?

Socket

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