{"id":18436080,"url":"https://github.com/codenotary/immugorm","last_synced_at":"2025-04-07T20:32:30.157Z","repository":{"id":44939435,"uuid":"405080030","full_name":"codenotary/immugorm","owner":"codenotary","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-15T15:50:54.000Z","size":222,"stargazers_count":16,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-06-19T03:02:25.340Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codenotary.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":"2021-09-10T12:53:06.000Z","updated_at":"2024-06-05T03:51:42.000Z","dependencies_parsed_at":"2022-08-30T09:31:18.434Z","dependency_job_id":null,"html_url":"https://github.com/codenotary/immugorm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenotary%2Fimmugorm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenotary%2Fimmugorm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenotary%2Fimmugorm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codenotary%2Fimmugorm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codenotary","download_url":"https://codeload.github.com/codenotary/immugorm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223291629,"owners_count":17120965,"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-11-06T06:10:14.729Z","updated_at":"2024-11-06T06:10:15.390Z","avatar_url":"https://github.com/codenotary.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IMMUGORM\nThis repository is a driver for [immudb](https://github.com/codenotary/immudb).  to act as a database for GORM. \n\n## Quick Start\nClone immudb repository, compile immudb and launch it:\n```shell\ngit clone https://github.com/codenotary/immudb\nmake immudb\n./immudb\n```\n\nBelow see an example on how to get GORM to work with immudb:\n\n```go\npackage main\n\nimport (\n    immugorm \"github.com/codenotary/immugorm\"\n    \"gorm.io/gorm\"\n    \"gorm.io/gorm/logger\"\n)\n\ntype Product struct {\n    ID     int `gorm:\"primarykey\"`\n    Code   string\n    Price  uint\n    Amount uint\n}\n\nfunc main() {\n    db, err := gorm.Open(immugorm.Open(\"immudb://immudb:immudb@127.0.0.1:3322/defaultdb?sslmode=disable\", \u0026immugorm.ImmuGormConfig{Verify: false}), \u0026gorm.Config{\n        Logger: logger.Default.LogMode(logger.Info),\n    })\n    if err != nil {\n        panic(err)\n    }\n\n    // Migrate the schema\n    err = db.AutoMigrate(\u0026Product{})\n    if err != nil {\n        panic(err)\n    }\n    // Create\n    err = db.Create(\u0026Product{Code: \"D43\", Price: 100, Amount: 500}).Error\n    if err != nil {\n        panic(err)\n    }\n    // Read\n    var product Product\n    // find just created one\n    err = db.First(\u0026product).Error\n    if err != nil {\n        panic(err)\n    }\n    // find product with code D42\n    err = db.First(\u0026product, \"code = ?\", \"D43\").Error\n    if err != nil {\n        panic(err)\n    }\n    // Update - update product's price to 200\n    err = db.Model(\u0026product).Update(\"Price\", 888).Error\n    if err != nil {\n        panic(err)\n    }\n\n    // Update - update multiple fields\n    err = db.Model(\u0026product).Updates(Product{Price: 200, Code: \"F42\"}).Error\n    if err != nil {\n        panic(err)\n    }\n\n    err = db.Model(\u0026product).Updates(map[string]interface{}{\"Price\": 200, \"Code\": \"F42\"}).Error\n    if err != nil {\n        panic(err)\n    }\n\n    // Delete - delete product\n    err = db.Delete(\u0026product, product.ID).Error\n    if err != nil {\n        panic(err)\n    }\n}\n```\n\n### Open with Immudb Options\nIt's possible open a connection with immudb options to provide more control over the connection or enable some features that are not available by standard DSN.\n```go\nimport (\n    \"github.com/codenotary/immudb/pkg/client\"\n    immugorm \"github.com/codenotary/immugorm\"\n    \"gorm.io/gorm\"\n    \"gorm.io/gorm/logger\"\n)\n\n...\n\nopts := client.DefaultOptions()\n\nopts.Username = \"immudb\"\nopts.Password = \"immudb\"\nopts.Database = \"defaultdb\"\nopts.HealthCheckRetries = 10\n\ndb, err := gorm.Open(immugorm.OpenWithOptions(opts, \u0026immugorm.ImmuGormConfig{Verify: false}), \u0026gorm.Config{\n    Logger: logger.Default.LogMode(logger.Info),\n})\n```\n\n## IMMUDB SPECIAL FEATURES\n\n### TamperProof read\nImmugorm is able to take benefits from immudb tamperproof capabilities.\nIt's possible to activate tamperproof read by setting  `Verify: true` when opening db.\nThe only difference is that verifications returns proofs needed to mathematically verify that the data was not tampered.\n\u003eNote that generating that proof has a slight performance impact.\n\u003e\n```go\n    db, err := gorm.Open(immugorm.Open(opts, \u0026immugorm.ImmuGormConfig{Verify: true}), \u0026gorm.Config{})\n```\n### Timetravel\n\nTime travel allows reading data from SQL as if it was in some previous state.\n\u003e The state is indicated by transaction id, that is a monotonically increasing number that is assigned to each transaction by immudb\n\u003e Each operation is assigned a transaction id.\n```go\ndb.Clauses(immugorm.BeforeTx(9)).Last(\u0026entity, 1)\n```\n\n## Warnings\n\nThis is an experimental software. The API is not stable yet and may change without notice.\nThere are limitations:\n* missing support related to altering or deleting already existent elements on schema. No drop table, index, alter table or column\n* missing float type\n* missing left join\n* no support for composite primary key\n* no support for polymorphism\n* no support for foreign constraints\n* is mandatory to have a primary key on tables\n* no default values\n* order is limit to one indexed column\n* group by not supported\n* no support for prepared statements\n* not condition missing\n* no transaction with savepoint\n* no nested transactions\n* having nor yet supported\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenotary%2Fimmugorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodenotary%2Fimmugorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodenotary%2Fimmugorm/lists"}