Skip to content
/ thindb Public

通用数据库连接和操作组件,如mysql、redis等

License

Notifications You must be signed in to change notification settings

Juuen/thindb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

thindb

基于 Nodejs 的通用数据库访问和操作组件,如 mysql、redis 等

Install

npm install thindb

Usage

实例化

const Thindb = require("thindb");
const thindb = new Thindb([...config]);

mysql

单数据库引用

let ddd=thindb.mysql.ddd();
ddd.execPromise({sp:"",token:"",data:""});

多数据库引用

let ddd=thindb.mysql.ddd();
ddd.execPromise({sp:"",token:"",data:""});

let ddd2=thindb.mysql.ddd("[poolName2]");
ddd2.execPromise({sp:"",token:"",data:""});

// 注:一般来说poolName值等于配置文件里面的database值

global 变量引用

// 当有多个数据库时候,该方式会选择配置里第一顺位数据库连接
global.ddd_mysql.exePromise({sp:"",token:"",data:""});

配置文件样例

{
	"dbconfig": [
		{
			"mysql": {
				"host": "[host]",
				"port": "[port]",
				"database": "[database]",
				"user": "[user]",
				"password": "[password]"
			}
		},
		{
			"mysql": {
				"host": "[host2]",
				"port": "[port2]",
				"database": "[database2]",
				"user": "[user2]",
				"password": "[password2]"
			}
		}
	]
}

About

通用数据库连接和操作组件,如mysql、redis等

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published