npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

h-mysql

v1.0.25

Published

一直以来很喜欢Thinkphp的数据操作风格,所以在nodejs上也封装了一个MYSQL数据库的常用操作,支持链式调用,实现语义化的数据库操作。

Downloads

173

Readme

h-mysql

  • 网站访问项目github地址
  • 介绍:一直以来很喜欢Thinkphp的数据操作风格,所以在nodejs上也封装了一个MYSQL数据库的常用操作,支持链式调用,实现语义化的数据库操作。

安装及引用


// npm安装
npm i h-mysql --save

// yarn安装
yarn add h-mysql

const hMysql = require('h-mysql');

初始化配置

const hMysql = new mysql({
  host: '127.0.0.1',
  user: 'root',
  password: '',
  database: 'test-db',
  port: 3306,

  acquireTimeout: 1000,
  waitForConnections: true,     //是否等待链接  
  connectionLimit: 10,          // 连接池数
  queueLimit: 0,                // 排队限制 

  defaultSqlPre: '',
  isPool: true,
  isDebug: true
});

const {error, result} = await hMysql.table('user')
  .where({ id: 100 })
  .select()
  .execSql();

console.log(result);

调用方式

规则:调用方法跟顺序无关

let hMysql = new hMysql(config)

hMysql.table()
      .where()
      .limit()
      .select()
      .execSql()

CURD操作

  • 添加:[insert] [table] [data]
  • 查询:[select] [field] from [table] [alias] [where] [join]
  • 更新:[update] [table] set [data] [where]
  • 删除:[delete] from [table] [where]

API 文档

迭代计划

  • [ ] 完善API文档、架构文档
  • [ ] 完善案例
  • [ ] 批量插入、批量更新、批量删除
  • [ ] 支持更复杂的链式操作
  • [ ] 添加测试用例
  • [ ] 重写异常处理方式
  • [ ] 添加性能测试、性能优化并添加每条语句执行的时间
  • [ ] 添加安全测试,防注入
  • [ ] 增加对数据库的操作(现在的功能都是针对表)
  • [ ] 考虑是不是要支持ORM

版本更新

  • v1.0.0
    • 实现常用方法的链式调用,未经过测试,慎用到生产环境,待更新到完善

项目骨干

贡献

欢迎大家到 Issues 交流或通过提交PR的形式对本项目进行贡献

License

MIT