{"id":13836901,"url":"https://github.com/goadesign/gorma","last_synced_at":"2025-04-04T11:09:05.963Z","repository":{"id":57484102,"uuid":"47219865","full_name":"goadesign/gorma","owner":"goadesign","description":"Storage generation plugin for Goa","archived":false,"fork":false,"pushed_at":"2024-11-17T01:18:57.000Z","size":21317,"stargazers_count":141,"open_issues_count":35,"forks_count":36,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-28T10:02:33.799Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://goa.design","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/goadesign.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":"2015-12-01T21:56:34.000Z","updated_at":"2025-03-03T12:24:03.000Z","dependencies_parsed_at":"2022-08-26T12:23:53.457Z","dependency_job_id":null,"html_url":"https://github.com/goadesign/gorma","commit_stats":null,"previous_names":["bketelsen/gorma"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goadesign%2Fgorma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goadesign%2Fgorma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goadesign%2Fgorma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goadesign%2Fgorma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goadesign","download_url":"https://codeload.github.com/goadesign/gorma/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166144,"owners_count":20894652,"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":[],"created_at":"2024-08-04T15:00:56.860Z","updated_at":"2025-04-04T11:09:05.945Z","avatar_url":"https://github.com/goadesign.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"\n# gorma\nGorma is a storage generator for [goa](http://goa.design).\n\n\u003eNote: Gorma is not compatible with Goa v2 or v3 and requires [v1](https://github.com/goadesign/goa/tree/v1).\n\n[![GoDoc](https://godoc.org/github.com/goadesign/gorma?status.svg)](http://godoc.org/github.com/goadesign/gorma) [![Build Status](https://travis-ci.org/goadesign/gorma.svg?branch=master)](https://travis-ci.org/goadesign/gorma) [![Go Report Card](https://goreportcard.com/badge/github.com/goadesign/gorma)](https://goreportcard.com/report/github.com/goadesign/gorma)\n\n## Table of Contents\n\n- [Purpose](#purpose)\n- [Opinionated](#opinionated)\n- [Translations](#translations)\n- [Use](#use)\n\n\n## Purpose\nGorma uses a custom `goa` DSL to generate a working storage system for your API.\n\n\n## Opinionated\nGorma generates Go code that uses [gorm](https://github.com/jinzhu/gorm) to access your database, therefore it is quite opinionated about how the data access layer is generated.\n\nBy default, a primary key field is created as type `int` with name ID.  Also Gorm's magic date stamp fields `created_at`, `updated_at` and `deleted_at` are created.  Override this behavior with the Automatic* DSL functions on the Store.\n\n\n## Translations\nUse the `BuildsFrom` and `RendersTo` DSL to have Gorma generate translation functions to translate your model\nto Media Types and from Payloads (User Types).  If you don't have any complex business logic in your controllers, this makes a typical controller function 3-4 lines long.\n\n## Use\nWrite a storage definition using DSL from the `dsl` package.  Example:\n\n```go\nvar sg = StorageGroup(\"MyStorageGroup\", func() {\n\tDescription(\"This is the global storage group\")\n\tStore(\"mysql\", gorma.MySQL, func() {\n\t\tDescription(\"This is the mysql relational store\")\n\t\tModel(\"Bottle\", func() {\n\t\t\tBuildsFrom(func() {\n\t\t\t\tPayload(\"myresource\",\"actionname\")  // e.g. \"bottle\", \"create\" resource definition\n\t\t\t})\n\n\t\t\tRendersTo(Bottle)\t\t\t\t\t\t// a Media Type definition\n\t\t\tDescription(\"This is the bottle model\")\n\n\t\t\tField(\"ID\", gorma.Integer, func() {    // Required for CRUD getters to take a PK argument!\n\t\t\t\tPrimaryKey()\n\t\t\t\tDescription(\"This is the ID PK field\")\n\t\t\t})\n\n\t\t\tField(\"Vintage\", gorma.Integer, func() {\n\t\t\t\tSQLTag(\"index\")\t\t\t\t\t\t// Add an index\n\t\t\t})\n\n\t\t\tField(\"CreatedAt\", gorma.Timestamp)\n\t\t\tField(\"UpdatedAt\", gorma.Timestamp)\t\t\t // Shown for demonstration\n\t\t\tField(\"DeletedAt\", gorma.NullableTimestamp)  // These are added by default\n\t\t})\n\t})\n})\n```\n\nSee the [`dsl` GoDoc](https://godoc.org/github.com/goadesign/gorma/dsl) for all the details and options.\n\nFrom the root of your application, issue the `goagen` command as follows:\n\n```\n$ goagen --design=github.com/gopheracademy/congo/design gen --pkg-path=github.com/goadesign/gorma\n```\n\nBe sure to replace `github.com/gopheracademy/congo/design` with the design package of your `goa` application.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoadesign%2Fgorma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoadesign%2Fgorma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoadesign%2Fgorma/lists"}