I’m currently trying to add an edit option on my posts in my current project, I have created a function where it checks to see if the person is an admin or not and therefore, if they can edit posts, when they are allowed, I want the post to be updated; so far this is my code :
allowEditAdmin(postid, username).then(result => {
console.log('row check ===', result);
if (result.length) {
console.log("you are authorized to edit");
console.log(`"${post}"`);
console.log(`"${image}"`);
console.log(postid);
db.query(
`UPDATE post SET post = ${post}, image = ${image} WHERE id = ?`, postid, (err4, results4) => {
console.log('admin post row update success ===', results4);
res.send(results4);
})
} else {
console.log("you are not authorized to edit");
}
})
In the console I am getting all the correct information (my variables and “you are authorized to edit”) however, my sql database is not updating with the information I am trying to give it. The table name is post, it contains 4 collumns named “id”, “username”, “post” and “image”. I am just getting in my console: “admin post row update success === undefined” on top of the console.logs of my variables and authorized message.
All help is much appreciated thanks!!