Now takes both id and type because there is two different sets of id pools, and need to select the corrent one.
This commit is contained in:
@@ -22,7 +22,7 @@ class RequestRepository {
|
||||
this.queries = {
|
||||
'insertRequest': "INSERT INTO requests VALUES (?, ?, ?, ?, ?, ?, CURRENT_DATE, 'requested', ?)",
|
||||
'fetchRequstedItems': "SELECT * FROM requests",
|
||||
'updateRequestedById': "UPDATE requests SET status = ? WHERE id is ?",
|
||||
'updateRequestedById': "UPDATE requests SET status = ? WHERE id is ? AND type is ?",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ class RequestRepository {
|
||||
return this.database.all(this.queries.fetchRequstedItems);
|
||||
}
|
||||
|
||||
updateRequestedById(id, status) {
|
||||
return this.database.run(this.queries.updateRequestedById, [status, id]);
|
||||
updateRequestedById(id, type, status) {
|
||||
return this.database.run(this.queries.updateRequestedById, [status, id, type]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,9 +9,10 @@ const requestRepository = new RequestRepository();
|
||||
*/
|
||||
function updateRequested(req, res) {
|
||||
const id = req.params.requestId;
|
||||
const type = req.body.type;
|
||||
const status = req.body.status;
|
||||
|
||||
requestRepository.updateRequestedById(id, status)
|
||||
requestRepository.updateRequestedById(id, type, status)
|
||||
.then(() => {
|
||||
res.send({ success: true });
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user