在查询的javascript对象中更改变量名称

时间:2014-07-19 14:01:50

标签: javascript mysql json node.js express

我在快递js中有这个查询:

connection.connect();

var queryString = 'xxxxxxxxxxxxxxx';

connection.query(queryString, function(err, rows, fields) {
if (err) throw err;

for(var i in rows){
rows[i].bestPrice = rows[i].MIN(inventory.price);
delete rows[i].MIN(inventory.price);
}


res.writeHead(200, { 'Content-Type': 'application/json'});
res.end(JSON.stringify(rows););
});

connection.end();

它正在询问有关笔记本电脑的一些细节。在我添加for循环之前,响应JSON部分看起来像这样:

displayType: "LED"
vga: "Intel Graphics Media Accelerat"
partNumber: "A0100001"
MIN(inventory.price): "40000"

我想将“MIN(inventory.price)”更改为“bestPrice”,但它不起作用。有什么建议吗?

0 个答案:

没有答案