Skip to content

Commit

Permalink
implemented BookRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
VikashChauhan51 committed Jul 23, 2024
1 parent ec984c0 commit 1cedd78
Show file tree
Hide file tree
Showing 208 changed files with 109,777 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ swag init -g cmd/api/main.go
```
go mod int <package_name>
go get <package_url>
go mod vendor
go mod tidy
go mod vendor
swag init -g cmd/api/main.go
Expand Down
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ require (
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.16.3
gorm.io/driver/sqlserver v1.5.3
gorm.io/gorm v1.25.11
)

require (
Expand All @@ -27,14 +29,19 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/microsoft/go-mssqldb v1.6.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down
89 changes: 89 additions & 0 deletions go.sum

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions internal/infra/repositories/book_repository.go
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
package repositories

import (
"github.com/VikashChauhan51/go-sample-api/internal/core/entities"
interfaces "github.com/VikashChauhan51/go-sample-api/internal/core/interfaces/repositories"
_ "gorm.io/driver/sqlserver"
"gorm.io/gorm"
)

type BookRepository struct {
db *gorm.DB
}

func NewBookRepository(db *gorm.DB) interfaces.BookRepository {
return &BookRepository{db}
}

func (r *BookRepository) FetchBooksAsync() (*[]entities.Book, error) {
var books []entities.Book
result := r.db.Find(&books)
if result.Error != nil {
return nil, result.Error
}
return &books, nil
}
73 changes: 73 additions & 0 deletions vendor/github.com/golang-sql/civil/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

202 changes: 202 additions & 0 deletions vendor/github.com/golang-sql/civil/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/golang-sql/civil/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1cedd78

Please sign in to comment.