Skip to content

Repositories

Piotr Kowalczuk edited this page Sep 6, 2018 · 4 revisions

Repository separates the logic that retrieves the data and maps it to the entity model from the business logic that acts on the model. Every table defined within the schema will get corresponding repository.

type <Entity>RepositoryBase struct {
	Table   string 
    DB      *sql.DB
    Columns []string // optional
    Log     LogFunc // optional
}

It is highly recommended to define custom object that embeds base one. For example:

type <Entity>Repository struct {
	<Entity>RepositoryBase
}
Clone this wiki locally