nodejs和mysql使用压缩字符串

时间:2014-04-09 22:16:19

标签: mysql node.js compression

我有一个已经压缩的字符串,当我运行像

这样的查询时
var mysql      = require('mysql');
...
connection.connect();

connection.query("select uncompress(name) from car where id = 1", function(err, rows, fields) {
if (err) throw err;
  console.log('uncompress: ', rows[0]);
});

我得到了回复

//console
//uncompress <Buffer 5b 7b 22 32 30 34 35 22 3a 7b 22 74 69 6d 65 53 74 61 6d 70 22 3a 31 33 39 36 38 37 36 37 37 35 38 33 35 2c 22 73 74 61 74 65 22 3a 7b 22 76 22 3a 31 2c ...> }

如何获得实际价值?

1 个答案:

答案 0 :(得分:0)

我明白了。您需要确保将缓冲区转换为如下字符串:

rows [0] [&#39; YOU_QUERY_RESULT&#39;]。toString()