Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
149 views
in Technique[技术] by (71.8m points)

reactjs - Change the output of the query in express

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...