1- import { OkPacket } from "mysql2" ;
1+ import { ResultSetHeader } from "mysql2" ;
22import connection from "../db" ;
33
44import Tutorial from "../models/tutorial.model" ;
@@ -15,7 +15,7 @@ interface ITutorialRepository {
1515class TutorialRepository implements ITutorialRepository {
1616 save ( tutorial : Tutorial ) : Promise < Tutorial > {
1717 return new Promise ( ( resolve , reject ) => {
18- connection . query < OkPacket > (
18+ connection . query < ResultSetHeader > (
1919 "INSERT INTO tutorials (title, description, published) VALUES(?,?,?)" ,
2020 [ tutorial . title , tutorial . description , tutorial . published ? tutorial . published : false ] ,
2121 ( err , res ) => {
@@ -65,7 +65,7 @@ class TutorialRepository implements ITutorialRepository {
6565
6666 update ( tutorial : Tutorial ) : Promise < number > {
6767 return new Promise ( ( resolve , reject ) => {
68- connection . query < OkPacket > (
68+ connection . query < ResultSetHeader > (
6969 "UPDATE tutorials SET title = ?, description = ?, published = ? WHERE id = ?" ,
7070 [ tutorial . title , tutorial . description , tutorial . published , tutorial . id ] ,
7171 ( err , res ) => {
@@ -78,7 +78,7 @@ class TutorialRepository implements ITutorialRepository {
7878
7979 delete ( tutorialId : number ) : Promise < number > {
8080 return new Promise ( ( resolve , reject ) => {
81- connection . query < OkPacket > (
81+ connection . query < ResultSetHeader > (
8282 "DELETE FROM tutorials WHERE id = ?" ,
8383 [ tutorialId ] ,
8484 ( err , res ) => {
@@ -91,7 +91,7 @@ class TutorialRepository implements ITutorialRepository {
9191
9292 deleteAll ( ) : Promise < number > {
9393 return new Promise ( ( resolve , reject ) => {
94- connection . query < OkPacket > ( "DELETE FROM tutorials" , ( err , res ) => {
94+ connection . query < ResultSetHeader > ( "DELETE FROM tutorials" , ( err , res ) => {
9595 if ( err ) reject ( err ) ;
9696 else resolve ( res . affectedRows ) ;
9797 } ) ;
0 commit comments