{"id":37174619,"url":"https://github.com/devimteam/gorm-loggable","last_synced_at":"2026-01-14T20:24:04.677Z","repository":{"id":57496284,"uuid":"147346764","full_name":"devimteam/gorm-loggable","owner":"devimteam","description":"Loggable plugin for GORM","archived":false,"fork":true,"pushed_at":"2019-01-10T13:32:20.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-20T08:18:05.094Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"sas1024/gorm-loggable","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devimteam.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-09-04T13:00:49.000Z","updated_at":"2024-06-20T08:18:05.095Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/devimteam/gorm-loggable","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/devimteam/gorm-loggable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devimteam%2Fgorm-loggable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devimteam%2Fgorm-loggable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devimteam%2Fgorm-loggable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devimteam%2Fgorm-loggable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devimteam","download_url":"https://codeload.github.com/devimteam/gorm-loggable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devimteam%2Fgorm-loggable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434431,"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":[],"created_at":"2026-01-14T20:24:03.961Z","updated_at":"2026-01-14T20:24:04.658Z","avatar_url":"https://github.com/devimteam.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Loggable\n\nLoggable is used to helps tracking changes and history of your [GORM](https://github.com/jinzhu/gorm) models.\n\nIt creates `change_logs` table in your database and writes to all loggable models when they are changed.\n\n\n## Usage\n1. Register plugin using `loggable.Register(db)`.\n```go\nplugin, err := Register(database) // database is a *gorm.DB\nif err != nil {\n\tpanic(err)\n}\n```\n2. Add (embed) `loggable.LoggableModel` to your GORM model.\n```go\ntype User struct{\n    Id        uint\n    CreatedAt time.Time\n    // some other stuff...\n    \n    loggable.LoggableModel\n}\n```\n3. Changes after calling Create, Save, Update, Delete will be tracked.\n\n## Customization\nYou may add additional fields to change logs, that should be saved.  \nFirst, embed `loggable.LoggableModel` to your model wrapper or directly to GORM model.  \n```go\ntype CreatedByLog struct {\n\t// Public field will be catches by GORM and will be saved to main table.\n\tCreatedBy     string\n\t// Hided field because we do not want to write this to main table,\n\t// only to change_logs.\n\tcreatedByPass string \n\tloggable.LoggableModel\n}\n```\nAfter that, shadow `LoggableModel`'s `Meta()` method by writing your realization, that should return structure with your information.  \n```go\ntype CreatedByLog struct {\n\tCreatedBy     string\n\tcreatedByPass string \n\tloggable.LoggableModel\n}\n\nfunc (m CreatedByLog) Meta() interface{} {\n\treturn struct { // You may define special type for this purposes, here we use unnamed one.\n\t\tCreatedBy     string\n\t\tCreatedByPass string // CreatedByPass is a public because we want to track this field. \n\t}{\n\t\tCreatedBy:     m.CreatedBy,\n\t\tCreatedByPass: m.createdByPass,\n\t}\n}\n```\n\n## Options\n#### LazyUpdate\nOption `LazyUpdate` allows save changes only if they big enough to be saved.  \nPlugin compares the last saved object and the new one, but ignores changes was made in fields from provided list.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevimteam%2Fgorm-loggable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevimteam%2Fgorm-loggable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevimteam%2Fgorm-loggable/lists"}