{"id":20249747,"url":"https://github.com/kamichidu/goen","last_synced_at":"2025-06-28T18:09:56.941Z","repository":{"id":57496667,"uuid":"136322600","full_name":"kamichidu/goen","owner":"kamichidu","description":"GOlang ENtity interface, similar to ORM but not fully featured","archived":false,"fork":false,"pushed_at":"2020-01-31T05:05:44.000Z","size":251,"stargazers_count":12,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T22:45:18.821Z","etag":null,"topics":["database","go","golang","orm-like"],"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/kamichidu.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}},"created_at":"2018-06-06T12:01:22.000Z","updated_at":"2020-07-13T23:44:14.000Z","dependencies_parsed_at":"2022-09-03T02:30:30.285Z","dependency_job_id":null,"html_url":"https://github.com/kamichidu/goen","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/kamichidu/goen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamichidu%2Fgoen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamichidu%2Fgoen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamichidu%2Fgoen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamichidu%2Fgoen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kamichidu","download_url":"https://codeload.github.com/kamichidu/goen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamichidu%2Fgoen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262474057,"owners_count":23316911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["database","go","golang","orm-like"],"created_at":"2024-11-14T09:55:27.467Z","updated_at":"2025-06-28T18:09:56.926Z","avatar_url":"https://github.com/kamichidu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/kamichidu/goen.svg?branch=master)](https://travis-ci.org/kamichidu/goen)\n[![wercker status](https://app.wercker.com/status/12a1429eafda5aafa0d10f4946551e37/s/master \"wercker status\")](https://app.wercker.com/project/byKey/12a1429eafda5aafa0d10f4946551e37)\n[![Coverage Status](https://coveralls.io/repos/github/kamichidu/goen/badge.svg)](https://coveralls.io/github/kamichidu/goen)\n[![godoc](https://godoc.org/github.com/kamichidu/goen?status.svg)](https://godoc.org/github.com/kamichidu/goen)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kamichidu/goen)](https://goreportcard.com/report/github.com/kamichidu/goen)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://raw.githubusercontent.com/kamichidu/goen/master/LICENSE)\n\n\n# goen\n\ngoen is a typesafe GOlang ENtity interface for relational databases.\n\nIt provides a way of programmatically to interact with relational databases.\nIt aims to implement in a go way and not to provide fully ORM features.\n\ngoen has following concepts:\n\n- No any fields or methods introducing into user's struct\n- Work with plain go's `database/sql`\n- Based on RTTI\n- Support bulk operation\n- Go generate is used only for utilities, it's not a core logic\n\n## Installation\n\n```\ngo get -u github.com/kamichidu/goen/...\n```\n\ngoen provides a binary tool used by go generate, please be sure that `$GOPATH/bin` is on your `$PATH` .\n\n## Usage\n\nWrite your first entity is.\n\n```\npackage entity\n\ntype User struct {\n    UserID int `goen:\"\" primary_key:\"\"`\n    Name, Email, PasswordHash string\n}\n```\n\nThen put the following on any file of that package:\n\n```\n//go:generate goen -o goen.go\n```\n\nNow, all you have to do is run `go generate ./...` and a `goen.go` file will be generated.\n\n## Define entities\n\nAn entity is just a go struct have a struct tag `goen:\"\"` .\nAll fields of this struct will be columns in the database table.\nAn entity also needs to have one primary key.\nThe primary key is defined using the `primary_key:\"\"` struct tag on the primary key fields.\n\nLet's review the rules and conventions for entity fields:\n\n- All the fields with basic types or types that implement sql.Scanner and driver.Valuer will be considered a column in the table of their matching type.\n- By default, the name of a table/view will be the name of the struct converted to lower snake case (e.g.`User` =\u003e `user`, `UserFriend` =\u003e `user_friend`)\n- By default, the name of a column will be the name of the struct field converted to lower snake case (e.g. `UserName` =\u003e `user_name`, `UserID` =\u003e `user_id`). You can override it with the struct tag `column:\"custom_name\"`.\n\n## Struct tags\n\n| Tag | Description |\n| --- | --- |\n| `goen:\"\"` | Indicates this struct as an entity. goen finds structs that have this struct tag. |\n| `table:\"table_name\"` | Specifies a table name. |\n| `view:\"view_name\"` | Specifies a view name for readonly entity. |\n| `primary_key:\"\"` | Indicates this field is a part of primary key |\n| `primary_key:\"column_name\"` | Indicates this field is a part of primary key and specifies a column name |\n| `primary_key:\"column_name,omitempty\"` | Indicates this field is a part of primary key, specifies a column name and this field is omitting if empty |\n| `primary_key:\",omitempty\"` | Indicates this field is a part of primary key, and this field is omitting if empty |\n| `column:\"column_name\"` | Specifies a column name |\n| `column:\"column_name,omitempty\"` | Specifies a column name and this field is omitting if empty |\n| `column:\",omitempty\"` | Specifies this field is omitting if empty |\n| `foreign_key:\"column_name\"` | Indicates this field is referencing another entity, and specifies keys |\n| `foreign_key:\"column_name1,column_name2:reference_column_name\"` | Indicates this field is referencing another entity, and specifies key pairs |\n| `ignore:\"\"` | Specifies this columns is to be ignored |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamichidu%2Fgoen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamichidu%2Fgoen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamichidu%2Fgoen/lists"}