Question: How to setup a function to edit item with reference to same like remove item function below: import mysql from ' mysql ' export const
How to setup a function to edit item with reference to same like remove item function below: import mysql from mysql
export const handler async event
get credentials from the dbaccess layer loaded separately via AWS console
var pool mysqlcreatePool
host: "replace your api"
eastrdsamazonaws.com",
user: "replace user",
password: "replace password",
database: "replace database"
;
let RemoveItem itemID
return new Promiseresolve reject
pool.queryDELETE FROM Items WHERE itemIDitemIDerror rows
if error return rejecterror;
if rows && rowsaffectedRows
return resolvetrue;
else
return resolvefalse;
;
;
let response
try
const result await RemoveItemeventitemID
if result
response statusCode: result: "success": true
else
response statusCode: error: No such item"
catch err
response statusCode: error: err
pool.end close DB connections
return response;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
