【问题标题】:Node MySQL connection resultset having issue节点 MySQL 连接结果集有问题
【发布时间】:2021-10-14 19:03:44
【问题描述】:

使用 MySQL 连接节点(使用 mysql2/promise)

const sql = `
            SELECT *
            FROM Applicant
            WHERE ApplicationId = ?
            `;

const result = await this.mysqlManager.Query(sql,number);
console.log(result);



public async Query(sql: any, parameters?: any, connection?: PoolConnection): Promise<any>
    {
        const con = connection || (await this.GetConnection());
        try
        {
            const data = await con.query(sql, parameters);
            return data;
        }
        catch (error)
        {
            con.release();
            throw error;
        }
    }

但得到回应

列定义{ _buf:, _clientEncoding: 'utf8', _catalogLength:3, _catalogStart: 2329, _schemaLength: 8, _schemaStart: 2333, _tableLength:9, _tableStart:2342, _orgTableLength: 9, _orgTableStart: 2352, _orgNameLength:16, _orgNameStart: 2379, 字符集:224, 编码:'utf8', 名称:'SalaryDayRangeTo', 列长度​​:80, 列类型:253, 标志:0, 小数:0 }

有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: mysql sql node.js


    【解决方案1】:

    const data = await con.query(sql, parameters);返回数据[0];

    因为第一个元素由数据组成,而其他属性则由模式信息组成。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-08
      • 2011-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-29
      相关资源
      最近更新 更多