qmysql

Mysql,TypeScript

Usage no npm install needed!

<script type="module">
  import qmysql from 'https://cdn.skypack.dev/qmysql';
</script>

README

Qmysql

基于 TypeScript 使用 Promise 封装了 node 里连接 mysql 和 Crud 等操作,解决了回调问题可直接 async 和 await, 让你更专注于业务代码

npm i qmysql

引入包,按需导入 Mysqlinit,qmysql 类

Mysqlinit 类

  • new Mysqlinit(你的 Option).init(),创建会返回连接对象,这意味着你可以开始你的 query 了

qmysql 类

_ 不必写繁琐的 select..from,你只需要按照内置的中文提示编写,剩下的都交给 qmysql _

  • new qmysql(你的 Option),自动创建连接并且调用相应的 CRUD 方法

  • new qmysql(你的 Option).Querys(sql: string, arr?: Array | undefined): Promise; 这是一个万能查询语句

  • new qmysql(你的 Option).Query( range: string, table: string, where?: string | undefined, Other?: string | undefined ): Promise; 查询 Sql

  • new qmysql(你的 Option). insertInto( table: string, insertValue: string, Placeholder: string, values: Array, where?: string, Other?: string ): Promise; 插入字段 Sql

  • new qmysql(你的 Option).modify(table: string, whichValue: string, whoChanged: string): Promise 修改 Sql;

  • new qmysql(你的 Option).strikeOut(table: string, whichValue: string): Promise 删除 Sql;

  • new qmysql(你的 Option).disconnect(end: boolean, destroy: boolean): void 断开连接 ;

  • new qmysql(你的 Option).Affairs(option?: QueryOptions): Promise 开启事务 ;

  • new qmysql(你的 Option).Close(option?: QueryOptions): Promise 关闭事务 ;

⚠️ 需要注意的是. sql 修改,删除,添加等操作的如果是 varchar 类型需要额外加上引号

new qmysql(Options).modify("User", "Password='1234'","id=1")

_ new Qmysql(Options).Querys 是万能语句 ,可点击源码查看详情 _

🍺 开箱即用