I'm new to express and react. Can I use models in express like using models in Angular?
I have a function for the query:
export async function YesNo(productName: string) {
return executeQueri("SELECT Transactions.TimeStamp,Transactions.ID,Transactions.DeviceId,Customers.SourceScreen,Customers.ProductName FROM Transactions INNER JOIN Customers ON Transactions.ID=Customers.TransactionId WHERE ProductName LIKE '%"+productName+"%'");
}
and i want it to look like this:
{
"TimeStamp": "01-08-2021-02-35-19-299",
"Id": "74a0fe4c-0e0e-4yVc-b887-993bc300887P",
"DeviceId": "digitalSignage_1",
"Report": [
{
"SourceScreen": "Recipe",
"ProductName": "Mariestad ?l 2,8%"
"ProductAvailabilty": "Success or Fail"
}
]
}
Do i need to create model here?
app.get('/productAvailability/:productname', async (req, res) => {
const results = await YesNo(req.params.productname);
res.json({results} );
})
question from:
https://stackoverflow.com/questions/65902689/change-the-output-of-the-query-in-express 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…