@@ -12,8 +12,8 @@ import (
1212 "github.com/afteracademy/goserve-example-api-server-postgres/utils"
1313 coredto "github.com/afteracademy/goserve/v2/dto"
1414 "github.com/afteracademy/goserve/v2/network"
15+ "github.com/afteracademy/goserve/v2/postgres"
1516 "github.com/google/uuid"
16- "github.com/jackc/pgx/v5/pgxpool"
1717)
1818
1919type Service interface {
@@ -28,11 +28,11 @@ type Service interface {
2828}
2929
3030type service struct {
31- db * pgxpool. Pool
31+ db postgres. Database
3232 blogService blog.Service
3333}
3434
35- func NewService (db * pgxpool. Pool , blogService blog.Service ) Service {
35+ func NewService (db postgres. Database , blogService blog.Service ) Service {
3636 return & service {
3737 db : db ,
3838 blogService : blogService ,
@@ -85,7 +85,7 @@ func (s *service) CreateBlog(
8585 status
8686 `
8787
88- err := s .db .QueryRow (
88+ err := s .db .Pool (). QueryRow (
8989 ctx ,
9090 query ,
9191 d .Title ,
@@ -138,7 +138,7 @@ func (s *service) UpdateBlog(
138138 var blogID uuid.UUID
139139 var currentSlug string
140140
141- err := s .db .QueryRow (
141+ err := s .db .Pool (). QueryRow (
142142 ctx ,
143143 selectQuery ,
144144 b .ID ,
@@ -225,7 +225,7 @@ func (s *service) UpdateBlog(
225225
226226 args = append (args , blogID , author .ID )
227227
228- tag , err := s .db .Exec (ctx , updateQuery , args ... )
228+ tag , err := s .db .Pool (). Exec (ctx , updateQuery , args ... )
229229 if err != nil {
230230 return nil , err
231231 }
@@ -254,7 +254,7 @@ func (s *service) DeactivateBlog(
254254 AND status = TRUE
255255 `
256256
257- tag , err := s .db .Exec (
257+ tag , err := s .db .Pool (). Exec (
258258 ctx ,
259259 query ,
260260 blogID ,
@@ -289,7 +289,7 @@ func (s *service) BlogSubmission(
289289 AND status = TRUE
290290 `
291291
292- tag , err := s .db .Exec (
292+ tag , err := s .db .Pool (). Exec (
293293 ctx ,
294294 query ,
295295 submit ,
@@ -341,7 +341,7 @@ func (s *service) GetBlogById(
341341
342342 var b model.Blog
343343
344- err := s .db .QueryRow (ctx , query , id , author .ID ).
344+ err := s .db .Pool (). QueryRow (ctx , query , id , author .ID ).
345345 Scan (
346346 & b .ID ,
347347 & b .Title ,
@@ -450,7 +450,7 @@ func (s *service) getPaginated(
450450 ctx := context .Background ()
451451 offset := (p .Page - 1 ) * p .Limit
452452
453- rows , err := s .db .Query (ctx , query , author .ID , p .Limit , offset )
453+ rows , err := s .db .Pool (). Query (ctx , query , author .ID , p .Limit , offset )
454454 if err != nil {
455455 return nil , err
456456 }
0 commit comments