Thanks for reading. I currently have an Express server connected to a MySQL database and I would like to perform queried and for each row it finds, I would like to modify one or more of the variables. Below I will post two of my current snippets, one which finds all, and one which finds by id. Could somebody modify these codes to show how to change a variable or two in each (name them whatever).// FETCH all schools exports.findAll = (req, res) => { models.schools.findAll().then(school => { // Send all schools to Client res.send(school); }).catch(err => { res.status(500).send("Error -> " + err); }) }; // Find a school by id exports.findById = (req, res) => { models.schools.findById(req.params.id).then(school => { res.send(school); }).catch(err => { res.status(500).send("Error -> " + err); }) }; Also, sorry but I just thought of another question. Is there a way to do an array to the MySQL table so say at a set interval I grab a reading and put it into a table and pop off the oldest number? Say I want to store the last 10 numbers added to continuously without storing more than those 10?Thanks for your help in advance. I know these are probably easy questions for some of you but they've been really bogging my progress down and I'm not finding what I'm looking for online.
Submitted November 23, 2019 at 03:57AM by mrcandyman
No comments:
Post a Comment