ali-rds-async
申明
本SDK
仅仅是将ali-rds的SDK
的generator
书写方法使用co 模块改造成现在市场上流行的Promise
的方式,参考文档直接看ali-rds 官网就可以
使用示例
-
1、安装模块
npm install ali-rds-async -
2、导包及连接数据库
;// orconst AsyncAliRds = ;const config =host: 'your-rds-address.mysql.rds.aliyuncs.com'port: 3306user: '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 = config;
-
3、使用案例
async {const r = await mysql;console;};async {const r = await mysql;console;};async {const r = await mysql;console;};
主要实现的方法
-
query
使用原生sql
语句 -
insert
插入语句 -
update
更新单条语句 -
updateRows
更新多条语句 -
get
获取一条数据 -
select
查询数据 -
delete
删除数据 -
count
计数 -
beginTransaction
事务