我使用的是mysql2软件包。我正在节点中执行简单的sql查询。那为什么它要
public async getTests(req: Request, res: Response): Promise<void> {
const pool = await connect();
const stmt = 'SELECT test, test2 FROM testTable';
const tests = await pool.query(stmt);
res.json({ tests});
}查询结果:
{ foo,foo1 },ColumnDefinition { _buf:<缓冲器01 00 01 0a 51 00 00 02 64 64 65 61 75 72 6f 72 61 5f 61 75 74 5f 73 69 67 6e 61 6c 0a 65 665 6d 65 6e 74 e 65 6A 65 6e 67 671 bytes>,
1200,,
发布于 2021-10-18 22:28:32
查询函数返回行&字段。请尝试获取行:
const [rows] = await pool.query(stmt);
有关详细信息,您可以查看下面的链接。https://github.com/sidorares/node-mysql2#using-promise-wrapper
https://stackoverflow.com/questions/69599546
复制相似问题