haizlin / h-mysql Goto Github PK
View Code? Open in Web Editor NEW一直以来很喜欢Thinkphp的数据操作风格,所以在nodejs上也封装了一个MYSQL数据库的常用操作,支持链式调用,实现语义化的数据库操作。
License: MIT License
一直以来很喜欢Thinkphp的数据操作风格,所以在nodejs上也封装了一个MYSQL数据库的常用操作,支持链式调用,实现语义化的数据库操作。
License: MIT License
1)按例子写,会报错如下:
const {error, result}= await hMysql.table('mytable').where().select().execSql();
^^^^^
SyntaxError: await is only valid in async function
2)去掉 await,返回值是一个 promise;不报错,但没有响应结果
2020-08-03 13:50:00 | SELECT * FROM mytable
undefined
3)如果只是第一句const result= hMysql.table('mytable');console.log(result);
不报错,能返回一个大对象,如下
hMysql {
connection: Pool {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
config: PoolConfig {
acquireTimeout: 1000,
connectionConfig: [ConnectionConfig],
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0
},
_acquiringConnections: [],
_allConnections: [],
_freeConnections: [],
_connectionQueue: [],
_closed: false,
[Symbol(kCapture)]: false
},
sqlObj: { table: 'mytable' },
tempObj: {},
config: {
host: 'localhost',
port: 3306,
user: 'root',
password: '‘,
database: 'exercise',
acquireTimeout: 1000,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
isPool: true,
defaultSqlPre: '',
isDebug: true
},
mixed: {
table: [Function: bound table],
alias: [Function: bound alias],
field: [Function: bound field],
where: [Function: bound where],
data: [Function: bound data],
order: [Function: bound order],
limit: [Function: bound limit],
page: [Function: bound page],
join: [Function: bound join],
union: [Function: bound union],
distinct: [Function: bound distinct],
lock: [Function: bound lock],
comment: [Function: bound comment],
group: [Function: bound group],
having: [Function: bound having],
count: [Function: bound count],
max: [Function: bound max],
min: [Function: bound min],
avg: [Function: bound avg],
sum: [Function: bound sum],
select: [Function: bound select],
find: [Function: bound find],
update: [Function: bound update],
insert: [Function: bound insert],
delete: [Function: bound delete],
query: [Function: bound query],
connect: [Function: bound connect],
poolEvent: [Function: bound poolEvent],
execSql: [Function: bound execSql] AsyncFunction,
transaction: [Function: bound transaction] AsyncFunction
},
isMixedWith: [Function (anonymous)],
pageNum: 1,
pageSize: 50
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.