{"id":37171667,"url":"https://github.com/feymanlee/storeit","last_synced_at":"2026-01-14T20:01:52.132Z","repository":{"id":176686948,"uuid":"627724327","full_name":"feymanlee/storeit","owner":"feymanlee","description":"Easy store data with GORM","archived":false,"fork":false,"pushed_at":"2025-09-18T12:03:52.000Z","size":94,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-18T14:34:38.714Z","etag":null,"topics":["golang","gorm","orm","repository","sql"],"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/feymanlee.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":"2023-04-14T04:10:35.000Z","updated_at":"2025-09-18T12:03:28.000Z","dependencies_parsed_at":"2024-01-08T13:51:03.958Z","dependency_job_id":"67c8bfb4-0c5f-488a-9480-79d2da6a1480","html_url":"https://github.com/feymanlee/storeit","commit_stats":null,"previous_names":["feymanlee/storeit"],"tags_count":53,"template":false,"template_full_name":null,"purl":"pkg:github/feymanlee/storeit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feymanlee%2Fstoreit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feymanlee%2Fstoreit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feymanlee%2Fstoreit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feymanlee%2Fstoreit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/feymanlee","download_url":"https://codeload.github.com/feymanlee/storeit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feymanlee%2Fstoreit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"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":["golang","gorm","orm","repository","sql"],"created_at":"2026-01-14T20:01:51.551Z","updated_at":"2026-01-14T20:01:52.126Z","avatar_url":"https://github.com/feymanlee.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# storeit\n\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/feymanlee/storeit?style=flat-square)\n[![Go Report Card](https://goreportcard.com/badge/github.com/feymanlee/storeit)](https://goreportcard.com/report/github.com/feymanlee/cacheit)\n[![Unit-Tests](https://github.com/feymanlee/storeit/workflows/Unit-Tests/badge.svg)](https://github.com/feymanlee/storeit/actions)\n[![codecov](https://codecov.io/gh/feymanlee/storeit/graph/badge.svg?token=S8M4CFG0NB)](https://codecov.io/gh/feymanlee/storeit)\n[![Go Reference](https://pkg.go.dev/badge/github.com/feymanlee/storeit.svg)](https://pkg.go.dev/github.com/feymanlee/cacheit)\n[![License](https://img.shields.io/github/license/feymanlee/storeit)](./LICENSE)\n\n## Tag List\n| Tag           | Value Type     | SQL Statment                        | DESC                   |\n|---------------|----------------|-------------------------------------|------------------------|\n| field:eq      | any            | feild = value                       |                        |\n| field:neq     | any            | feild \u003c\u003e value                      |                        |\n| field:gt      | any            | feild \u003e value                       |                        |\n| field:gte     | any            | feild \u003e= value                      |                        |\n| field:lt      | any            | feild \u003c value                       |                        |\n| field:lte     | any            | feild \u003c= value                      |                        |\n| field:like    | string         | feild LIKE \"%value%\"                |                        |\n| field:llike   | string         | feild LIKE \"%value\"                 |                        |\n| field:rlike   | string         | feild LIKE \"value%\"                 |                        |\n| field:in      | []any          | feild IN (value)                    |                        |\n| field:notin   | []any          | feild IN (value)                    |                        |\n| field:isnull  | any            | feild IS NULL                       |                        |\n| field:notnull | []any          | feild IS NOT NULL                   |                        |\n| field:between | []any (len==2) | feild BETWEEN value[0] AND value[1] |                        |\n| -:sort        | string         | ORDER BY a DESC, b, c DESC          | value is a-,b+,c-      |\n| -:page        | int            | OFFSET (value-1)*per_page           | Default per_page is 50 |\n| -:per_page    | int            | LIMIT value                         | Default  50            |\n| -:limit       | int            | LIMIT value                         |                        |\n| -:offset      | int            | OFFSET value                        |                        |\n\n## 在 gin 里面使用\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"database/sql\"\n\t\"log\"\n\t\"net/http\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/brianvoe/gofakeit/v6\"\n\t\"github.com/feymanlee/storeit\"\n\t\"github.com/gin-gonic/gin\"\n\t\"gorm.io/driver/sqlite\"\n\t\"gorm.io/gorm\"\n\t\"gorm.io/gorm/logger\"\n)\n\ntype User struct {\n\tID        int64        `gorm:\"column:id;primarykey\" json:\"id\"`\n\tUsername  string       `gorm:\"column:username\" json:\"username\"`\n\tEmail     string       `gorm:\"column:email\" json:\"email\"`\n\tMobile    string       `gorm:\"column:mobile\" json:\"mobile\"`\n\tStatus    string       `gorm:\"column:status\" json:\"status\"`\n\tWeight    int          `gorm:\"column:weight\" json:\"weight\"`\n\tSource    string       `gorm:\"column:source\" json:\"source\"`\n\tCreatedAt time.Time    `gorm:\"column:created_at\" json:\"created_at\"`\n\tUpdatedAt time.Time    `gorm:\"column:updated_at\" json:\"updated_at\"`\n\tDeletedAt sql.NullTime `gorm:\"column:email;index\"`\n}\n\nvar db *gorm.DB\n\nfunc init() {\n\tvar err error\n\tdb, err = gorm.Open(sqlite.Open(\"file::memory:?cache=shared\"), \u0026gorm.Config{\n\t\tLogger: logger.Default.LogMode(logger.Info),\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc main() {\n\trouter := gin.Default()\n\tv1 := router.Group(\"/api/v1\")\n\t{\n\t\tv1.GET(\"/users\", SearchUser)\n\t\tv1.POST(\"/users\", CreateUser)\n\t\tv1.GET(\"/user/:id\", FindUser)\n\t\tv1.PUT(\"/users/:id\", UpdateUser)\n\t\tv1.DELETE(\"/users/:id\", DeleteUser)\n\t}\n\trouter.Run(\":8180\")\n}\nfunc SearchUser(c *gin.Context) {\n\tvar req struct {\n\t\tID      int    `form:\"id\" criteria:\"id,eq\"`\n\t\tKeyword string `form:\"keyword\" criteria:\"phone,email:like\"`\n\t\tName    string `form:\"name\" criteria:\"name:llike\"`\n\t\tPhone   int    `form:\"phone\" criteria:\"phone:eq\"`\n\t\tStatus  string `form:\"status\" criteria:\"status:eq\"`\n\t\tWeight  int    `form:\"weight\" criteria:\"weight:eq\"`\n\t\tSource  string `form:\"source\"`\n\t\tPage    int    `form:\"page\" criteria:\"-:page\"`\n\t\tPerPage int    `form:\"per_page\" criteria:\"-:per_page\"`\n\t\tSorts   string `form:\"sorts\" criteria:\"-:sort\"`\n\t}\n\tif err := c.ShouldBindQuery(\u0026req); err != nil {\n\t\tlog.Println(err)\n\t}\n\tcriteria, _ := storeit.ExtractCriteria(req)\n\t// source 是多个值，使用英文逗号分隔\n\tcriteria.WhereIn(\"source\", strings.Split(req.Source, \",\"))\n\t// 实现自动分页\n\tret, _ := storeit.New[User](db).Paginate(c, criteria)\n\n\tc.JSON(http.StatusOK, ret)\n}\n\nfunc FindUser(c *gin.Context) {\n\tuser, _ := storeit.New[User](db).FindByID(c, c.Params.ByName(\"id\"))\n\n\tc.JSON(200, user)\n}\n\nfunc CreateUser(c *gin.Context) {\n\tvar user User\n\t_ = c.ShouldBindJSON(\u0026user)\n\tstoreit.New[User](db).Insert(c, \u0026user)\n\tc.JSON(200, user)\n}\n\nfunc UpdateUser(c *gin.Context) {\n\tvar user User\n\t_ = c.ShouldBindJSON(\u0026user)\n\tid, _ := strconv.Atoi(c.Params.ByName(\"id\"))\n\tuser.ID = int64(id)\n\tstoreit.New[User](db).Save(c, \u0026user)\n\tc.JSON(200, user)\n}\n\nfunc DeleteUser(c *gin.Context) {\n\ttx := storeit.New[User](db).DeleteById(c, c.Params.ByName(\"id\"))\n\tif tx.Error != nil {\n\t\tc.AbortWithStatus(http.StatusBadRequest)\n\t}\n\tc.JSON(200, gin.H{\n\t\t\"id\": c.Params.ByName(\"id\"),\n\t})\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeymanlee%2Fstoreit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeymanlee%2Fstoreit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeymanlee%2Fstoreit/lists"}