如何管理2个堆栈的查询

时间:2019-02-21 10:20:07

标签: sql node.js database api

我连续有2个查询,例如:

"SELECT A.id , A.name FROM A WHERE 1"

"SELECT b.val1, b.val2 FROM B WHERE B.id = result_from_A"

结果ID存储在数组中

var JSON_obj = JSON.parse(JSON.stringify(results_A));

for (let i = 0; i < JSON_obj.length; i++) {
    var A_Id = parseInt(JSON_obj[i].id);
    //query B from A_Id
}

以及如何使数据看起来像这样

[{"name" : "...",
  "data":[
     {"val1":...},
     {"val2":...}]
 },
 {"name" : "...",
  "data":[
     {"val1":...},
     {"val2":...}]
 }]

0 个答案:

没有答案