Skip to content

bangadam/gorm-repository-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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


🎯 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.

✨ Features

✔️ CRUD

🚀 Technologies

The following tools were used in this project:

✅ Requirements

Before starting 🏁, you need to have Go installed.

🏁 Usage

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...)
}

📝 License

This project is under license from MIT. For more details, see the LICENSE file.

Made with ❤️ by bangadam

 

Back to top

About

implementation repository pattern in gorm with easily to use and testable

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages