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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ali-rds-async

v0.0.2

Published

使用co模块改造ali-rds连接数据库sdk成promise

Downloads

5

Readme

ali-rds-async

申明

SDK仅仅是将ali-rdsSDKgenerator书写方法使用co 模块改造成现在市场上流行的Promise的方式,参考文档直接看ali-rds 官网就可以

使用示例

  • 1、安装模块

    npm install ali-rds-async
  • 2、导包及连接数据库

    import AsyncAliRds from 'ali-rds-async';
    // or
    const { AsyncAliRds } = require('ali-rds-async');
    
    const config = {
      host: 'your-rds-address.mysql.rds.aliyuncs.com',
      port: 3306,
      user: 'your-username',
      password: 'your-password',
      database: 'your-database-name',
    
      // optional params
      // The charset for the connection.
      // This is called "collation" in the SQL-level of MySQL (like utf8_general_ci).
      // If a SQL-level charset is specified (like utf8mb4)
      // then the default collation for that charset is used. (Default: 'UTF8_GENERAL_CI')
      // charset: 'utf8_general_ci',
      //
      // The maximum number of connections to create at once. (Default: 10)
      // connectionLimit: 10,
      //
      // The maximum number of connection requests the pool will queue
      // before returning an error from getConnection.
      // If set to 0, there is no limit to the number of queued connection requests. (Default: 0)
      // queueLimit: 0,
    };
    // 创建连接
    let mysql = new AsyncAliRds(config);
  • 3、使用案例

    (async () => {
      const r = await mysql.query('select * from dog');
      console.log(r);
    })();
    
    (async () => {
      const r = await mysql.select('dog');
      console.log('结果2', r);
    })();
    
    (async () => {
      const r = await mysql.insert('dog', { name: '小狗', color: '黄色' });
      console.log('结果', r);
    })();

主要实现的方法

  • [x] query使用原生sql语句
  • [x] insert插入语句
  • [x] update更新单条语句
  • [x] updateRows更新多条语句
  • [x] get获取一条数据
  • [x] select查询数据
  • [x] delete删除数据
  • [x] count计数
  • [x] beginTransaction事务