{"id":35061753,"url":"https://github.com/javiorfo/gormen","last_synced_at":"2026-01-31T17:13:36.469Z","repository":{"id":318990324,"uuid":"1076429848","full_name":"javiorfo/gormen","owner":"javiorfo","description":"Go library for enhancing Gorm (CRUD, Hexagonal Architecture, Paging, Sorting and Filtering)","archived":false,"fork":false,"pushed_at":"2026-01-16T14:55:21.000Z","size":70,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-17T11:28:25.970Z","etag":null,"topics":["clean-architecture","crud","filtering","go","go-library","golang","gorm","pagination","sorting"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/javiorfo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-14T21:08:30.000Z","updated_at":"2026-01-16T14:54:36.000Z","dependencies_parsed_at":"2026-01-14T01:02:04.035Z","dependency_job_id":null,"html_url":"https://github.com/javiorfo/gormen","commit_stats":null,"previous_names":["javiorfo/gormix","javiorfo/gormen"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/javiorfo/gormen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiorfo%2Fgormen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiorfo%2Fgormen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiorfo%2Fgormen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiorfo%2Fgormen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/javiorfo","download_url":"https://codeload.github.com/javiorfo/gormen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiorfo%2Fgormen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28948361,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T14:26:55.697Z","status":"ssl_error","status_checked_at":"2026-01-31T14:26:52.545Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-architecture","crud","filtering","go","go-library","golang","gorm","pagination","sorting"],"created_at":"2025-12-27T10:46:40.458Z","updated_at":"2026-01-31T17:13:36.429Z","avatar_url":"https://github.com/javiorfo.png","language":"Go","funding_links":["https://www.paypal.com/donate/?hosted_button_id=FA7SGLSCT2H8G"],"categories":[],"sub_categories":[],"readme":"# gormen\n*Go library for enhancing Gorm (CRUD, Hexagonal Architecture, Paging, Sorting and Filtering)*\n\n## Description\nThis library provides a high-level, ergonomic API for enhancing [Gorm](https://github.com/go-gorm/gorm). \nIt offers a CRUD API, Paging, Sorting and Filtering. Allowing simple implementation or hexagonal architecture decoupling interface.\nRoughly inspired in Java **CrudRepository** and **PagingAndSortingRepository** interfaces.\n\n## Caveats\n- This library requires Go 1.23+\n\n## Intallation\n```bash\ngo get -u github.com/javiorfo/gormen@latest\n```\n\n## Example Std Repository\n#### More examples [here](https://github.com/javiorfo/gormen/tree/master/examples)\n```go\npackage main\n\nimport (\n  \"context\"\n  \"log\"\n  \"github.com/glebarez/sqlite\"\n  \"github.com/javiorfo/gormen\"\n  \"github.com/javiorfo/gormen/pagination/sort\"\n  \"github.com/javiorfo/gormen/std\"\n  \"github.com/javiorfo/gormen/where\"\n  \"gorm.io/gorm\"\n)\n\nfunc main() {\n  ctx := context.Background()\n\n  var repo gormen.Repository[UserDB]\n  repo = std.NewRepository[UserDB](SetupDB())\n\n  user1 := UserDB{\n    Username: \"batch1\",\n    Password: \"1234\",\n    Person: PersonDB{\n      Name:  \"Batch 1\",\n      Email: \"b1@mail.com\",\n    },\n  }\n  user2 := UserDB{\n    Username: \"batch2\",\n    Password: \"1234\",\n    Person: PersonDB{\n      Name:  \"Batch 2\",\n      Email: \"b2@mail.com\",\n    },\n  }\t\n  user3 := UserDB{\n    Username: \"batch3\",\n    Password: \"1234\",\n    Person: PersonDB{\n      Name:  \"Batch 3\",\n      Email: \"b3@mail.com\",\n    },\n  }\n  users := []UserDB{user1, user2, user3}\n\n  err = repo.CreateAll(ctx, \u0026users, 3)\n  if err != nil {\n    log.Fatalf(\"Error creating users %v\", err)\n  }\n\n  opt, _ := repo.FindBy(ctx, gormen.NewWhere(where.Like(\"username\", \"2%\")).Build(), \"Person\")\n  opt.Consume(func(ud UserDB) {\n    log.Printf(\"%+v\", ud)\n  })\n\n  orders := []sort.Order{sort.NewOrder(\"username\", sort.Descending)}\n  users, err = repo.FindAllOrdered(ctx, orders, \"Person\")\n  if err != nil {\n    log.Fatalf(\"Error searching users %v\", err)\n  }\n  log.Printf(\"%+v\", users)\n}\n```\n\n## Example Converter Repository (Hexagonal Arch)\n#### More examples [here](https://github.com/javiorfo/gormen/tree/master/examples)\n```go\n// Converter data must satisfies converter interface\n\n// User model\ntype User struct {\n  ID       uint\n  Username string\n  Password string\n  Enable   bool\n}\n\n// User DB\ntype UserDB struct {\n  ID       uint   `gorm:\"primaryKey;autoIncrement\"`\n  Username string `gorm:\"not null\"`\n  Password string `gorm:\"not null\"`\n  Enable   bool\n}\n\nfunc (udb UserDB) TableName() string {\n  return \"users\"\n}\n\n// Satisfies converter interface\nfunc (udb *UserDB) From(u User) {\n  udb.ID = u.ID\n  udb.Username = u.Username\n  udb.Password = u.Password\n  udb.Enable = u.Enable\n}\n\n// Satisfies converter interface\nfunc (udb UserDB) Into() User {\n  return User{\n    ID:       udb.ID,\n    Username: udb.Username,\n    Password: udb.Password,\n    Enable:   udb.Enable,\n  }\n}\n\n// Then the implementation\ntype userRepo struct {\n  gormen.Repository[User]\n}\n\nfunc NewUserRepo(db *gorm.DB) userRepo {\n  return userRepo{\n    // converter.Repository converts inside from UserDB to User and vice versa\n    // Applying From(M) or Into() M, as needed\n    Repository: converter.NewRepository[UserDB, *UserDB](db),\n  }\n}\n\nfunc (u *userRepo) FindAll(ctx context.Context, pageable pagination.Pageable) (*pagination.Page[User], error) {\n  return u.FindAllPaginated(ctx, pageable)\n}\n\nfunc (u *userRepo) FindByUsername(ctx context.Context, username string) (nilo.Option[User], error) {\n  return u.FindBy(ctx, gormen.NewWhere(where.Equal(\"username\", username)).Build())\n}\n\n```\n\n## Available interfaces\n#### Any of these satisfies std.Repository or converter.Repository \n```go\n// Repository defines a generic interface combining CUD (Create, Update, Delete)\n// and Read operations for a model type M.\ntype Repository[M any] interface {\n  CudRepository[M]\n  ReadRepository[M]\n}\n\n// CudRepository defines generic Create, Update, and Delete operations for model M.\ntype CudRepository[M any] interface {\n  Create(ctx context.Context, model *M) error\n  CreateAll(ctx context.Context, model *[]M, batchSize int) error\n  Delete(ctx context.Context, model *M) error\n  DeleteAll(ctx context.Context, model []M) error\n  DeleteAllBy(ctx context.Context, where Where) error\n  Save(ctx context.Context, model *M) error\n  SaveAll(ctx context.Context, model []M) error\n}\n\n// ReadRepository defines generic read/query operations for model M.\ntype ReadRepository[M any] interface {\n  Count(ctx context.Context) (int64, error)\n  CountBy(ctx context.Context, where Where) (int64, error)\n  FindBy(ctx context.Context, where Where, preloads ...Preload) (nilo.Option[M], error)\n  FindAll(ctx context.Context, preloads ...Preload) ([]M, error)\n  FindAllBy(ctx context.Context, where Where, preloads ...Preload) ([]M, error)\n  FindAllPaginated(ctx context.Context, pageable pagination.Pageable, preloads ...Preload) (*pagination.Page[M], error)\n  FindAllPaginatedBy(ctx context.Context, pageable pagination.Pageable, where Where, preloads ...Preload) (*pagination.Page[M], error)\n  FindAllOrdered(ctx context.Context, orders []sort.Order, preloads ...Preload) ([]M, error)\n}\n```\n\n---\n\n### Donate\n- **Bitcoin** [(QR)](https://raw.githubusercontent.com/javiorfo/img/master/crypto/bitcoin.png)  `1GqdJ63RDPE4eJKujHi166FAyigvHu5R7v`\n- [Paypal](https://www.paypal.com/donate/?hosted_button_id=FA7SGLSCT2H8G)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaviorfo%2Fgormen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaviorfo%2Fgormen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaviorfo%2Fgormen/lists"}