I have two tables which are give in at this fiddle.
http://sqlfiddle.com/#!9/d37102
I want to retrieve data from the table currently I am doing this way
mysqlConnection.query("SELECT* FROM wallet WHERE user_id = ? ORDER by date",authData.id,(err,rows,fields)=>{
if(!err){
res.json({
message :"Statement",
rechargeDetails : rows,
transactionDetail://// TODO: Transaction details
});
}
else console.log(err);
});
That is correctly retrieving the JSON data in at this format over here
{
"message": "Statement",
"rechargeDetails": [
{
"id": 17,
"amount": 50,
"type": "CREDIT",
"pg_id": "xxxxq123",
"comments": null,
"intrument_type": "REFUND",
"user_id": 1,
"date": "2020-04-17T18:30:00.000Z"
},
{
"id": 18,
"amount": 50,
"type": "CREDIT",
"pg_id": "xxxxq123",
"comments": null,
"intrument_type": "REFUND",
"user_id": 1,
"date": "2020-04-17T18:30:00.000Z"
}
]
}
I want to get transaction table data also like this
{
"message": "Statement",
"rechargeDetails": [
{
"id": 17,
"amount": 50,
"type": "CREDIT",
"pg_id": "xxxxq123",
"comments": null,
"intrument_type": "REFUND",
"user_id": 1,
"date": "2020-04-17T18:30:00.000Z"
},
{
"id": 18,
"amount": 50,
"type": "CREDIT",
"pg_id": "xxxxq123",
"comments": null,
"intrument_type": "REFUND",
"user_id": 1,
"date": "2020-04-17T18:30:00.000Z"
}
"transactionDetails": [
{
"id": 17,
"amount": 50,
"tax": "CREDIT",
"discount": "xxxxq123",
"adjustment": null,
"refrence_id": "REFUND",
"payment_ref_id": 1,
xxxxxx
xxxxxxxxxx
}
],
}
How could i do that? Is there a way to do this?