> This 3 does not exist : database error TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
> at deleteData (file:///C:/Users/Ammar%20Khan/WebstormProjects/expressdb/models/database.mjs:72:28)
> at file:///C:/Users/Ammar%20Khan/WebstormProjects/expressdb/main.mjs:41:32
> at Layer.handle [as handle_request] (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\layer.js:95:5)
> at next (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\route.js:149:13)
> at Route.dispatch (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\route.js:119:3)
> at Layer.handle [as handle_request] (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\layer.js:95:5)
> at C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\index.js:284:15
> at param (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\index.js:365:14)
> at param (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\index.js:376:14)
> at Function.process_params (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\index.js:421:3)
> C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\mysql2\promise.js:94
> const localErr = new Error();
> ^
*> *
> Error: Cannot delete or update a parent row: a foreign key constraint fails (expressdb
.courses
, CONSTRAINT courses_ibfk_1
FOREIGN KEY (st_id
) REFERENCES student
(st_id
))
> at PromiseConnection.query (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\mysql2\promise.js:94:22)
> at deleteData (file:///C:/Users/Ammar%20Khan/WebstormProjects/expressdb/models/database.mjs:72:39)
> at file:///C:/Users/Ammar%20Khan/WebstormProjects/expressdb/main.mjs:41:32
> at Layer.handle [as handle_request] (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\layer.js:95:5)
> at next (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\route.js:149:13)
> at Route.dispatch (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\route.js:119:3)
> at Layer.handle [as handle_request] (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\layer.js:95:5)
> at C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\index.js:284:15
> at param (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\index.js:365:14)
> at param (C:\Users\Ammar Khan\WebstormProjects\expressdb\node_modules\express\lib\router\index.js:376:14) {
> code: ‘ER_ROW_IS_REFERENCED_2’,
> errno: 1451,
> sql: 'delete from student \n where st_id = 3\n ',
> sqlState: ‘23000’,
> sqlMessage: ‘Cannot delete or update a parent row: a foreign key constraint fails (expressdb
.courses
, CONSTRAINT courses_ibfk_1
FOREIGN KEY (st_id
) REFERENCES student
(st_id
))’
> }
*> *
> Node.js v22.2.0
> [nodemon] app crashed - waiting for file changes before starting….