{"id":15096041,"url":"https://github.com/elegantsoft/go-restful-generator","last_synced_at":"2026-04-01T20:54:01.030Z","repository":{"id":37588975,"uuid":"504301622","full_name":"ElegantSoft/go-restful-generator","owner":"ElegantSoft","description":"generate crud rest api in go and gin in no time ","archived":false,"fork":false,"pushed_at":"2025-02-13T11:15:29.000Z","size":141,"stargazers_count":86,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T11:06:42.325Z","etag":null,"topics":["crud","crud-generator","generator","gin","go","golang","gorm","swagger"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ElegantSoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2022-06-16T20:48:00.000Z","updated_at":"2025-03-22T07:26:48.000Z","dependencies_parsed_at":"2025-03-24T08:21:25.794Z","dependency_job_id":null,"html_url":"https://github.com/ElegantSoft/go-restful-generator","commit_stats":null,"previous_names":["elegantsoft/go-crud-starter"],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElegantSoft%2Fgo-restful-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElegantSoft%2Fgo-restful-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElegantSoft%2Fgo-restful-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ElegantSoft%2Fgo-restful-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ElegantSoft","download_url":"https://codeload.github.com/ElegantSoft/go-restful-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247640462,"owners_count":20971557,"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":["crud","crud-generator","generator","gin","go","golang","gorm","swagger"],"created_at":"2024-09-25T15:45:11.721Z","updated_at":"2026-04-01T20:54:00.989Z","avatar_url":"https://github.com/ElegantSoft.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go gin crud starter\nThis repo could be used as a kind of inherited CRUD api, and it will save a lot of time.\n\n## story\n\nI used to handle crud operations in Nodejs with nest crud package, and it is fully compatible with react admin.\nI've never spent any time to make sorting or selecting or filtering functionalities. I was able to create\nadmin dashboard in no time. When I switched to golang I missed these productive tools so I decided to create it.\n\n\n## Features\n- Full crud features\n- sorting, selecting and do complex filters like nested \"and\" \u0026 \"or\" queries\n- add joins and nested joins from uri\n- compatible with [ra-admin](https://www.radmin.com/)\n- inspired from [@nestjsx/crud](https://github.com/nestjsx/crud)\n\n## packages I am using\n- Gin\n- Gorm\n- Postgres\n- Air\n- Swagger\n\nFell free to make PR to add other frameworks or ORMs\n## How to use\n\n### Install\n`go install github.com/ElegantSoft/go-restful-generator/cmd/crudgen@latest`\n\n- create new golang project\n- go get github.com/ElegantSoft/go-restful-generator@latest\n- create db/models folder for models\n- create db/db.go with package db for db connection\n\n\n`crudgen service --name service-name --path lib/apps/service-name`\n\n### Configuration\n- Create `.env` file for configuration.\n- Add to it `DB_URL` as a connection string which is in used by [Gorm](https://gorm.io/docs/connecting_to_the_database.html)\n- By default `PORT` is configured on 8080, but you can specify in the `.env` file a different `PORT` if you like so.\n- If you want to have the documentation also updated then follow the next steps:\n  - Install `swaggo` with `go install github.com/swaggo/swag/cmd/swag@latest`\n  - Run in terminal `swag init` which will update the swagger files in the `docs` directory.\n\n### See examples as posts then duplicate it\n\nFirst you can see how crud api works by running project and go to `/docs/index.html`\n\n- duplicate posts folder\n- change package name\n- create your entity in models folder\n- replace `model` struct in `repository.go`\n\n### requests params\n- [Query params](#query-params)\n    - [select](#select)\n    - [search](#search)\n    - [filter conditions](#filter-conditions)\n    - [filter](#filter)\n    - [or](#or)\n    - [sort](#sort)\n    - [join](#join)\n    - [limit](#limit)\n    - [offset](#offset)\n    - [page](#page)\n    - [cache](#cache)\n- [Frontend usage](#frontend-usage)\n    - [Customize](#customize)\n    - [Usage](#usage)\n\n## Query params\n\nBy default, we support these param names:\n\n`fields` - get selected fields in GET result\n\n`s` - search conditions (`$and`, `$or` with all possible variations)\n\n`filter` - filter GET result by `AND` type of condition\n\n`join` - receive joined relational resources in GET result (with all or selected fields)\n\n`sort` - sort GET result by some `field` in `ASC | DESC` order\n \n`limit` - limit the amount of received resources\n\n`page` - receive a portion of limited amount of resources\n\n\n**_Notice:_** You can easily map your own query params names and chose another string delimiters by applying [global options](https://github.com/nestjsx/crud/wiki/Controllers#global-options).\n\nHere is the description of each of those using default params names:\n\n### select\n\nSelects fields that should be returned in the reponse body.\n\n_Syntax:_\n\n\u003e ?fields=**field1**,**field2**,...\n\n_Example:_\n\n\u003e ?fields=**email**,**name**\n\n### search\n\nAdds a search condition as a JSON string to you request. You can combine `$and`, `$or` and use any [condition](#filter-conditions) you need. Make sure it's being sent encoded or just use [`RequestQueryBuilder`](#frontend-usage)\n\n_Syntax:_\n\n\u003e ?s={\"name\": \"Michael\"}\n\n_Some examples:_\n\n- Search by field `name` that can be either `null` OR equals `Superman`\n\n\u003e ?s={\"name\": {\"**\\$or**\": {\"**\\$isnull**\": true, \"**\\$eq**\": \"Superman\"}}}\n\n- Search an entity where `isActive` is `true` AND `createdAt` not equal `2008-10-01T17:04:32`\n\n\u003e ?s={\"**\\$and**\": [{\"isActive\": true}, {\"createdAt\": {\"**$ne**\": \"2008-10-01T17:04:32\"}}]}\n\n...which is the same as:\n\n\u003e ?s={\"isActive\": true, \"createdAt\": {\"**\\$ne**\": \"2008-10-01T17:04:32\"}}\n\n- Search an entity where `isActive` is `false` OR `updatedAt` is not `null`\n\n\u003e ?s={\"**\\$or**\": [{\"isActive\": false}, {\"updatedAt\": {\"**$notnull**\": true}}]}\n\nSo the amount of combinations is really huge.\n\n**_Notice:_** if search query param is present, then [filter](#filter) and [or](#or) query params will be ignored.\n\n### filter conditions\n\n- **`$eq`** (`=`, equal)\n- **`$ne`** (`!=`, not equal)\n- **`$gt`** (`\u003e`, greater than)\n- **`$lt`** (`\u003c`, lower that)\n- **`$gte`** (`\u003e=`, greater than or equal)\n- **`$lte`** (`\u003c=`, lower than or equal)\n- **`$cont`** (`LIKE %val%`, contains)\n\n### filter\n\nAdds fields request condition (multiple conditions) to your request.\n\n_Syntax:_\n\n\u003e ?filter=**field**||**\\$condition**||**value**\n\n\u003e ?join=**relation**\u0026filter=**relation**.**field**||**\\$condition**||**value**\n\n**_Notice:_** Using nested filter shall join relation first.\n\n_Examples:_\n\n\u003e ?filter=**name**||**\\$eq**||**batman**\n\n\u003e ?filter=**isVillain**||**\\$eq**||**false**\u0026filter=**city**||**\\$eq**||**Arkham** (multiple filters are treated as a combination of `AND` type of conditions)\n\n\u003e ?filter=**shots**||**\\$in**||**12**,**26** (some conditions accept multiple values separated by commas)\n\n\u003e ?filter=**power**||**\\$isnull** (some conditions don't accept value)\n\n### or\n\nAdds `OR` conditions to the request.\n\n_Syntax:_\n\n\u003e ?or=**field**||**\\$condition**||**value**\n\nIt uses the same [filter conditions](#filter-conditions).\n\n_Rules and examples:_\n\n- If there is only **one** `or` present (without `filter`) then it will be interpreted as simple [filter](#filter):\n\n\u003e ?or=**name**||**\\$eq**||**batman**\n\n- If there are **multiple** `or` present (without `filter`) then it will be interpreted as a compination of `OR` conditions, as follows:  \n  `WHERE {or} OR {or} OR ...`\n\n\u003e ?or=**name**||**\\$eq**||**batman**\u0026or=**name**||**\\$eq**||**joker**\n\n- If there are **one** `or` and **one** `filter` then it will be interpreted as `OR` condition, as follows:  \n  `WHERE {filter} OR {or}`\n\n\u003e ?filter=**name**||**\\$eq**||**batman**\u0026or=**name**||**\\$eq**||**joker**\n\n- If present **both** `or` and `filter` in any amount (**one** or **miltiple** each) then both interpreted as a combitation of `AND` conditions and compared with each other by `OR` condition, as follows:  \n  `WHERE ({filter} AND {filter} AND ...) OR ({or} AND {or} AND ...)`\n\n\u003e ?filter=**type**||**\\$eq**||**hero**\u0026filter=**status**||**\\$eq**||**alive**\u0026or=**type**||**\\$eq**||**villain**\u0026or=**status**||**\\$eq**||**dead**\n\n### sort\n\nAdds sort by field (by multiple fields) and order to query result.\n\n_Syntax:_\n\n\u003e ?sort=**field**,**ASC|DESC**\n\n_Examples:_\n\n\u003e ?sort=**name**,**ASC**\n\n\u003e ?sort=**name**,**ASC**\u0026sort=**id**,**DESC**\n\n### join\n\nReceive joined relational objects in GET result (with all or selected fields). You can join as many relations as allowed in your [CrudOptions](https://github.com/nestjsx/crud/wiki/Controllers#join).\n\n_Syntax:_\n\n\u003e ?join=**relation**\n\n\u003e ?join=**relation**||**field1**,**field2**,...\n\n\u003e ?join=**relation1**||**field11**,**field12**,...\u0026join=**relation1**.**nested**||**field21**,**field22**,...\u0026join=...\n\n_Examples:_\n\n\u003e ?join=**profile**\n\n\u003e ?join=**profile**||**firstName**,**email**\n\n\u003e ?join=**profile**||**firstName**,**email**\u0026join=**notifications**||**content**\u0026join=**tasks**\n\n\u003e ?join=**relation1**\u0026join=**relation1**.**nested**\u0026join=**relation1**.**nested**.**deepnested**\n\n**_Notice:_** primary field/column always persists in relational objects. To use nested relations, the parent level **MUST** be set before the child level like example above.\n\n### limit\n\nReceive `N` amount of entities.\n\n_Syntax:_\n\n\u003e ?limit=**number**\n\n_Example:_\n\n\u003e ?limit=**10**\n\n### offset\n\nLimit the amount of received resources\n\n_Syntax:_\n\n\u003e ?offset=**number**\n\n_Example:_\n\n\u003e ?offset=**10**\n\n### page\n\nReceive a portion of limited amount of resources.\n\n_Syntax:_\n\n\u003e ?page=**number**\n\n_Example:_\n\n\u003e ?page=**2**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felegantsoft%2Fgo-restful-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felegantsoft%2Fgo-restful-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felegantsoft%2Fgo-restful-generator/lists"}