Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 node demo.js 无法运行事例 #1

Open
fengdanbailu opened this issue Aug 3, 2020 · 0 comments
Open

使用 node demo.js 无法运行事例 #1

fengdanbailu opened this issue Aug 3, 2020 · 0 comments

Comments

@fengdanbailu
Copy link

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant