Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        


Gorm Repository Boilerplate

 


Gorm Repository Boilerplate


Github top language

Github language count

Repository size

License

Github issues

Github forks

Github stars


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 base

import "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

 

Back to top