Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bangadam/gorm-repository-boilerplate
implementation repository pattern in gorm with easily to use and testable
https://github.com/bangadam/gorm-repository-boilerplate
boilerplate go golang gorm template
Last synced: 2 days ago
JSON representation
implementation repository pattern in gorm with easily to use and testable
- Host: GitHub
- URL: https://github.com/bangadam/gorm-repository-boilerplate
- Owner: bangadam
- License: gpl-3.0
- Created: 2022-11-26T07:54:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-02T04:07:30.000Z (almost 2 years ago)
- Last Synced: 2024-06-20T01:49:59.904Z (5 months ago)
- Topics: boilerplate, go, golang, gorm, template
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Gorm Repository Boilerplate
About |
Features |
Technologies |
Requirements |
Usage |
License |
Author
## :dart: About
Gorm Repository Boilerplate is a boilerplate for gorm repository pattern. It is a providing basic functions to CRUD and query entities as well as transactions and common error handling. It is a good starting point for gorm repository pattern.
## :sparkles: Features
:heavy_check_mark: CRUD
## :rocket: Technologies
The following tools were used in this project:
- [Golang](https://golang.org/)
- [Gorm](https://gorm.io/)## :white_check_mark: Requirements
Before starting :checkered_flag:, you need to have [Go](https://golang.org/) installed.
## :checkered_flag: Usage
```go
package baseimport "github.com/bangadam/gorm-repository-boilerplate"
type BaseRepository interface {
gormrepository.TransactionRepository
FindByName(target interface{}, name string, preloads ...string) error
}type repository struct {
gormrepository.TransactionRepository
}func NewRepository(db *gorm.DB, logger logging.Logger) BaseRepository {
return &repository{
TransactionRepository: gormrepository.NewGormRepository(db, logger, "Creator"),
}
}func (r *repository) FindByName(target interface{}, name string, preloads ...string) error {
return r.TransactionRepository.FindOneByField(target, "name", name, preloads...)
}
```## :memo: License
This project is under license from MIT. For more details, see the [LICENSE](LICENSE.md) file.
Made with :heart: by bangadam